Custom Validator
Your own form rule: returns null when valid or an error object when not.
What is Custom Validator?
A custom validator is your own form rule: a function that returns null when the value is fine or an error object when it isn't.
export const noSpaces: ValidatorFn = control =>
control.value?.includes(' ') ? { noSpaces: true } : null;
username = new FormControl('', noSpaces);
Level: Freelancer · More Angular terms at this level
Updated