接口 SmartValidator
- 所有超级接口:
Validator
- 所有已知实现类:
CustomValidatorBean
,LocalValidatorFactoryBean
,OptionalValidatorFactoryBean
,SpringValidatorAdapter
public interface SmartValidator extends Validator
Extended variant of theValidator
interface, adding support for validation 'hints'.- 从以下版本开始:
- 3.1
- 作者:
- Juergen Hoeller, Sam Brannen
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 void
validate(Object target, Errors errors, Object... validationHints)
Validate the suppliedtarget
object, which must be of a type ofClass
for which theValidator.supports(Class)
method typically returnstrue
.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.
方法详细资料
validate
void validate(Object target, Errors errors, Object... validationHints)
Validate the suppliedtarget
object, which must be of a type ofClass
for which theValidator.supports(Class)
method typically returnstrue
.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 typeClass
).Note: Validation hints may get ignored by the actual target
Validator
, in which case this method should behave just like its regularValidator.validate(Object, Errors)
sibling.- 参数:
target
- the object that is to be validatederrors
- contextual state about the validation processvalidationHints
- one or more hint objects to be passed to the validation engine- 另请参阅:
Validator.validate(Object, Class[])
validateValue
default void validateValue(Class<?> targetType, String fieldName, @Nullable 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.- 参数:
targetType
- the target typefieldName
- the name of the fieldvalue
- the candidate valueerrors
- contextual state about the validation processvalidationHints
- one or more hint objects to be passed to the validation engine- 从以下版本开始:
- 5.1
- 另请参阅:
Validator.validateValue(Class, String, Object, Class[])