UNPKG

ng2-validators

Version:

An implementation of angular validators for Angular 2

48 lines 2.42 kB
import { Directive, Input, forwardRef } from '@angular/core'; import { NG_VALIDATORS, Validators } from '@angular/forms'; import { PasswordValidators } from './password-validators'; var PasswordValidatorDirective = (function () { function PasswordValidatorDirective() { this.repeatCharacter = 4; this.alphabeticalCharacter = 1; this.digitCharacter = 1; this.lowercaseCharacter = 1; this.uppercaseCharacter = 1; } PasswordValidatorDirective.prototype.ngOnInit = function () { this.repeatCharacterValidator = PasswordValidators.repeatCharacterRegexRule(this.repeatCharacter); this.alphabeticalCharacterValidator = PasswordValidators.alphabeticalCharacterRule(this.alphabeticalCharacter); this.digitCharacterValidator = PasswordValidators.digitCharacterRule(this.digitCharacter); this.lowercaseCharacterValidator = PasswordValidators.lowercaseCharacterRule(this.lowercaseCharacter); this.uppercaseCharacterValidator = PasswordValidators.uppercaseCharacterRule(this.uppercaseCharacter); }; PasswordValidatorDirective.prototype.validate = function (c) { var compose = Validators.compose([this.repeatCharacterValidator, this.digitCharacterValidator, this.alphabeticalCharacterValidator, this.lowercaseCharacterValidator, this.uppercaseCharacterValidator]); return compose(c); }; return PasswordValidatorDirective; }()); export { PasswordValidatorDirective }; PasswordValidatorDirective.decorators = [ { type: Directive, args: [{ selector: '[password][formControlName],[password][formControl],[password][ngModel]', providers: [{ provide: NG_VALIDATORS, // tslint:disable-next-line:no-forward-ref useExisting: forwardRef(function () { return PasswordValidatorDirective; }), multi: true }] },] }, ]; /** @nocollapse */ PasswordValidatorDirective.ctorParameters = function () { return []; }; PasswordValidatorDirective.propDecorators = { 'repeatCharacter': [{ type: Input },], 'alphabeticalCharacter': [{ type: Input },], 'digitCharacter': [{ type: Input },], 'lowercaseCharacter': [{ type: Input },], 'uppercaseCharacter': [{ type: Input },], }; //# sourceMappingURL=password.directive.js.map