Skip to content

Instantly share code, notes, and snippets.

@stevermeister
Last active July 1, 2017 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevermeister/0eb1129e32beda5405f73f4f87d2db49 to your computer and use it in GitHub Desktop.
Save stevermeister/0eb1129e32beda5405f73f4f87d2db49 to your computer and use it in GitHub Desktop.
@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