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, anAddressValidator
validates "address", not being aware that this is a subobject of customer.Note:
Errors
objects 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 String
NESTED_PATH_SEPARATOR
The 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 void
addAllErrors(Errors errors)
Add all errors from the givenErrors
instance to thisErrors
instance.List<ObjectError>
getAllErrors()
Get all errors, both global and field ones.int
getErrorCount()
Return the total number of errors.FieldError
getFieldError()
Get the first error associated with a field, if any.FieldError
getFieldError(String field)
Get the first error associated with the given field, if any.int
getFieldErrorCount()
Return the number of errors associated with a field.int
getFieldErrorCount(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.Object
getFieldValue(String field)
Return the current value of the given field, either the current bean property value or a rejected update from the last binding.ObjectError
getGlobalError()
Get the first global error, if any.int
getGlobalErrorCount()
Return the number of global errors.List<ObjectError>
getGlobalErrors()
Get all global errors.String
getNestedPath()
Return the current nested path of thisErrors
object.String
getObjectName()
Return the name of the bound root object.boolean
hasErrors()
Return if there were any errors.boolean
hasFieldErrors()
Are there any field errors?boolean
hasFieldErrors(String field)
Are there any errors associated with the given field?boolean
hasGlobalErrors()
Are there any global errors?void
popNestedPath()
Pop the former nested path from the nested path stack.void
pushNestedPath(String subPath)
Push the given sub path onto the nested path stack.void
reject(String errorCode)
Register a global error for the entire target object, using the given error description.void
reject(String errorCode, Object[] errorArgs, String defaultMessage)
Register a global error for the entire target object, using the given error description.void
reject(String errorCode, String defaultMessage)
Register a global error for the entire target object, using the given error description.void
rejectValue(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.void
rejectValue(String field, String errorCode, Object[] errorArgs,