-
Notifications
You must be signed in to change notification settings - Fork 52
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
Errors should display useful informations. #12
Comments
Okay, it will be released soon |
Love u! |
This take a bit more time as I have to rewrite a lot of unit test, sorry |
You are doing an amazing job. I love the validators. Thanks again! |
Thanks! Released with 6.0.3. The paramater of each validator (if it has) can be accessible in the template with reason. <input type="number" [(ngModel)]="model.field" name="field" #field="ngModel" [gt]="10">
<!--> Will display : error message and must be greater than 10 <-->
<p *ngIf="field.errors?.gt">error message and must be greater than {{ field.errors?.reason }}</p>1 |
Dow :( Actual situation:
Desired situation:
in this way you can have multiple validators which do not override each-others reasons |
Following the Material Guideline, you shouldn't display more than one error message. In your example, gt won't trigger an error when the field has already a required error. Nevertheless, put the reason in gt is (technically) a better choice. |
Released with 6.10 |
IMPORTANT:
Validator like "greater than" (equalTo has the same issue) should return back the value which is suppose to be bigger of so we can include the information in the error we have to display.
Steps to reproduce and a minimal demo
Add a validator to the field and check the value of the error.
Current behavior
The error return a simple boolean.
Expected/desired behavior
in this way i can do something like:
The text was updated successfully, but these errors were encountered: