UNPKG

@naturalcycles/nodejs-lib

Version:
22 lines 983 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const JoiLib = require("@hapi/joi"); const number_extensions_1 = require("./number.extensions"); const string_extensions_1 = require("./string.extensions"); /** * This is the only right place to import Joi from */ exports.Joi = JoiLib.defaults(schema => { // hack to prevent infinite recursion due to .empty('') where '' is a stringSchema itself if (schema.type === 'string') { return schema .trim() // trim all strings by default .empty([schema.valid('', null)]); // treat '' or null as empty (undefined, will be stripped out) } // Treat `null` as undefined for all schema types // undefined values will be stripped by default from object values return schema.empty(null); }) .extend((joi) => string_extensions_1.stringExtensions(joi)) .extend((joi) => number_extensions_1.numberExtensions(joi)); //# sourceMappingURL=joi.extensions.js.map