Consider the following code snippet:
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
}
}
Source: https://angular.io/guide/form-validation#custom-validators
This function acts as a factory that accepts a regular expression to identify a specific prohibited name and generates a validator function.
The function returns a ValidatorFn, which in turn can return an error message or null.
So, what will actually be returned when using this function?