Last active
July 1, 2017 14:19
-
-
Save stevermeister/0eb1129e32beda5405f73f4f87d2db49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Directive({ | |
selector: '[vali][ngModel]', | |
providers: [ | |
{ | |
provide: NG_VALIDATORS, | |
useExisting: ValiDirective, | |
multi: true | |
} | |
] | |
}) | |
export class ValiDirective implements Validator { | |
validate(formControl: AbstractControl): ValidationErrors { | |
if(formControl.value === '3'){ | |
return {vali: { error: 'vali'}} | |
} | |
return null; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment