UNPKG

@kerthin/domain

Version:
28 lines 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ValidatorExecutor = void 0; const uuid_1 = require("uuid"); const validator_exception_validate_1 = require("./validator-exception.validate"); class ValidatorExecutor { constructor(validator) { this.validator = validator; this.exception = new validator_exception_validate_1.ValidatorException(); } add(validation, key, isValueArray, index) { let validationValue = validation; if (isValueArray) { const keyExceptions = (this.exception.get(key) || {}); validationValue = Object.assign(Object.assign({}, keyExceptions), { [index]: validationValue }); } this.exception.set(key || `random_${(0, uuid_1.v4)()}`, validationValue); return this; } get(key) { return this.exception.get(key); } throwException() { return this.validator.execute(this.exception); } } exports.ValidatorExecutor = ValidatorExecutor; //# sourceMappingURL=validator-executor.validate.js.map