nodejs-schema-rules
Version:
The CLI tool automatically generates basic validation rules for popular libraries such as JOI, ValidatorJS and @vinejs/vine based on your database table schema!
22 lines (21 loc) • 912 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.RequestSchemaGenerator = void 0;
const constants_1 = require("../utils/constants");
class RequestSchemaGenerator {
constructor(templateSettings) {
this.requestSchemaType = templateSettings.templateType;
this.templateSettings = templateSettings;
}
// Function to initialize a class based on the request validation type
initializeRequestSchemaGenerator() {
const RequestSchemaGeneratorClass = constants_1.requestSchemaClassMap[this.requestSchemaType];
if (RequestSchemaGeneratorClass) {
return new RequestSchemaGeneratorClass(this.templateSettings).buildAndStore();
}
else {
throw new Error(`Unsupported request validation type: ${String(this.requestSchemaType)}`);
}
}
}
exports.RequestSchemaGenerator = RequestSchemaGenerator;
;