Is there any way we can set different validation behavior for different validators?
for example,
{
field1: ['', [Validators.email, Validators.required]],
field2: ['', Validators.required],
},
Here, field1 should validate the input on change, and field2 should validate the input on submit.
Is it possible to set behaviour for individual field of a form?
Why would you want to let a user Submit something only for it to later fail? If a form lets me submit that means my form, as far as the front end is concerned, is valid.
However, if you want something like that then for field1:
for field2, you will have to set the form to run validations onSubmit:
https://stackoverflow.com/questions/55061066/how-to-validate-form-input-on-submit-in-angular-6#:~:text=You%20can%20use%20the%20updateOn,customer_id%3A%20new%20FormControl
How to user updateOn blur in FormBuilder
but in essence:
field2: ['', {validators: Validators.required, updateOn: 'submit'}]