UNPKG

nralcm

Version:

This is a framework based on NodeJs to manage rest api request lifecycle

22 lines (21 loc) 892 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); require("reflect-metadata"); const requiredMetadataKey = "validation"; function Optional(displayName, message) { return function (target, propertyKey, parameterIndex) { const validatorData = { propertyKey: propertyKey, validator: "Optional", displayName: displayName, message: message, validate: undefined, parameterIndex: parameterIndex }; // console.log("target", target, parameterIndex, propertyKey); const existingOptionalParameters = Reflect.getOwnMetadata(requiredMetadataKey, target, propertyKey) || []; existingOptionalParameters.push(validatorData); Reflect.defineMetadata(requiredMetadataKey, existingOptionalParameters, target, propertyKey); }; } exports.Optional = Optional;