ng2-validation
Version:
46 lines • 1.48 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var forms_1 = require("@angular/forms");
var _1 = require("./");
var MIN_VALIDATOR = {
provide: forms_1.NG_VALIDATORS,
useExisting: core_1.forwardRef(function () { return MinValidator; }),
multi: true
};
var MinValidator = (function () {
function MinValidator() {
}
MinValidator.prototype.ngOnInit = function () {
this.validator = _1.min(this.min);
};
MinValidator.prototype.ngOnChanges = function (changes) {
for (var key in changes) {
if (key === 'min') {
this.validator = _1.min(changes[key].currentValue);
if (this.onChange)
this.onChange();
}
}
};
MinValidator.prototype.validate = function (c) {
return this.validator(c);
};
MinValidator.prototype.registerOnValidatorChange = function (fn) {
this.onChange = fn;
};
return MinValidator;
}());
MinValidator.decorators = [
{ type: core_1.Directive, args: [{
selector: '[min][formControlName],[min][formControl],[min][ngModel]',
providers: [MIN_VALIDATOR]
},] },
];
/** @nocollapse */
MinValidator.ctorParameters = function () { return []; };
MinValidator.propDecorators = {
'min': [{ type: core_1.Input },],
};
exports.MinValidator = MinValidator;
//# sourceMappingURL=directive.js.map
;