We often are going to want to write our own custom validations. To see how validators are implemented, let’s look at Validators.required from the Angular core source:
1 2 3 4 5 6 |
export class Validators { static required(c: FormControl): StringMap<string, boolean> { return isBlank(c.value) || c.value == "" ? {"required": true} : null; } |
A validator: – Takes a FormControl as its input and – Returns a StringMap<string, boolean> where the key is “error code” and the value is true if it fails Writing […]