$errors property

List<ValidationError> $errors
override

Implementation

List<ValidationError> get $errors {
  if (_errors.isNotEmpty) return _errors;
  if (_isValid!) {
    return const [];
  } else if (_field != null) {
    if (_hasElementErrors) {
      var errorFields = '';
      var count = 0;
      _elements.forEach((key, value) {
        if (value.$isNotValid) {
          errorFields =
              errorFields + "${errorFields.isNotEmpty ? ',' : ''}" + key;
          count++;
        }
      });
      final elementError = ValidationError(
          'ElementErrors',
          'Validation failed for $count element(s).',
          errorFields,
          '0 errors.');
      final errors = List<ValidationError>.from(_field!.$errors);
      errors.add(elementError);
      _errors.addAll(errors);
      return _errors;
    } else {
      return _field!.$errors;
    }
  } else {
    return const [];
  }
}