import { Directive } from '@angular/core'; import { AbstractControl, ValidationErrors, Validator } from '@angular/forms'; @Directive({ selector: '[forbiddenNameValidator]', standalone: true }) export class ForbiddenNameValidatorDirective implements Validator { constructor() { } validate(control: AbstractControl): ValidationErrors | null { const forbidden = /admin/.test(control.value); return forbidden ? { 'forbiddenName': { value: control.value } } : null; } }