1234567891011121314151617181920212223242526272829303132333435 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.ValidationSchemaToMetadataTransformer = void 0;
- const ValidationMetadata_1 = require("../metadata/ValidationMetadata");
- /**
- * Used to transform validation schemas to validation metadatas.
- */
- class ValidationSchemaToMetadataTransformer {
- transform(schema) {
- const metadatas = [];
- Object.keys(schema.properties).forEach(property => {
- schema.properties[property].forEach(validation => {
- const validationOptions = {
- message: validation.message,
- groups: validation.groups,
- always: validation.always,
- each: validation.each,
- };
- const args = {
- type: validation.type,
- name: validation.name,
- target: schema.name,
- propertyName: property,
- constraints: validation.constraints,
- validationTypeOptions: validation.options,
- validationOptions: validationOptions,
- };
- metadatas.push(new ValidationMetadata_1.ValidationMetadata(args));
- });
- });
- return metadatas;
- }
- }
- exports.ValidationSchemaToMetadataTransformer = ValidationSchemaToMetadataTransformer;
- //# sourceMappingURL=ValidationSchemaToMetadataTransformer.js.map
|