Static Access to Validation Error Strings
See original GitHub issueWhich @angular/* package(s) are relevant/releated to the feature request?
forms
Description
We can retrieve the boolean value for a specific Validator like this:
this.email.hasError('email')
I would be nice if we could get programmatic access to the correct email
string like this:
this.email.hasError(Validators.EMAIL_KEY)
Proposed solution
this.email.hasError('Validators.EMAIL_KEY')
Alternatives considered
Just type the string … email
…
The thing is … if we make a mistake … for example typing minLength
… instead of minlength
…
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Share data between static method and static event handler
My problem is, the static validation method needs to return a bool flag to indicate if there were any errors, and an output...
Read more >validation - 1.2.7 - Play Framework
Validation error messages. At the end of the validation you can check if any errors have been created and display them: public static...
Read more >c# How to perform multiple validation and return error ... - MSDN
So, just add an array with the error messages ( for the equivalent indexes ), and iterate through the array using the static...
Read more >Validation and Error Messages - Elastic Path Documentation
When a user takes an action that violates a business state or provides invalid input, an error is generated in Commerce Engine.
Read more >Handling validation messages in Angular like a boss
Tired of writing validation messages for each control and applying conditions to show them? In this post, I will explain how to create...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Totati IIUC
control.hasValidator
checks whether thecontrol
has a specific validator.So for example:
Will return true if the
email
control has theValidators.email
validator assigned to it.This is different from:
Which checks whether the
errors
property on the control has a specific keyed error. In this case that error would be triggered if the value of theemail
control is not a valid email address …This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.