public class ValidationResult extends Object
This class is heavily inspired on Spring's Errors
interface. The main difference is that Hawaii's ValidationResult
does not bind or require
the target object being validated.
Modifier and Type | Field and Description |
---|---|
String |
NESTED_PATH_INDEX_PREFIX |
String |
NESTED_PATH_INDEX_SUFFIX |
String |
NESTED_PATH_SEPARATOR
The separator between path elements in a nested path, for example in "name" or
"address.street".
|
Constructor and Description |
---|
ValidationResult() |
Modifier and Type | Method and Description |
---|---|
void |
addAllErrors(List<ValidationError> errors)
Adds the supplied
ValidationError s to this ValidationResult . |
void |
addAllErrors(ValidationResult validationResult)
Adds all errors from the supplied
ValidationResult to this ValidationResult . |
void |
addError(ValidationError error)
Adds the supplied
ValidationError to this ValidationResult . |
List<ValidationError> |
getErrors()
Returns the validation errors.
|
String |
getNestedPath()
Returns the current nested path of this
ValidationResult . |
boolean |
hasErrors()
Returns
true if this validation result contains errors. |
void |
popNestedPath() |
void |
pushNestedPath(String path) |
void |
pushNestedPath(String path,
int index) |
void |
reject(String code) |
void |
rejectIf(boolean expr,
String code) |
<T> void |
rejectIf(T actual,
Matcher<? super T> matcher,
String code) |
void |
rejectValue(String code) |
void |
rejectValue(String field,
String code) |
void |
rejectValueIf(boolean expr,
String code) |
void |
rejectValueIf(boolean expr,
String field,
String code) |
<T> void |
rejectValueIf(T actual,
Matcher<? super T> matcher,
String code) |
<T> void |
rejectValueIf(T actual,
Matcher<? super T> matcher,
String field,
String code) |
String |
toString() |
public String NESTED_PATH_SEPARATOR
public String NESTED_PATH_INDEX_PREFIX
public String NESTED_PATH_INDEX_SUFFIX
public String getNestedPath()
ValidationResult
.public void pushNestedPath(String path)
public void pushNestedPath(String path, int index)
public void popNestedPath() throws IllegalArgumentException
IllegalArgumentException
public boolean hasErrors()
true
if this validation result contains errors.true
if this validation result contains errorspublic List<ValidationError> getErrors()
public void reject(String code)
public void rejectIf(boolean expr, String code)
public void rejectValue(String code)
public void rejectValueIf(boolean expr, String code)
public <T> void rejectValueIf(T actual, Matcher<? super T> matcher, String field, String code)
public void addError(ValidationError error)
ValidationError
to this ValidationResult
.error
- the validation errorpublic void addAllErrors(List<ValidationError> errors)
ValidationError
s to this ValidationResult
.errors
- the validation errorspublic void addAllErrors(ValidationResult validationResult)
ValidationResult
to this ValidationResult
.validationResult
- the validation result to merge in