Class ParameterValidationResult
java.lang.Object
org.springframework.validation.method.ParameterValidationResult
- Direct Known Subclasses:
- ParameterErrors
Store and expose the results of method validation for a method parameter.
- Validation errors directly on method parameter values are exposed as a
list of MessageSourceResolvables.
- Nested validation errors on an Object method parameter are exposed as
Errorsby the subclassParameterErrors.
When the method parameter is a container such as a List, array,
or Map, then a separate ParameterValidationResult
is created for each element with errors. In that case, the properties
container, containerIndex,
and containerKey provide additional context.
- Since:
- 6.1
- Author:
- Rossen Stoyanchev
- 
Constructor SummaryConstructorsConstructorDescriptionParameterValidationResult(MethodParameter param, @Nullable Object arg, Collection<? extends MessageSourceResolvable> errors, @Nullable Object container, @Nullable Integer index, @Nullable Object key, BiFunction<MessageSourceResolvable, Class<?>, Object> sourceLookup) Create aParameterValidationResult.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanThe method argument value that was validated.When@Validis declared on a container of elements such asCollection,Map,Optional, and others, this method returns the container of the validatedargument, whilegetContainerIndex()andgetContainerKey()provide information about the index or key if applicable.The method parameter the validation results are for.List ofMessageSourceResolvablerepresentations adapted from the validation errors of the validation library.inthashCode()toString()<T> Tunwrap(MessageSourceResolvable error, Class<T> sourceType) Unwrap the source behind the given error.
- 
Constructor Details- 
ParameterValidationResultpublic ParameterValidationResult(MethodParameter param, @Nullable Object arg, Collection<? extends MessageSourceResolvable> errors, @Nullable Object container, @Nullable Integer index, @Nullable Object key, BiFunction<MessageSourceResolvable, Class<?>, Object> sourceLookup) Create aParameterValidationResult.
 
- 
- 
Method Details- 
getMethodParameterThe method parameter the validation results are for.
- 
getArgument
- 
getResolvableErrorsList ofMessageSourceResolvablerepresentations adapted from the validation errors of the validation library.- For a constraints directly on a method parameter, error codes are
based on the names of the constraint annotation, the object, the method,
the parameter, and parameter type, for example,
["Max.myObject#myMethod.myParameter", "Max.myParameter", "Max.int", "Max"]. Arguments include the parameter itself as aMessageSourceResolvable, for example,["myObject#myMethod.myParameter", "myParameter"], followed by actual constraint annotation attributes (i.e. excluding "message", "groups" and "payload") in alphabetical order of attribute names.
- For cascaded constraints via @Validon a bean method parameter, this method returnsfield errorsthat you can also access more conveniently through methods of theParameterErrorssub-class.
 
- For a constraints directly on a method parameter, error codes are
based on the names of the constraint annotation, the object, the method,
the parameter, and parameter type, for example,
- 
getContainerWhen@Validis declared on a container of elements such asCollection,Map,Optional, and others, this method returns the container of the validatedargument, whilegetContainerIndex()andgetContainerKey()provide information about the index or key if applicable.
- 
getContainerIndex
- 
getContainerKey
- 
unwrapUnwrap the source behind the given error. For Jakarta Bean validation the source is aConstraintViolation.- Parameters:
- sourceType- the expected source type
- Returns:
- the source object of the given type
- Since:
- 6.2
 
- 
equals
- 
hashCode
- 
toString
 
-