UNPKG

objectypes

Version:

A type-safe library to transform and validate objects

17 lines (16 loc) 785 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.applyTransformationsToObject = void 0; const transformation_1 = require("../metadata/transformation"); function applyTransformationsToObject(targetClass, { propertyKey }, value) { if (value === undefined) { return value; } const transformations = (0, transformation_1.findClassTransformationMetadata)(targetClass, 'build'); const transformMetadata = transformations === null || transformations === void 0 ? void 0 : transformations.find(metadata => metadata.propertyKey === propertyKey); if (!transformMetadata) { return value; } return transformMetadata.transformer.transform(value); } exports.applyTransformationsToObject = applyTransformationsToObject;