I want to understand the syntax of the following TypeScript function.
export function forbiddenNameValidator(nameRe: RegExp): ValidatorFn
{
return (control: AbstractControl): {[key: string]: any} | null => {
const forbidden = nameRe.test(control.value);
return forbidden ? {'forbiddenName': {value: control.value}} : null;
};
}
Here: AbstractControl: https://angular.io/api/forms/AbstractControl
My understanding is:
forbiddenNameValidator: name of the user defined function.
nameRe: RegExp: Argument to function - forbiddenNameValidator.
ValidatorFn: Return type of the function - forbiddenNameValidator.
From here: https://angular.io/api/forms/ValidatorFn
interface ValidatorFn
{
(control: AbstractControl): ValidationErrors | null
}
That documentation says that (control: AbstractControl): ValidationErrors | null is a function.
Which symbol here shows that it is a function? I had read that => symbol represents functions.