Instantiating FormControl using ValidatorFn and AbstractControlOptions at the same time

Viewed 955

Is it possible to instantiate FormControl using both ValidatorFn and AbstractControlOptions at the same time, as in the following example?

new FormControl(null, Validators.required, { updateOn : 'change' });

Looking at the form.d.ts file, it doesn't seem possible:

constructor(
  formState?: any,
  validatorOrOpts?:
    | ValidatorFn
    | ValidatorFn[]
    | AbstractControlOptions
    | null,
  asyncValidator?:
    | AsyncValidatorFn
    | AsyncValidatorFn[]
    | null
){}

However, as this is a pretty common requirement, I think it should be possible, is there any way to accomplish this?

1 Answers

What you need is the below thing?

new FormControl(null, {
    validators: Validators.required,
    updateOn: 'change'
});
Related