I want to write a custom validations for my angular2 project. Can you help me, where to write and how to integrate to my components. I tried like this:
function emailValidator(control: FormControl): { [s: string]: boolean } {
alert('---->'+control.value);
if (!control.value.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)) {
return {invalidEmail: true};
}
}
In console log, it is giving null. Can you help me.. Thanks..