UNPKG

joiful

Version:

TypeScript Declarative Validation. Decorate your class properties to validate them using Joi.

13 lines 1.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createStringPropertyDecorator = exports.getStringSchemaModifierProviders = void 0; const common_1 = require("./common"); const any_1 = require("./any"); function getStringSchemaModifierProviders(getJoi) { const result = Object.assign(Object.assign({}, any_1.getAnySchemaModifierProviders(getJoi)), { alphanum: () => ({ schema }) => schema.alphanum(), creditCard: () => ({ schema }) => schema.creditCard(), email: (options) => ({ schema }) => schema.email(options), exactLength: (length) => ({ schema }) => schema.length(length), guid: (options) => ({ schema }) => schema.guid(options), hex: () => ({ schema }) => schema.hex(), hostname: () => ({ schema }) => schema.hostname(), insensitive: () => ({ schema }) => schema.insensitive(), ip: (options) => ({ schema }) => schema.ip(options), isoDate: () => ({ schema }) => schema.isoDate(), lowercase: () => ({ schema }) => schema.lowercase(), max: (length) => ({ schema }) => schema.max(length), min: (length) => ({ schema }) => schema.min(length), pattern: (pattern, name) => ({ schema }) => schema.regex(pattern, name), regex: (pattern, name) => ({ schema }) => schema.regex(pattern, name), replace: (pattern, replacement) => ({ schema }) => schema.replace(pattern, replacement), token: () => ({ schema }) => schema.token(), trim: () => ({ schema }) => schema.trim(), uppercase: () => ({ schema }) => schema.uppercase(), uri: (options) => ({ schema }) => schema.uri(options) }); return result; } exports.getStringSchemaModifierProviders = getStringSchemaModifierProviders; const createStringPropertyDecorator = (joifulOptions) => (common_1.createPropertyDecorator()(({ joi }) => joi.string(), getStringSchemaModifierProviders, joifulOptions)); exports.createStringPropertyDecorator = createStringPropertyDecorator; //# sourceMappingURL=string.js.map