validate method

  1. @override
bool validate()
override

Runs array-level validators and triggers validate on every child control.

Returns true if all child controls and array-level validators pass; false otherwise.

Implementation

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

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

  for (final child in fields.value) {
    final valid = child.validate();
    if (!valid) allValid = false;
  }
  return allValid;
}