0

We currenty have a legacy project, that needs to be maintained until the final version implementing angular-final is deployed.

In final I can easily apply conditional Validators using:

this.myForm.controls['name'].setValidators(Validators.required)

Obviously the set method was not available back then, the only exposed thing was

validator: ValidatorFN;

property on AbstractControl.

So following this, I tried setting it by just doing:

this.myForm.controls['someControl'].validator(Validators.required)

which will unfortunately throw the following error:

"Cannot read property 'validationViolations' of undefined"

1 Answer 1

1

because there is no explicit setter method you can set a new validator via this.myForm.controls['someControl'].validator=

Cheers

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.