@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
- Only 1
- Only 2
- Both 1 and 2
- Neither 1 nor 2