A Validator that can check only the constraints of some validation groups.
Groups let one class carry rules for different situations: an id that
must be empty on create and set on update, checks that only run before
an order is shipped. BeanValidator is the implementation;
applications receive it rather than write one. The framework calls
validateWithGroups when @Validated([OnUpdate]) names groups, and so
do DataBinder.validate and ValidationUtils.invokeValidator when
they are given groups.
// Check only the constraints declared with groups: [OnUpdate].
final errors = BeanPropertyBindingResult(form, 'signup');
validator.validateWithGroups(form, errors, [OnUpdate]);
Spring (Java):
SmartValidator validator = new LocalValidatorFactoryBean();
Errors errors = new BeanPropertyBindingResult(form, "signup");
validator.validate(form, errors, OnUpdate.class);
- Implemented types
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
supports(
Object target) → bool -
Whether this validator knows how to check
target; usually a type test such astarget is SignupForm.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
validate(
Object target, Errors errors) → void -
Checks
targetand records every problem inerrors, with Errors.rejectValue for a field or Errors.reject for the whole object. Records nothing whentargetis valid; does not throw for invalid data.inherited -
validateWithGroups(
Object target, Errors errors, List< Type> groups) → void -
Checks
targetagainst the constraints ofgroupsonly and records the problems inerrors.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited