@szegedsw/lib-node
Version:
A little framework published by Szeged Software Zrt. in order to enhance api endpoint security and create reuseable code. Email module, Logging system, and much more. Further improvements are expected.
28 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrayModelValidator = void 0;
const export_1 = require("../controller/export");
const logger_1 = require("../logger/logger");
const validator_1 = require("./validator");
class ArrayModelValidator extends validator_1.Validator {
constructor(model) {
var _a;
super(new RegExp(""), `Every item should validate for the model: ${(_a = model.interfaceHelpMessage) === null || _a === void 0 ? void 0 : _a.call(model)}`);
Object.defineProperty(this, "model", {
enumerable: true,
configurable: true,
writable: true,
value: model
});
}
validate(value) {
const array = JSON.parse(value);
return (Array.isArray(array) &&
array.every((elem, index) => {
logger_1.Logger.trace(`Validating item #${index}.`);
return export_1.Controller.modelValidator(elem, this.model);
}));
}
}
exports.ArrayModelValidator = ArrayModelValidator;
//# sourceMappingURL=array-model-validator.js.map