📜  Angular 实现验证器 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:51.930000             🧑  作者: Mango

代码示例1
<>Copyimport {AbstractControl, ValidatorFn} from '@angular/forms';

export function blue(): ValidatorFn {  
    return (control: AbstractControl): { [key: string]: any } | null =>  
        control.value?.toLowerCase() === 'blue' 
            ? null : {wrongColor: control.value};
}