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

[REQUEST] Be able to loop through all a field's errors #104

Open
kirkbushell opened this issue Feb 4, 2023 · 0 comments
Open

[REQUEST] Be able to loop through all a field's errors #104

kirkbushell opened this issue Feb 4, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@kirkbushell
Copy link

kirkbushell commented Feb 4, 2023

Is your feature request related to a problem? Please describe.
I cannot find any documentation pertaining to looping through all errors for a given field. The documentation seems to imply that you must know all the validations, and every field, and then write a new conditional block for each. This is amazingly inefficient and results in some fairly ugly code.

Describe the solution you'd like
Make it so that we can simply check if a form is invalid for each block, and if so, loop through all errors (if applicable) for a given field. This will ensure we do not have to check for each individual validation requirement for that field.

Ideally, the API would look something like the following:

#if ($myForm.hasErrors('field'))
   // loop through error and output messages
/if

Introducing a set of language files for supporting various messages would make this idea a reality and considering all fields' errors would look fairly similar across all apps, imho shoudl be supported.

Additional context
A perfect example is "required". The message itself should be pretty much identical for ALL fields, yet we're having to define them for every field, then check for every field if the required validation has been broken. This results in fairly wet solutions (read: not DRY) which is more susceptible to bugs.

@kirkbushell kirkbushell added the enhancement New feature or request label Feb 4, 2023
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

2 participants