validate method

  1. @override
bool validate()
override

Runs group-level validators and validate on every child control.

Returns true if all child controls and group validators pass; false otherwise.

Implementation

@override
bool validate() {
  _debounceTimer?.cancel();
  _debounceTimer = null;
  ++_asyncValidationSeq;
  _groupValidating.value = false;

  var allValid = true;
  final errs = <String>[];
  final currentValues = rawValue;
  for (final v in validators) {
    final err = v(currentValues);
    if (err != null) errs.add(err);
  }
  errors.value = errs;
  if (errs.isNotEmpty) allValid = false;

  for (final field in _fields.values) {
    final valid = field.validate();
    if (!valid) allValid = false;
  }
  return allValid;
}