Package org.springframework.validation
Interface Errors
- All Known Subinterfaces:
BindingResult
- All Known Implementing Classes:
AbstractBindingResult,AbstractErrors,AbstractPropertyBindingResult,BeanPropertyBindingResult,BindException,DirectFieldBindingResult,EscapedErrors,MapBindingResult,WebExchangeBindException
public interface Errors
Stores and exposes information about data-binding and validation errors for a specific object.Field names can be properties of the target object (e.g. "name" when binding to a customer object), or nested fields in case of subobjects (e.g. "address.street"). Supports subtree navigation via
setNestedPath(String): for example, anAddressValidatorvalidates "address", not being aware that this is a subobject of customer.Note:
Errorsobjects are single-threaded.- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
setNestedPath(java.lang.String),BindException,DataBinder,ValidationUtils
Field Summary
Fields Modifier and Type Field Description static StringNESTED_PATH_SEPARATORThe separator between path elements in a nested path, for example in "customer.name" or "customer.address.street".
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddAllErrors(Errors errors)Add all errors from the givenErrorsinstance to thisErrorsinstance.List<ObjectError>getAllErrors()Get all errors, both global and field ones.intgetErrorCount()Return the total number of errors.FieldErrorgetFieldError()Get the first error associated with a field, if any.FieldErrorgetFieldError(String field)Get the first error associated with the given field, if any.intgetFieldErrorCount()Return the number of errors associated with a field.intgetFieldErrorCount(String field)Return the number of errors associated with the given field.List<FieldError>getFieldErrors()Get all errors associated with a field.List<FieldError>getFieldErrors(String field)Get all errors associated with the given field.Class<?>getFieldType(String field)Return the type of a given field.ObjectgetFieldValue(String field)Return the current value of the given field, either the current bean property value or a rejected update from the last binding.ObjectErrorgetGlobalError()Get the first global error, if any.intgetGlobalErrorCount()Return the number of global errors.List<ObjectError>getGlobalErrors()Get all global errors.StringgetNestedPath()Return the current nested path of thisErrorsobject.StringgetObjectName()Return the name of the bound root object.booleanhasErrors()Return if there were any errors.booleanhasFieldErrors()Are there any field errors?booleanhasFieldErrors(String field)Are there any errors associated with the given field?booleanhasGlobalErrors()Are there any global errors?voidpopNestedPath()Pop the former nested path from the nested path stack.voidpushNestedPath(String subPath)Push the given sub path onto the nested path stack.voidreject(String errorCode)Register a global error for the entire target object, using the given error description.voidreject(String errorCode, Object[] errorArgs, String defaultMessage)Register a global error for the entire target object, using the given error description.voidreject(String errorCode, String defaultMessage)Register a global error for the entire target object, using the given error description.voidrejectValue(String field, String errorCode)Register a field error for the specified field of the current object (respecting the current nested path, if any), using the given error description.voidrejectValue(String field, String errorCode, Object[] errorArgs,