Errors interface, managing global
errors and field errors for a top-level target object. Flexibly retrieves
field values through bean property getter methods, and automatically
falls back to raw field access if necessary.
Note that this Errors implementation comes without support for
nested paths. It is exclusively designed for the validation of individual
top-level objects, not aggregating errors from multiple sources.
If this is insufficient for your purposes, use a binding-capable
Errors implementation such as BeanPropertyBindingResult.
Validator#validateObject(Object), BeanPropertyBindingResult, DirectFieldBindingResult
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private final List | |
| private final String | |
| private final Object |
| Access | Constructor and Description |
|---|---|
| public | SimpleErrors(Object
the target to wrap target)Create a new |
| public | SimpleErrors(Object
the target to wrap target, String the name of the target object for error reporting objectName)Create a new |
| Modifier and Type | Method and Description |
|---|---|
| public void | addAllErrors(Errors
the errors)Errors instance to merge inOverrides default org. Add all errors from the given |
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. Indicates whether some other object is "equal to" this one. |
| public List | getFieldErrors()
Implements org. Get all errors associated with a field. |
| public Class | getFieldType(String
the field name field)Overrides default org. Determine the type of the given field, as far as possible. |
| public Object | getFieldValue(String
the field name field)Implements org. Return the current value of the given field, either the current bean property value or a rejected update from the last binding. |
| public List | getGlobalErrors()
Implements org. Get all global errors. |
| public String | getObjectName()
Implements org. Return the name of the bound root object. |
| public int | |
| public void | reject(String
error code, interpretable as a message key errorCode, Object[] error arguments, for argument binding via MessageFormat
(can be errorArgs, String null)fallback default message defaultMessage)Implements org. Register a global error for the entire target object, using the given error description. |
| public void | rejectValue(String
the field name (may be field, String null or empty String)error code, interpretable as a message key errorCode, Object[] error arguments, for argument binding via MessageFormat
(can be errorArgs, String null)fallback default message defaultMessage)Implements org. Register a field error for the specified field of the current object (respecting the current nested path, if any), using the given error description. |
| public String | toString()
Overrides java. Implements org. Return a summary of the recorded errors, e.g. for inclusion in an exception message. |
| fieldErrors | back to summary |
|---|---|
| private final List<FieldError> fieldErrors | |
| globalErrors | back to summary |
|---|---|
| private final List<ObjectError> globalErrors | |
| objectName | back to summary |
|---|---|
| private final String objectName | |
| target | back to summary |
|---|---|
| private final Object target | |
| SimpleErrors | back to summary |
|---|---|
| public SimpleErrors(Object target) Create a new
| |
| SimpleErrors | back to summary |
|---|---|
| public SimpleErrors(Object target, String objectName) Create a new | |
| addAllErrors | back to summary |
|---|---|
| public void addAllErrors(Errors errors) Overrides default org. Doc from org. Add all errors from the given This is a convenience method to avoid repeated Note that the passed-in The default implementation throws | |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getFieldErrors | back to summary |
|---|---|
| public List Implements org. Doc from org. Get all errors associated with a field.
| |
| getFieldType | back to summary |
|---|---|
| public Class Overrides default org. Doc from org. Determine the type of the given field, as far as possible. Implementations should be able to determine the type even
when the field value is | |
| getFieldValue | back to summary |
|---|---|
| public Object getFieldValue(String field) Implements org. Doc from org. Return the current value of the given field, either the current bean property value or a rejected update from the last binding. Allows for convenient access to user-specified field values, even if there were type mismatches. | |
| getGlobalErrors | back to summary |
|---|---|
| public List Implements org. Doc from org. Get all global errors.
| |
| getObjectName | back to summary |
|---|---|
| public String getObjectName() Implements org. Doc from org. Return the name of the bound root object.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| reject | back to summary |
|---|---|
| public void reject(String errorCode, Object[] errorArgs, String defaultMessage) Implements org. Doc from org. Register a global error for the entire target object, using the given error description. | |
| rejectValue | back to summary |
|---|---|
| public void rejectValue(String field, String errorCode, Object[] errorArgs, String defaultMessage) Implements org. Doc from org. Register a field error for the specified field of the current object (respecting the current nested path, if any), using the given error description. The field name may be | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Implements org. Doc from org. Return a summary of the recorded errors, e.g. for inclusion in an exception message.
| |