1 | {"version":3,"file":"ValidationSchemaToMetadataTransformer.js","sourceRoot":"","sources":["../../../src/validation-schema/ValidationSchemaToMetadataTransformer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIpE;;GAEG;AACH;IAAA;IAwBA,CAAC;IAvBC,yDAAS,GAAT,UAAU,MAAwB;QAChC,IAAM,SAAS,GAAyB,EAAE,CAAC;QAC3C,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,QAAQ;YAC7C,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,UAAA,UAAU;gBAC5C,IAAM,iBAAiB,GAAsB;oBAC3C,OAAO,EAAE,UAAU,CAAC,OAAO;oBAC3B,MAAM,EAAE,UAAU,CAAC,MAAM;oBACzB,MAAM,EAAE,UAAU,CAAC,MAAM;oBACzB,IAAI,EAAE,UAAU,CAAC,IAAI;iBACtB,CAAC;gBACF,IAAM,IAAI,GAA2B;oBACnC,IAAI,EAAE,UAAU,CAAC,IAAI;oBACrB,MAAM,EAAE,MAAM,CAAC,IAAI;oBACnB,YAAY,EAAE,QAAQ;oBACtB,WAAW,EAAE,UAAU,CAAC,WAAW;oBACnC,qBAAqB,EAAE,UAAU,CAAC,OAAO;oBACzC,iBAAiB,EAAE,iBAAiB;iBACrC,CAAC;gBACF,SAAS,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;IACH,4CAAC;AAAD,CAAC,AAxBD,IAwBC","sourcesContent":["import { ValidationSchema } from './ValidationSchema';\nimport { ValidationMetadata } from '../metadata/ValidationMetadata';\nimport { ValidationMetadataArgs } from '../metadata/ValidationMetadataArgs';\nimport { ValidationOptions } from '../decorator/ValidationOptions';\n\n/**\n * Used to transform validation schemas to validation metadatas.\n */\nexport class ValidationSchemaToMetadataTransformer {\n transform(schema: ValidationSchema): ValidationMetadata[] {\n const metadatas: ValidationMetadata[] = [];\n Object.keys(schema.properties).forEach(property => {\n schema.properties[property].forEach(validation => {\n const validationOptions: ValidationOptions = {\n message: validation.message,\n groups: validation.groups,\n always: validation.always,\n each: validation.each,\n };\n const args: ValidationMetadataArgs = {\n type: validation.type,\n target: schema.name,\n propertyName: property,\n constraints: validation.constraints,\n validationTypeOptions: validation.options,\n validationOptions: validationOptions,\n };\n metadatas.push(new ValidationMetadata(args));\n });\n });\n return metadatas;\n }\n}\n"]} |