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

Added getter errorMessages to reactive_form_field.dart #455

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MatteMirror
Copy link

Added getter errorMessages to reactive_form_field.dart

Connection with Issues

Solution Description

The errorMessages getter has been implemented to retrieve a list of all error messages (in addition to the errorText getter, which only returns the first) associated with the FormControl bound to the widget. Here’s a detailed breakdown of the solution:

  • Error Condition: The getter checks if the control has errors and if the _showErrors flag is true.
  • If the 'required' error is present, the method returns a list containing the 'required' error message.
  • The error message is either a custom validation message (if provided) or the string 'required'.

Handling Other Errors:

  • If the 'required' error is not present, the method returns a list of all other error messages.
  • For each error key, it looks for a custom validation message.
  • If a custom validation message is found, it is used as the error message. Otherwise, the error key itself is used as the error message.
  • No Errors or Flag False: If the control has no errors or the _showErrors flag is false, an empty list is returned.

Result

This getter provides more extensive customization options for custom ReactiveTextFields.

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

Successfully merging this pull request may close these issues.

1 participant