Why don't reactive forms have a 'message' field directed to each validator's messages?
See original GitHub issueWhich @angular/* package(s) are relevant/releated to the feature request?
No response
Description
It would be very useful if the reactive forms had the possibility to add messages for each validator. This would make it easier to change the text of messages when needed.
Proposed solution
TS:
this.form = this.fb.group({
name: [
'',
[
Validators.required({ message: 'Field required' }),
Validators.minLength({ lenght: 15, message: 'Min. length: {0}' }),
],
],
});
HTML:
<label *ngIf="this.form.get('name').hasError('required') && this.form.get('name').touched">
{{this.form.get('name').errors.get('required').message}}
</label>
Alternatives considered
Something similar to flutter’s reactive forms:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:37
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to Display Validation or Error Messages in Angular Forms
This guide covers how to display validation or error messages with Angular forms. It looks at both template-driven forms and reactive forms.
Read more >Show Validation Error Messages for Reactive Forms in ...
In this example, I'll define a reactive form with one text field. We'll configure this field to have a few validation rules before...
Read more >Angular Reactive Forms Validation Messages Not Showing
Validations are correctly running. (When type in valid email, form field become red) But validation message not shown.It was perfecty work ...
Read more >Angular Forms and Validations
Reactive Forms, Template-driven Forms. Setup of form model, Explicit, created in component class, Implicit, created by directives.
Read more >Working with Angular 4 Forms: Nesting and Input Validation
Validating user inputs is an essential part of any robust web application. Angular 4 makes it especially easy for both template-driven and reactive...
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
Hi @CarvalhoWesley, thanks for creating this feature request. We’ll discuss it during one of the upcoming team syncs and provide an update on whether we decide to move forward with this feature or not. Thank you.
This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we’ll move it to our consideration list.
You can find more details about the feature request process in our documentation.