UNPKG

@eddaic/nestjs-decorators

Version:

Additional decorators intended for use with NestJS framework.

24 lines (23 loc) 782 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.splitString = splitString; exports.SplitString = SplitString; const class_transformer_1 = require("class-transformer"); const class_validator_1 = require("class-validator"); function splitString(value, options = {}) { const { separator = ',', limit } = options; if ((0, class_validator_1.isString)(value)) { return value.split(separator, limit); } else { return value; } } /** * Transforms a string by a delimiter which defaults to `,`. If the * passed value is not a string, the value is returned unchanged. * @returns */ function SplitString(options) { return (0, class_transformer_1.Transform)(({ value }) => splitString(value, options), options); }