Working with Forms in Angular

@Directive({
 selector: '[appForbiddenName]',
 providers: [{provide: NG_VALIDATORS, useExisting: ForbiddenValidatorDirective, multi: true}]
})
export class ForbiddenValidatorDirective implements Validator {
 @Input('appForbiddenName') forbiddenName: string;

 validate(control: AbstractControl): {[key: string]: any} | null {
 return this.forbiddenName ? forbiddenNameValidator(new RegExp(this.forbiddenName, 'i'))(control)
 : null;
 }
}

Which of the following is true about the code snippet given above?

1. NG_VALIDATORS is a predefined provider with an extensible collection of validators.

2. You can add its selector, appForbiddenNamence once the ForbiddenValidatorDirective is ready,

Options
  1. Only 1
  2. Only 2
  3. Both 1 and 2
  4. Neither 1 nor 2

Related Posts