Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Multiple Error Messages Getter #454

Open
MatteMirror opened this issue May 29, 2024 · 0 comments
Open

Feature Request: Multiple Error Messages Getter #454

MatteMirror opened this issue May 29, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@MatteMirror
Copy link

Environment

Version: latest

Description

Currently, the ReactiveFormFieldState class has a method that returns only the first error message encountered. Below is the existing implementation:

String? get errorText {
    if (control.hasErrors && _showErrors) {
      final errorKey = control.errors.keys.first;
      final validationMessage = _findValidationMessage(errorKey);

      return validationMessage != null
          ? validationMessage(control.getError(errorKey)!)
          : errorKey;
    }

    return null;
  }

Request

I would like to request an additional getter that returns a list containing all error messages. This enhancement would allow for better error handling and display in forms.

Proposed Implementation

 List<String> get errorMessages {
    if (control.hasErrors && _showErrors) {
      return control.errors.keys.map((errorKey) {
        final validationMessage = _findValidationMessage(errorKey);
        return validationMessage != null
            ? validationMessage(control.getError(errorKey)!)
            : errorKey;
      }).toList();
    }

    return [];
  }

Benefits

  • Improved error handling: Users can see all validation errors at once.
  • Enhanced user experience: More informative error messages help users understand and correct form input errors more efficiently.

Thank you for considering this feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant