Top Description Methods
org.springframework.validation

public Interface SmartValidator

extends Validator
Known Direct Implementers
org.springframework.validation.beanvalidation.SpringValidatorAdapter
Imports
org.springframework.lang.Nullable

Extended variant of the Validator interface, adding support for validation 'hints'.
Authors
Juergen Hoeller, Sam Brannen
Since
3.1

Method Summary

Modifier and TypeMethod and Description
public default <
the type of the object to return
T
>
T

Returns:

a validator instance of the specified type; null if there isn't a nested validator; an exception may be raised if the specified validator type does not match.
unwrap
(Class<T>
the class of the object to return
type
)

Return a contained validator instance of the specified type, unwrapping as far as necessary.

public void
validate(Object
the object that is to be validated
target
,
Errors
contextual state about the validation process
errors
,
Object...
one or more hint objects to be passed to the validation engine
validationHints
)

Validate the supplied target object, which must be of a type of Class for which the supports(Class) method typically returns true.

public default void
validateValue(Class<?>
the target type
targetType
,
String
the name of the field
fieldName
,
Object
the candidate value
value
,
Errors
contextual state about the validation process
errors
,
Object...
one or more hint objects to be passed to the validation engine
validationHints
)

Validate the supplied value for the specified field on the target type, reporting the same validation errors as if the value would be bound to the field on an instance of the target class.

Inherited from org.springframework.validation.Validator:
forInstanceOfforTypesupportsvalidatevalidateObject

Method Detail

unwrapback to summary
public default <T> T unwrap(Class<T> type)

Return a contained validator instance of the specified type, unwrapping as far as necessary.

Parameters
<T>
the type of the object to return
type:Class<T>

the class of the object to return

Returns:T

a validator instance of the specified type; null if there isn't a nested validator; an exception may be raised if the specified validator type does not match.

Annotations
@Nullable
Since
6.1
validateback to summary
public void validate(Object target, Errors errors, Object... validationHints)

Validate the supplied target object, which must be of a type of Class for which the supports(Class) method typically returns true.

The supplied errors instance can be used to report any resulting validation errors.

This variant of validate() supports validation hints, such as validation groups against a JSR-303 provider (in which case, the provided hint objects need to be annotation arguments of type Class).

Note

Validation hints may get ignored by the actual target Validator, in which case this method should behave just like its regular validate(Object, Errors) sibling.

Parameters
target:Object

the object that is to be validated

errors:Errors

contextual state about the validation process

validationHints:Object[]

one or more hint objects to be passed to the validation engine

See Also
jakarta.validation.Validator#validate(Object, Class[])
validateValueback to summary
public default void validateValue(Class<?> targetType, String fieldName, Object value, Errors errors, Object... validationHints)

Validate the supplied value for the specified field on the target type, reporting the same validation errors as if the value would be bound to the field on an instance of the target class.

Parameters
targetType:Class<?>

the target type

fieldName:String

the name of the field

value:Object

the candidate value

errors:Errors

contextual state about the validation process

validationHints:Object[]

one or more hint objects to be passed to the validation engine

Since
5.1
See Also
jakarta.validation.Validator#validateValue(Class, String, Object, Class[])