validate method

  1. @override
bool validate({
  1. Set<Object>? tags,
  2. bool notify = true,
})

Validates the form.

Only the fields that are currently bound to UI are validated. If non-UI fields are to be validated as well, activate method can be used. Similarly to ignore validation of non-UI fields deactivate can be used.

If tags is not null, only the fields with the given tags will be validated. If notify is true, the form will notify its listeners if the form is invalid.

Implementation

@override
bool validate({Set<Object>? tags, bool notify = true}) {
  final fields = (tags ?? _activeTags).map(call);

  var isFormValid = true;
  for (final field in fields) {
    if (!field.validate(notify: notify)) isFormValid = false;
  }

  _setValidity(isValid: isFormValid);
  if (!isFormValid) notifyListeners();
  return isFormValid;
}