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

[BUG/Feature] When using native required, the (vest) validation is ignored and no error message is shown #9

Open
the-ult opened this issue Jul 24, 2024 · 4 comments

Comments

@the-ult
Copy link
Collaborator

the-ult commented Jul 24, 2024

When you add a required to an input. The vest validation is ignored

We should find a way to work together with the native validations (and native validation errors)
Or even show the 'native' message when there is no Vest message

@wmaurer
Copy link

wmaurer commented Jul 25, 2024

I just came across the same problem.

I'm using mat-form-field and matInput, and I want to use the required attribute because mat-form-field will then add a required marker (*) to the label.

Some sort of angular validation is working as the FormControl.errors gets { required: true }, but then the vest suite doesn't run.

I would really like to be able to have the vest suite run so that I can set a custom error message (or translation key).

@simplifiedcourses
Copy link
Owner

The native required is a directive that creates a different validator on the side that validates in Angular. It doesn't have anything to do with vest. The goal of vest is to have one place where all validations lie, not have anymore validations in the template. Even if we would trigger vest, it would not know how to map this required to the actual validations. The vest suite should be the single source of truth where all validations lie. Does that make sense?

@wmaurer
Copy link

wmaurer commented Jul 25, 2024

Yes it makes sense, and I do like this approach.

I'm working separately on a solution for my other problem (the required marker):
https://material.angular.io/components/form-field/overview#floating-label

@the-ult
Copy link
Collaborator Author

the-ult commented Jul 25, 2024

should we somehow catch it. And show an informative message.

The native required is not working when using Vest. Remove it and use Vest

Or something.
But this seems more like a linting feature

Would be good if it is mentioned in the documentation.

troubleshooting

or

be aware

Or something similar 👍🏼

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

No branches or pull requests

3 participants