validate method

void validate({
  1. List<Type> groups = const [],
})

Runs each of validators that supports the target, adding the errors to bindingResult; does nothing when there is no target.

Non-empty groups restrict SmartValidators such as BeanValidator to the constraints of those groups. A field that already has a typeMismatch error gets no constraint error on top.

// An edit form: check the update rules.
binder.validate(groups: [OnUpdate]);

Implementation

void validate({List<Type> groups = const []}) {
  final target = _target;
  if (target == null) {
    return;
  }
  for (final validator in validators) {
    if (validator.supports(target)) {
      ValidationUtils.invokeValidator(
        validator,
        target,
        bindingResult,
        groups: groups,
      );
    }
  }
}