#131
IN this lecture you will learn how to create and use a custom validator in a Reactive form in Angular.
YOU CAN DOWNLOAD THE STARTUP PROJECT FROM HERE: github.com/manojjha86/angular...
YOU CAN DOWNLOAD THE FINAL PROJECT FROM HERE: github.com/manojjha86/angular...
Пікірлер: 5
simple and easy . nicely explained
thanks bro...really helpful
Thanks 😊
@jimfrith
15 күн бұрын
I cant get it too work. When i add the custom validator to the control, I get the following error No overload matches this call. Overload 1 of 5, '(value: FormControlState | null, opts: FormControlOptions & { nonNullable: true; }): FormControl', gave the following error. Argument of type '(((control: AbstractControl) => ValidationErrors | null) | ((control: FormControl) => { noSpaceAllowed: boolean; } | null))[]' is not assignable to parameter of type 'FormControlOptions & { nonNullable: true; }'. Property 'nonNullable' is missing in type '(((control: AbstractControl) => ValidationErrors | null) | ((control: FormControl) => { noSpaceAllowed: boolean; } | null))[]' but required in type '{ nonNullable: true; }'. Overload 2 of 5, '(value: FormControlState | null, opts: FormControlOptions & { initialValueIsDefault: true; }): FormControl', gave the following error. Argument of type '(((control: AbstractControl) => ValidationErrors | null) | ((control: FormControl) => { noSpaceAllowed: boolean; } | null))[]' is not assignable to parameter of type 'FormControlOptions & { initialValueIsDefault: true; }'. Property 'initialValueIsDefault' is missing in type '(((control: AbstractControl) => ValidationErrors | null) | ((control: FormControl) => { noSpaceAllowed: boolean; } | null))[]' but required in type '{ initialValueIsDefault: true; }'. Overload 3 of 5, '(value: FormControlState | null, validatorOrOpts?: FormControlOptions | ValidatorFn | ValidatorFn[] | null | undefined, asyncValidator?: AsyncValidatorFn | ... 2 more ... | undefined): FormControl', gave the following error. Type '(control: FormControl) => { noSpaceAllowed: boolean; } | null' is not assignable to type 'ValidatorFn'. Types of parameters 'control' and 'control' are incompatible. Type 'AbstractControl' is missing the following properties from type 'FormControl': defaultValue, registerOnChange, registerOnDisabledChangets(2769) index.d.ts(5206, 9): 'nonNullable' is declared here. index.d.ts(5212, 9): 'initialValueIsDefault' is declared here.