import { Directive } from '@angular/core';
import { FormGroup, NG_VALIDATORS} from '@angular/forms';
/**
* Generated class for the FormValidators directive.
*
* See https://angular.io/docs/ts/latest/api/core/index/DirectiveMetadata-class.html
* for more info on Angular Directives.
*/
export function validateMobile(c: FormGroup) {
let Mobile_Format = /^(13[0-9]|15[012356789]|17[03678]|18[0-9]|14[57])[0-9]{8}$/;
return Mobile_Format.test(c.value) ? null : {
validateMobile:{valid:false}
}
}
@Directive({
selector: '[validateMobile][ngModel]', // Attribute selector
providers: [
{ provide:NG_VALIDATORS, useValue: validateMobile, multi: true}
]
})
export class FormValidators {
// constructor() {
// console.log('Hello FormValidators Directive');
// }
}