@eddaic/nestjs-decorators
Version:
Additional decorators intended for use with NestJS framework.
24 lines (23 loc) • 661 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.trim = trim;
exports.Trim = Trim;
const class_transformer_1 = require("class-transformer");
const class_validator_1 = require("class-validator");
function trim(value) {
if ((0, class_validator_1.isString)(value)) {
return value.trim();
}
else {
return null;
}
}
/**
* Removes the leading and trailing white space and line terminator characters from string input.
*
* Null is returned if the value is not a string.
* @returns
*/
function Trim(options) {
return (0, class_transformer_1.Transform)(({ value }) => trim(value), options);
}