@bshg/validation
Version:
Validation Library for TypeScript projects
35 lines (34 loc) • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidatorTemplate = void 0;
const validator_1 = require("./validator");
class ValidatorTemplate {
constructor(config) {
this.config = config;
}
instant() {
const validatorConfig = {
id: this.config.id,
options: this.config.options,
items: this.config.items,
};
const nested = this.config.nested;
if (nested) {
Object.keys(nested).forEach((it) => {
var _a;
if (validatorConfig.nested == undefined)
validatorConfig.nested = {};
// @ts-ignore
validatorConfig.nested[it] = (_a = nested[it]) === null || _a === void 0 ? void 0 : _a.instant();
});
}
return new validator_1.Validator().config(validatorConfig);
}
batchValidate(...data) {
return this.instant().batchValidate(...data);
}
batchValidateThrow(...data) {
this.instant().batchValidateThrow(...data);
}
}
exports.ValidatorTemplate = ValidatorTemplate;