simplifiedcourses / ngx-vest-forms

Simple form development for complex and scalable solutions
44 stars 3 forks source link

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

Open the-ult opened 1 month ago

the-ult commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 👍🏼