Required Validator is not removed by required directive

This issue has been created since 2022-09-19.

Which @angular/* package(s) are the source of the bug?

forms

Is this a regression?

No

Description

When setting up a control with required validator (eg: new FormControl('', Validators.Required) ), the required directive [required] does not have effect.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-ivy-cuadg4

Please provide the exception or error you saw

I would expect the changes in the value of the "required" directive would be aligned with the control validators.

Please provide the environment you discovered this bug in (run ng version)

I found that issue in angular 12 but seems to be also happening in angular 14.2

Anything else?

In the minimal reproduction we can see three controls.
First one with initial required validator plus a custom isRequired directive which acts as I would expect.
Second one without initial required validator plus required directive which acts as I would expect.
Third one with initial required validator plus required directive which required gets miss aligned.

geromegrignon wrote this answer on 2022-09-19

As explained in the Documentation: https://angular.io/guide/form-validation#validating-input-in-reactive-forms

In a reactive form, the source of truth is the component class. Instead of adding validators through attributes in the template, you add validator functions directly to the form control model in the component class.

If you need to change the required attribute, update the control's Validators on the component side.

angelfraga wrote this answer on 2022-09-19

Thanks.

I will then remove the data binding to the required attribute in the template and apply the changes directly to the control validators.

More Details About Repo
Owner Name angular
Repo Name angular
Full Name angular/angular
Language TypeScript
Created Date 2014-09-18
Updated Date 2022-09-30
Star Count 84080
Watcher Count 3064
Fork Count 22235
Issue Count 1197

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
WebRTC status showing "failed" when running in Mac Catalyst 0 2022-08-07 2022-09-02
[Feature Request]: Proxy support 1 2022-05-14 2022-08-13
Drag drop summary vector : Optionally include history vector 0 2022-05-30 2022-08-18
Plot visibility filter: plot page layout hick-up 0 2022-05-31 2022-08-21
Drag'n'Drop doesn't work when source window is undocked 0 2022-05-30 2022-08-31
Plot Template: Store step dimension 0 2022-05-31 2022-08-21
Detailed Installation Instructions 4 2022-04-10 2022-09-28
Always sync problems 4 2022-02-07 2022-07-13
[fparser2-FE] Routine containing a PROCEDURE() declaration becomes a CodeBlock 0 2022-04-08 2022-08-22
How to link my Proxies from Proxiware to Anticaptcha.com 0 2022-04-23 2022-09-21
KN-3710 is unsupported 1 2022-05-13 2022-09-17
shadowGroups.ps1 // problem with comma in username 3 2021-01-15 2022-08-31
ansible 2.13.1 ''str object'' has no attribute ''hotkey''' 4 2022-07-20 2022-08-17
The FTP reported by Peloton is not actually the FTP, its the max 20min avg output from an ftp test 2 2022-08-03 2022-09-20
1 minute DPS / 2 minute DPS 0 2022-03-19 2022-07-25
DB not opening on oneplus7t Pro, Vivo V2050, RealMe 7i 2 2021-07-03 2022-08-22
Could not open database 0 2021-10-21 2022-08-22
Tagging versions in git 0 2021-08-02 2022-01-05
pts/compress-zstd-1.2.1 is using a LOT of memory on ARM64 2 2020-12-08 2022-09-14
BUG: convert container in provided compose file won't start in swarm mode 2 2022-07-29 2022-09-03
Macros are failing for me in 0.6.6 5 2022-04-18 2022-09-05
Real-Time Reconstrution display question 1 2021-11-10 2022-09-02
`autocomplete` function name conflict with elm/html 0 2021-05-05 2022-09-08
"An error occurred" Generic error when running this script. 3 2021-01-08 2022-09-14
Configure https grafana docker-compose 3 2022-05-24 2022-09-20
When trying to run a function that is imported from a class from a separate file, a browser session cannot be succesfully initiated 3 2022-05-23 2022-09-20
[main] Use `MockIPv8` key injection 2 2021-08-18 2022-08-05
Root privilege escalation by subverting chown 3 2017-09-05 2022-06-24
Improve Card browser scrolling performance 7 2022-07-19 2022-09-25
`Autocomplete.Input` does not allow value to be set to empty string `""` 1 2022-03-24 2022-08-30
Issue with "Basic concepts of flexbox": (short summary here please) 1 2022-01-03 2022-08-29
enhance CloudFront dashboard 0 2022-08-08 2022-09-21
update() in Custom Drawing 2D 0 2022-09-20 2022-09-19
Left drawer overlaps documentation content on 5:4 monitor 1 2022-09-18 2022-09-19
Rewrite "Importing 3D scenes" page 0 2022-09-19 2022-09-19
prepull image version for gce windows testing need to be updated. 5 2020-08-20 2022-09-21
New Resource to create workspace state version and set as current state 6 2021-09-03 2022-09-26
FLASK-APP cats images not available ; link not working 0 2021-03-29 2022-09-21
functions createTag fails when the full file path where the code is has a space character 5 2021-06-30 2022-09-21
Integration test for DB upgrades 6 2022-03-21 2022-09-17
[Doc] Explain in the documentation what X-Hasura-Is-Owner does/means/is used for. 3 2022-05-03 2022-09-29
Qubits not properly released? 2 2021-07-16 2022-09-24
[Simple Site] .txt files are only downloadable for logged in users. [403: Access Denied] 2 2021-10-28 2022-08-27
Does it support Highcharts Theme? 4 2018-06-27 2022-08-14
network architecture (UNet) 0 2022-06-27 2022-09-22
How to use distribution strategy at the time of production? 1 2021-03-02 2022-09-22
sample_weight in model.fit() does not work on Tensorflow 2.1 1 2021-03-30 2022-09-22
[SharedUX] NoData component - cleanup & follow-up 0 2022-04-25 2022-08-09
[Stack Monitoring] Investigate if there are Stack Monitoring ES queries that can be eliminated 3 2022-04-26 2022-07-27
Export `getAccessorValue` as util from library 0 2021-09-14 2022-09-27