ng2-validators
Version:
An implementation of angular validators for Angular 2
87 lines • 3.59 kB
JavaScript
import { Directive, Input, forwardRef } from '@angular/core';
import { NG_VALIDATORS } from '@angular/forms';
import { PhoneValidators } from './phone-validators';
var PossiblePhoneValidatorDirective = (function () {
function PossiblePhoneValidatorDirective() {
this.possiblePhone = 'US';
}
PossiblePhoneValidatorDirective.prototype.ngOnInit = function () {
this.validator = PhoneValidators.isPossibleNumberWithReason(this.possiblePhone);
};
PossiblePhoneValidatorDirective.prototype.validate = function (c) {
return this.validator(c);
};
return PossiblePhoneValidatorDirective;
}());
export { PossiblePhoneValidatorDirective };
PossiblePhoneValidatorDirective.decorators = [
{ type: Directive, args: [{
selector: '[possiblePhone][formControlName],[possiblePhone][formControl],[possiblePhone][ngModel]',
providers: [{
provide: NG_VALIDATORS,
// tslint:disable-next-line:no-forward-ref
useExisting: forwardRef(function () { return PossiblePhoneValidatorDirective; }),
multi: true
}]
},] },
];
/** @nocollapse */
PossiblePhoneValidatorDirective.ctorParameters = function () { return []; };
PossiblePhoneValidatorDirective.propDecorators = {
'possiblePhone': [{ type: Input },],
};
var PhoneValidatorDirective = (function () {
function PhoneValidatorDirective() {
this.phone = 'US';
}
PhoneValidatorDirective.prototype.ngOnInit = function () {
this.validator = PhoneValidators.isPhoneNumber(this.phone);
};
PhoneValidatorDirective.prototype.validate = function (c) {
return this.validator(c);
};
return PhoneValidatorDirective;
}());
export { PhoneValidatorDirective };
PhoneValidatorDirective.decorators = [
{ type: Directive, args: [{
selector: '[phone][formControlName],[phone][formControl],[phone][ngModel]',
providers: [{
provide: NG_VALIDATORS,
// tslint:disable-next-line:no-forward-ref
useExisting: forwardRef(function () { return PhoneValidatorDirective; }),
multi: true
}]
},] },
];
/** @nocollapse */
PhoneValidatorDirective.ctorParameters = function () { return []; };
PhoneValidatorDirective.propDecorators = {
'phone': [{ type: Input },],
};
var CountryCodeValidatorDirective = (function () {
function CountryCodeValidatorDirective() {
}
CountryCodeValidatorDirective.prototype.ngOnInit = function () {
this.validator = PhoneValidators.isValidRegionCode;
};
CountryCodeValidatorDirective.prototype.validate = function (c) {
return this.validator(c);
};
return CountryCodeValidatorDirective;
}());
export { CountryCodeValidatorDirective };
CountryCodeValidatorDirective.decorators = [
{ type: Directive, args: [{
selector: '[countryCode][formControlName],[countryCode][formControl],[countryCode][ngModel]',
providers: [{
provide: NG_VALIDATORS,
// tslint:disable-next-line:no-forward-ref
useExisting: forwardRef(function () { return CountryCodeValidatorDirective; }),
multi: true
}]
},] },
];
/** @nocollapse */
CountryCodeValidatorDirective.ctorParameters = function () { return []; };
//# sourceMappingURL=phone.directive.js.map