requiredTrue doesn't set a control to be `INVALID` when its value is not `true`
See original GitHub issueSee comment thread
π bug report
Affected Package
The issue is caused by package @angular/....β@angular/formsβ: β^8.0.2β
Is this a regression?
Not sure
Description
I change validation rules on fly by setting Validators.requriedTrue
however the control which has whatever value but true
is still valid and my form is ready to submit (meanwhile it shouldnβt).
I use this.formGroup.get(...).setValidators(Validators.requiredTrue)
. The validator is set, but form is still valid although the value of the control is null
or false
π¬ Minimal Reproduction
https://stackblitz.com/edit/angular-wrokpbClick the button to toggle the requiredTrue
and see in console logged FormGroup object.
π₯ Exception or Error
π Your Environment
Angular Version:
Angular CLI: 8.0.4
Node: 12.5.0
OS: linux x64
Angular: 8.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.800.4
@angular-devkit/build-angular 0.800.4
@angular-devkit/build-ng-packagr 0.800.4
@angular-devkit/build-optimizer 0.800.4
@angular-devkit/build-webpack 0.800.4
@angular-devkit/core 8.0.4
@angular-devkit/schematics 8.0.4
@angular/cdk 8.0.1
@angular/cli 8.0.4
@angular/material 8.0.1
@angular/material-moment-adapter 8.0.1
@ngtools/json-schema 1.1.0
@ngtools/webpack 8.0.4
@schematics/angular 8.0.4
@schematics/update 0.800.4
ng-packagr 5.3.0
rxjs 6.5.2
typescript 3.4.5
webpack 4.30.0
Anything else relevant?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How can I manually set an Angular form field as invalid?
To set validation error in component: formData.form.controls['email'].setErrors({'incorrect': true});. To unset validation error in ...
Read more >Chapter 11. Validating forms - Angular Development with ...
In this chapter, we'll show you how to validate forms in Angular using built-in validators and ... requiredTrue, The form control must have...
Read more >aria-invalid - Accessibility - MDN Web Docs
If a value is determined to be invalid or out-of-range, set aria-invalid="true" and tell the user there is an error. For better user...
Read more >Form fields - Django documentation
Normalizes to: A Python True or False value. Validates that the value is True (e.g. the check box is checked) if the field...
Read more >The best way to implement custom validators - Angular inDepth
wrongColor}} is wrong </div>. To make our custom validator accessible for template-driven forms, we need to implement our validator as a directive andΒ ......
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
Youβre correct, this should be noted in the docs for
setValidators
. Iβm moving this to a docs issue.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.