docs: use `ValidationErrors` interface in Form validation examples (#42135)
PR Close #42135
This commit is contained in:
parent
4579200c7f
commit
63383c186d
|
@ -5,7 +5,7 @@ import { AbstractControl, NG_VALIDATORS, ValidationErrors, Validator, ValidatorF
|
||||||
// #docregion custom-validator
|
// #docregion custom-validator
|
||||||
/** A hero's name can't match the given regular expression */
|
/** A hero's name can't match the given regular expression */
|
||||||
export function forbiddenNameValidator(nameRe: RegExp): ValidatorFn {
|
export function forbiddenNameValidator(nameRe: RegExp): ValidatorFn {
|
||||||
return (control: AbstractControl): {[key: string]: any} | null => {
|
return (control: AbstractControl): ValidationErrors | null => {
|
||||||
const forbidden = nameRe.test(control.value);
|
const forbidden = nameRe.test(control.value);
|
||||||
return forbidden ? {forbiddenName: {value: control.value}} : null;
|
return forbidden ? {forbiddenName: {value: control.value}} : null;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue