UNPKG

@dooboostore/dom-render

Version:
77 lines 2.55 kB
import { Validator } from './Validator'; import { NonPassValidator } from './NonPassValidator'; export class ValidatorArray extends Validator { constructor(value, target, event, autoValid = true) { super(value, target, event, autoValid); this._makeValidatorFactory = (value, target, event) => { return new NonPassValidator(value, target, event); }; } getMakeValidatorFactory() { return this._makeValidatorFactory; } setMakeValidatorFactory(value) { this._makeValidatorFactory = value; return this; } setArrayValue(target, value, event) { var _a; (_a = this.value) === null || _a === void 0 ? void 0 : _a.filter(it => { if (it.getTarget()) { return it.getTarget() === target; } else { return false; } }).forEach(it => { it.set(value, target, event); }); this.tickValue(this.value); } addValidator(value, target, event) { var _a, _b; if (!this.value) { this.value = []; } if (value instanceof Validator) { (_a = this.value) === null || _a === void 0 ? void 0 : _a.push(value); } else { (_b = this.value) === null || _b === void 0 ? void 0 : _b.push(this.makeValidator(value, target, event)); } this.tickValue(this.value); } allChecked(checked) { var _a; this.checked = checked; (_a = this.value) === null || _a === void 0 ? void 0 : _a.forEach(it => { it.checked = checked; }); } getValidators() { return this._value; } getValidator(e) { var _a; return (_a = this.value) === null || _a === void 0 ? void 0 : _a.filter(it => it.getTarget() === e)[0]; } getValidatorByValue(value) { const validatorByValue = this.getValidatorByValues(value)[0]; return validatorByValue; } getValidatorByValues(value) { var _a, _b; return (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.filter(it => it.value === value)) !== null && _b !== void 0 ? _b : []; } removeElement(e) { const value = this.value; if (value) { this.value = value.filter(it => it.getTarget() !== e); } } makeValidator(value, target, event) { return this._makeValidatorFactory(value, target, event); } ; } //# sourceMappingURL=ValidatorArray.js.map