{"version":3,"sources":["../src/errors/SchemaError.ts","../src/errors/ValidationError.ts","../src/utils.ts","../src/clean/any.ts","../src/clean/array.ts","../src/clean/boolean.ts","../src/clean/string.ts","../src/clean/date.ts","../src/clean/email.ts","../src/clean/number.ts","../src/clean/float.ts","../src/clean/integer.ts","../src/clean/object.ts","../src/clean/uuid.ts","../src/clean/index-ns.ts"],"sourcesContent":["export class SchemaError extends Error {}\n","export type ErrorMessage = string\n\nexport type ErrorMessages = ErrorMessage[]\n\nexport type FieldErrorMessages = {\n\t[field: string]: ErrorMessages\n}\n\nexport type SimpleFieldErrorMessages = {\n\t[field: string]: ErrorMessage | ErrorMessages\n}\n\nexport interface ErrorOptions {\n\tlabel?: string | null\n}\n\nexport class ValidationError extends Error {\n\tmessages?: ErrorMessages\n\terrors?: FieldErrorMessages\n\topts: ErrorOptions\n\n\tconstructor(\n\t\targ: ErrorMessage | ErrorMessages | SimpleFieldErrorMessages,\n\t\topts?: Partial<ErrorOptions>\n\t) {\n\t\tlet message: ErrorMessage | undefined\n\t\tlet messages: ErrorMessages | undefined\n\t\tlet errors: FieldErrorMessages | undefined\n\n\t\tif (typeof arg === \"string\") {\n\t\t\tmessages = [arg]\n\t\t\tmessage = arg\n\t\t} else if (Array.isArray(arg)) {\n\t\t\tif (!arg.length) {\n\t\t\t\tthrow new Error(\"ValidationError array argument can't empty.\")\n\t\t\t}\n\t\t\tfor (const i in arg) {\n\t\t\t\tconst e = arg[i]\n\t\t\t\tif (!(typeof e === \"string\")) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`ValidationError array element ${i} must be a string.`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tmessages = arg\n\t\t\tmessage = JSON.stringify(messages)\n\t\t} else if (typeof arg === \"object\") {\n\t\t\tif (!Object.keys(arg).length) {\n\t\t\t\tthrow new Error(\"ValidationError object argument can't be empty.\")\n\t\t\t}\n\t\t\terrors = {}\n\t\t\tfor (const field of Object.keys(arg)) {\n\t\t\t\tconst fieldArg = arg[field]\n\t\t\t\tif (typeof fieldArg === \"string\") {\n\t\t\t\t\terrors[field] = [fieldArg]\n\t\t\t\t} else if (Array.isArray(fieldArg)) {\n\t\t\t\t\tif (!fieldArg.length) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`ValidationError field ${field} can't be empty array.`\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tfor (const i in fieldArg) {\n\t\t\t\t\t\tconst e = fieldArg[i]\n\t\t\t\t\t\tif (!(typeof e === \"string\")) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`ValidationError field ${field} array element ${i} must be a string.`\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\terrors[field] = fieldArg\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`ValidationError field ${field} must be a string or array.`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\tmessage = JSON.stringify(errors)\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t\"ValidationError argument must be a string, array or object.\"\n\t\t\t)\n\t\t}\n\t\tsuper(message)\n\t\tthis.messages = messages\n\t\tthis.errors = errors\n\t\tthis.opts = { ...opts }\n\t}\n}\n","export interface MessageContext {\n\tmessages?: Record<string, string>\n}\n\nexport function getMessage(\n\tcontext: MessageContext | undefined,\n\tname: string,\n\tdefaultText: string\n) {\n\treturn (context && context.messages && context.messages[name]) || defaultText\n}\n","import { SchemaError } from \"../errors/SchemaError\"\nimport { ValidationError } from \"../errors/ValidationError\"\nimport { Cleaner } from \"../types\"\nimport { getMessage } from \"../utils\"\n\nexport interface AnySchema<T, V = any> {\n\t/** `required: false` - allow undefined values */\n\trequired?: boolean\n\t/** `null: true` - allow null values */\n\tnull?: boolean\n\t/** Replace `undefined` with this value (sets `required: false` automatically) */\n\tdefault?: any\n\t/** Override flat collector field label, or `null` to omit field label altogether. */\n\tlabel?: string | null\n\t/** Nested cleaner (called if the validation passes) */\n\tclean?: Cleaner<T, V>\n}\n\nexport type WithSchema<C extends Cleaner<any>, S> = C & {\n\tschema: S\n}\n\nexport function setSchema<C extends Cleaner<any>, S>(fn: C, schema: S) {\n\t;(fn as any).schema = schema\n\treturn fn as WithSchema<C extends WithSchema<infer OC, any> ? OC : C, S>\n}\n\nexport function cleanAny<T = any, V = any>(schema: AnySchema<T, V> = {}) {\n\tif (schema.default !== undefined) {\n\t\tif (schema.required === undefined) {\n\t\t\tschema.required = false\n\t\t} else if (schema.required !== false) {\n\t\t\tthrow new SchemaError(\"clean.any with 'default' needs 'required: false'\")\n\t\t}\n\t}\n\tif (schema.default === null) {\n\t\tif (schema.null === undefined) {\n\t\t\tschema.null = true\n\t\t} else if (schema.null !== true) {\n\t\t\tthrow new SchemaError(\"clean.any with 'default: null' needs 'null: true'\")\n\t\t}\n\t}\n\tconst cleaner: Cleaner<T, V> = function (value, context) {\n\t\tif (value === undefined && schema.required !== false) {\n\t\t\tthrow new ValidationError(\n\t\t\t\tgetMessage(context, \"required\", \"Value required.\")\n\t\t\t)\n\t\t}\n\t\tif (value === undefined && schema.default !== undefined) {\n\t\t\tvalue = schema.default\n\t\t}\n\t\tif (value === null && schema.null !== true) {\n\t\t\tthrow new ValidationError(\n\t\t\t\tgetMessage(context, \"required\", \"Value required.\")\n\t\t\t)\n\t\t}\n\t\treturn schema.clean ? schema.clean(value, context) : (value as unknown as T)\n\t}\n\treturn setSchema(cleaner, schema)\n}\n","import { ErrorMessages, ValidationError } from \"../errors/ValidationError\"\nimport { Cleaner } from \"../types\"\nimport { getMessage } from \"../utils\"\nimport { AnySchema, cleanAny, setSchema } from \"./any\"\n\nexport interface ArraySchema<E, T> extends AnySchema<T, E[]> {\n\t/** Individual element cleaner. */\n\telement?: Cleaner<E>\n\t/** Minimum allowed number of elements. */\n\tmin?: number\n\t/** Maximum allowed number of elements. */\n\tmax?: number\n}\n\nexport function cleanArray<E = any, T = E[], V = any>(\n\tschema: ArraySchema<E, T> = {}\n) {\n\tconst cleaner = cleanAny<T, V>({\n\t\trequired: schema.required,\n\t\tdefault: schema.default,\n\t\tnull: schema.null,\n\t\tasync clean(value, context) {\n\t\t\tlet res: any = value\n\t\t\tif (!(res === undefined || res === null)) {\n\t\t\t\tif (!Array.isArray(res)) {\n\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\tgetMessage(context, \"invalid\", \"Invalid value.\")\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (schema.min && res.length < schema.min) {\n\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\tgetMessage(context, \"array_min\", \"Not enough values.\")\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (schema.max && res.length > schema.max) {\n\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\tgetMessage(context, \"array_max\", \"Too many values.\")\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (schema.element) {\n\t\t\t\t\tconst cleanedArray: E[] = []\n\t\t\t\t\tconst errors: ErrorMessages = []\n\t\t\t\t\t// TODO: use Promise.all instead of loop\n\t\t\t\t\tfor (const el of res) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tcleanedArray.push(await schema.element(el, context))\n\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\tif (err instanceof ValidationError) {\n\t\t\t\t\t\t\t\tif (err.messages) {\n\t\t\t\t\t\t\t\t\terrors.push(...err.messages)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (err.errors) {\n\t\t\t\t\t\t\t\t\tfor (const subfield of Object.keys(err.errors)) {\n\t\t\t\t\t\t\t\t\t\terrors.push(`${subfield}: ${err.errors[subfield]}`)\n\t\t\t\t\t\t\t\t\t\t// TODO: define object error decomposition method via schema options.\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow err\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (errors.length) {\n\t\t\t\t\t\tthrow new ValidationError(errors)\n\t\t\t\t\t}\n\t\t\t\t\tres = cleanedArray\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn schema.clean ? schema.clean(res, context) : res\n\t\t},\n\t})\n\treturn setSchema(cleaner, schema)\n}\n","import { ValidationError } from \"../errors/ValidationError\"\nimport { getMessage } from \"../utils\"\nimport { AnySchema, cleanAny, setSchema } from \"./any\"\n\nexport interface BooleanSchema<T> extends AnySchema<T, boolean> {\n\t/** No strict type check, convert value with `!!value` */\n\tcast?: boolean\n\t/** Return `undefined` for `false` */\n\tomit?: boolean\n}\n\nexport function cleanBoolean<T = boolean, V = any>(\n\tschema: BooleanSchema<T> = {}\n) {\n\tconst cleaner = cleanAny<T, V>({\n\t\trequired: schema.required,\n\t\tdefault: schema.default,\n\t\tnull: schema.null,\n\t\tclean(value, context) {\n\t\t\tlet res: any = value\n\t\t\tif (!(res === undefined || res === null)) {\n\t\t\t\tif (typeof res !== \"boolean\" && schema.cast !== true) {\n\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\tgetMessage(context, \"invalid\", \"Invalid value.\")\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tres = !!res\n\t\t\t\tif (res === false && schema.omit === true) {\n\t\t\t\t\tres = undefined\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn schema.clean ? schema.clean(res, context) : res\n\t\t},\n\t})\n\treturn setSchema(cleaner, schema)\n}\n","import { SchemaError } from \"../errors/SchemaError\"\nimport { ValidationError } from \"../errors/ValidationError\"\nimport { getMessage } from \"../utils\"\nimport { AnySchema, cleanAny, setSchema } from \"./any\"\n\nexport interface StringSchema<T> extends AnySchema<T, string> {\n\t/**\n\t * `blank: true` - allow blank values (empty strings).\n\t *\n\t * `blank: null` - convert blank values (empty strings) to `null` (sets `null: true` automatically).\n\t */\n\tblank?: boolean | null\n\t/** `cast: true` - no strict type check, convert value with `String(value)` */\n\tcast?: boolean\n\t/** Test non-blank strings to match against regexp */\n\tregexp?: RegExp\n}\n\nexport function cleanString<T = string, V = any>(schema: StringSchema<T> = {}) {\n\tif (schema.blank === null) {\n\t\tif (schema.null === undefined) {\n\t\t\tschema.null = true\n\t\t} else if (schema.null !== true) {\n\t\t\tthrow new SchemaError(\n\t\t\t\t\"clean.string with 'blank: null' needs 'null: true'\"\n\t\t\t)\n\t\t}\n\t}\n\tif (schema.regexp && typeof schema.regexp.test !== \"function\") {\n\t\tthrow new SchemaError(\"clean.string regexp must be a RegExp object\")\n\t}\n\tconst cleaner = cleanAny<T, V>({\n\t\trequired: schema.required,\n\t\tdefault: schema.default,\n\t\tnull: schema.null,\n\t\tclean(value, context) {\n\t\t\tlet res: any = value\n\t\t\tif (!(res === undefined || res === null)) {\n\t\t\t\tif (typeof res === \"object\" && schema.cast !== true) {\n\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\tgetMessage(context, \"invalid\", \"Invalid value.\")\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tres = String(res)\n\t\t\t\tif (res === \"\") {\n\t\t\t\t\tif (schema.blank === null) {\n\t\t\t\t\t\tres = null\n\t\t\t\t\t} else if (schema.blank !== true) {\n\t\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t\tgetMessage(context, \"required\", \"Value required.\")\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (res && schema.regexp && !schema.regexp.test(res as string)) {\n\t\t\t\t\t// Only test non-empty values\n\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\tgetMessage(context, \"invalid\", \"Invalid value.\")\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn schema.clean ? schema.clean(res, context) : res\n\t\t},\n\t})\n\treturn setSchema(cleaner, schema)\n}\n","import { SchemaError } from \"../errors/SchemaError\"\nimport { ValidationError } from \"../errors/ValidationError\"\nimport { Cleaner } from \"../types\"\nimport { getMessage } from \"../utils\"\nimport { setSchema } from \"./any\"\nimport { cleanString, StringSchema } from \"./string\"\n\nexport interface DateSchema<T>\n\textends Omit<StringSchema<T>, \"cast\" | \"regexp\"> {\n\t/**\n\t * `format: undefined` (default) - return Date object\n\t *\n\t * `format: null` - return valid value as is\n\t *\n\t * `format: \"iso\"` - return ISO-formatted date-time\n\t */\n\tformat?: null | \"iso\"\n}\n\n// FIXME: type result as having schema\nexport function cleanDate<T = Date, V = any>(\n\tschema?: DateSchema<T> & { format?: undefined }\n): Cleaner<T, V>\n\n// FIXME: type result as having schema\nexport function cleanDate<T = string, V = any>(\n\tschema?: DateSchema<T> & { format: \"iso\" | null }\n): Cleaner<T, V>\n\nexport function cleanDate<T = Date | string, V = any>(\n\tschema: DateSchema<T> = {}\n) {\n\tif (\n\t\t!(\n\t\t\tschema.format === undefined ||\n\t\t\tschema.format === null ||\n\t\t\tschema.format === \"iso\"\n\t\t)\n\t) {\n\t\tthrow new SchemaError(\n\t\t\t\"clean.date format may be only: undefined, null, 'iso'\"\n\t\t)\n\t}\n\t// TODO: don't allow weird combinations e.g. { format: undefined, blank: true }\n\tconst cleaner = cleanString<T, V>({\n\t\t...schema,\n\t\tcast: true, // TODO: double check this\n\t\tregexp: undefined,\n\t\tclean(value, context) {\n\t\t\tlet res: any = value\n\t\t\tif (res) {\n\t\t\t\tconst date = new Date(res)\n\t\t\t\tif (isNaN(date.getTime())) {\n\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\tgetMessage(context, \"invalid\", \"Invalid value.\")\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (schema.format === null) {\n\t\t\t\t\t// ok\n\t\t\t\t} else if (schema.format === \"iso\") {\n\t\t\t\t\tres = date.toISOString()\n\t\t\t\t} else {\n\t\t\t\t\tres = date\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn schema.clean ? schema.clean(res, context) : res\n\t\t},\n\t})\n\treturn setSchema(cleaner, schema)\n}\n","import { validate as validateEmail } from \"email-validator\"\n\nimport { ValidationError } from \"../errors/ValidationError\"\nimport { getMessage } from \"../utils\"\nimport { setSchema } from \"./any\"\nimport { cleanString, StringSchema } from \"./string\"\n\nexport type EmailSchema<T> = StringSchema<T>\n\nexport function cleanEmail<T = string, V = any>(schema: EmailSchema<T> = {}) {\n\tconst cleaner = cleanString<T, V>({\n\t\t...schema,\n\t\tcast: true, // why?\n\t\tclean(value, context) {\n\t\t\tif (value && !validateEmail(value as string)) {\n\t\t\t\tthrow new ValidationError(\n\t\t\t\t\tgetMessage(context, \"invalid_email\", \"Invalid e-mail address.\")\n\t\t\t\t)\n\t\t\t}\n\t\t\tconst res: any = value\n\t\t\treturn schema.clean ? schema.clean(res, context) : res\n\t\t},\n\t})\n\treturn setSchema(cleaner, schema)\n}\n","import { SchemaError } from \"../errors/SchemaError\"\nimport { ValidationError } from \"../errors/ValidationError\"\nimport { getMessage } from \"../utils\"\nimport { AnySchema, cleanAny, setSchema } from \"./any\"\n\nexport interface NumberSchema<T> extends AnySchema<T, number> {\n\t/** No strict type check, convert value with `parseInt(value)` */\n\tcast?: boolean\n\t/** Minimum allowed value */\n\tmin?: number\n\t/** Maximum allowed value */\n\tmax?: number\n\tparseNumber: (value: any) => number\n}\n\nexport function cleanNumber<T = number, V = any>(schema: NumberSchema<T>) {\n\tif (!schema.parseNumber) {\n\t\tthrow new SchemaError(\"clean.number needs 'parseNumber'\")\n\t}\n\tconst cleaner = cleanAny<T, V>({\n\t\trequired: schema.required,\n\t\tdefault: schema.default,\n\t\tnull: schema.null,\n\t\tclean(value, context) {\n\t\t\tlet res: any = value\n\t\t\tif (!(res === undefined || res === null)) {\n\t\t\t\tif (typeof res !== \"number\" && schema.cast !== true) {\n\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\tgetMessage(context, \"invalid\", \"Invalid value.\")\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (res === \"\" && (schema.null === true || schema.default === null)) {\n\t\t\t\t\tres = null\n\t\t\t\t} else {\n\t\t\t\t\tres = schema.parseNumber(res)\n\t\t\t\t\tif (isNaN(res)) {\n\t\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t\tgetMessage(context, \"invalid\", \"Invalid value.\")\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (schema.min !== undefined && res < schema.min) {\n\t\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t\tgetMessage(context, \"invalid\", \"Value too low.\")\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (schema.max !== undefined && res > schema.max) {\n\t\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\t\tgetMessage(context, \"invalid\", \"Value too high.\")\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (schema.clean) {\n\t\t\t\tres = schema.clean(res, context)\n\t\t\t}\n\t\t\treturn res\n\t\t},\n\t})\n\treturn setSchema(cleaner, schema)\n}\n","import { setSchema } from \"./any\"\nimport { cleanNumber, NumberSchema } from \"./number\"\n\nexport type FloatSchema<T> = Omit<NumberSchema<T>, \"parseNumber\">\n\nexport function cleanFloat<T = number, V = any>(schema: FloatSchema<T> = {}) {\n\tconst cleaner = cleanNumber<T, V>({\n\t\t...schema,\n\t\tparseNumber: parseFloat,\n\t})\n\treturn setSchema(cleaner, schema)\n}\n","import { setSchema } from \"./any\"\nimport { cleanNumber, NumberSchema } from \"./number\"\n\nexport type IntegerSchema<T> = Omit<NumberSchema<T>, \"parseNumber\">\n\nexport function cleanInteger<T = number, V = any>(\n\tschema: IntegerSchema<T> = {}\n) {\n\tconst cleaner = cleanNumber<T, V>({\n\t\t...schema,\n\t\tparseNumber: parseInt,\n\t})\n\treturn setSchema(cleaner, schema)\n}\n","import { capitalCase } from \"capital-case\"\n\nimport { SchemaError } from \"../errors/SchemaError\"\nimport {\n\tErrorMessages,\n\tErrorOptions,\n\tFieldErrorMessages,\n\tValidationError,\n} from \"../errors/ValidationError\"\nimport { Cleaner } from \"../types\"\nimport { getMessage } from \"../utils\"\nimport { AnySchema, cleanAny, setSchema } from \"./any\"\n\ntype Dict = Record<string, any>\n\ntype ParseKeysOptions = boolean | ((key: string) => string[])\n\nexport interface ObjectSchema<M, T> extends AnySchema<T, M> {\n\t/** Create nested objects from keys like `job.position`\n\t *\n\t * `true`: split by dots\n\t *\n\t * `(string) => string[]`: custom key path parser function\n\t */\n\tparseKeys?: ParseKeysOptions\n\t/** Map of field names to their respective cleaners */\n\tfields: {\n\t\t// TODO: properly document or remove (and fix types/tests) the `?` mark\n\t\t[F in keyof M]?: Cleaner<M[F]>\n\t}\n\t/** Non-field errors will be grouped under this pseudo field key */\n\tnonFieldErrorsKey?: string\n\t/** `groupErrors: true` (default) - group field errors by field name */\n\tgroupErrors?: boolean\n}\n\nexport function cleanObject<M extends Record<string, any>, T = M, V = any>(\n\tschema: ObjectSchema<M, T>\n) {\n\tif (!schema || typeof schema.fields !== \"object\") {\n\t\tthrow new SchemaError(\"clean.object schema must include fields.\")\n\t}\n\tconst schemaGroupErrors =\n\t\tschema.groupErrors !== undefined ? !!schema.groupErrors : true\n\t// TODO: prevent !groupErrors && nonFieldErrorsKey\n\n\tlet cleaner: Cleaner<T, V> = cleanAny({\n\t\trequired: schema.required,\n\t\tdefault: schema.default,\n\t\tnull: schema.null,\n\t\tasync clean(value, context = {}) {\n\t\t\tconst groupErrors =\n\t\t\t\tcontext.groupErrors !== undefined\n\t\t\t\t\t? !!context.groupErrors\n\t\t\t\t\t: schemaGroupErrors\n\t\t\tlet res: any = value\n\t\t\tconst collectedErrors: Array<{\n\t\t\t\tfield: string\n\t\t\t\tmessages: ErrorMessages\n\t\t\t\topts: ErrorOptions\n\t\t\t}> = []\n\t\t\tif (!(res === undefined || res === null)) {\n\t\t\t\tif (typeof res !== \"object\") {\n\t\t\t\t\tthrow new ValidationError(\n\t\t\t\t\t\tgetMessage(context, \"invalid\", \"Invalid value.\")\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tif (schema.parseKeys) {\n\t\t\t\t\tres = parseKeys(res, schema.parseKeys)\n\t\t\t\t}\n\t\t\t\tconst cleanRes: Dict = {}\n\t\t\t\tconst customDataStore = {}\n\t\t\t\tconst fieldCleanerContext = {\n\t\t\t\t\t...context,\n\t\t\t\t\tdata: customDataStore,\n\t\t\t\t\tgroupErrors: groupErrors === false ? groupErrors : undefined,\n\t\t\t\t}\n\t\t\t\tfor (const [field, fieldCleaner] of Object.entries(schema.fields)) {\n\t\t\t\t\tconst fieldValue = res.hasOwnProperty(field) ? res[field] : undefined\n\t\t\t\t\tlet cleanedFieldValue\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcleanedFieldValue = await fieldCleaner(\n\t\t\t\t\t\t\tfieldValue,\n\t\t\t\t\t\t\tfieldCleanerContext\n\t\t\t\t\t\t)\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tif (!(err instanceof ValidationError)) {\n\t\t\t\t\t\t\tthrow err\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (err.messages) {\n\t\t\t\t\t\t\t// plain errors -> {field: errors}\n\t\t\t\t\t\t\tcollectedErrors.push({\n\t\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\t\tmessages: err.messages,\n\t\t\t\t\t\t\t\topts: err.opts,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (err.errors) {\n\t\t\t\t\t\t\tif (!groupErrors) {\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\"Error grouping disabled, but nested cleaner threw grouped ValidationError. Make sure nested cleaners only throw simple ValidationError's\"\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfor (const subfield of Object.keys(err.errors)) {\n\t\t\t\t\t\t\t\t// {subfield: errors}  -> {field.subfield: errors}\n\t\t\t\t\t\t\t\tcollectedErrors.push({\n\t\t\t\t\t\t\t\t\tfield: field + \".\" + subfield,\n\t\t\t\t\t\t\t\t\tmessages: err.errors[subfield],\n\t\t\t\t\t\t\t\t\topts: err.opts,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (cleanedFieldValue !== undefined) {\n\t\t\t\t\t\tcleanRes[field] = cleanedFieldValue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tObject.assign(cleanRes, customDataStore)\n\t\t\t\tres = cleanRes\n\t\t\t}\n\n\t\t\tif (!collectedErrors.length) {\n\t\t\t\ttry {\n\t\t\t\t\t// Normal flow\n\t\t\t\t\tif (schema.clean) {\n\t\t\t\t\t\tres = await schema.clean(res, context)\n\t\t\t\t\t}\n\t\t\t\t\treturn res\n\t\t\t\t} catch (err) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!(err instanceof ValidationError) ||\n\t\t\t\t\t\terr.messages ||\n\t\t\t\t\t\tgroupErrors\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Normal error handling\n\t\t\t\t\t\tthrow err\n\t\t\t\t\t}\n\t\t\t\t\t// Error grouping disabled, but custom cleaner threw grouped errors\n\t\t\t\t\t// Pretend these were generated by fields, then they will be ungrouped below.\n\t\t\t\t\tif (err.errors) {\n\t\t\t\t\t\tfor (const field of Object.keys(err.errors)) {\n\t\t\t\t\t\t\tcollectedErrors.push({\n\t\t\t\t\t\t\t\tfield,\n\t\t\t\t\t\t\t\tmessages: err.errors[field],\n\t\t\t\t\t\t\t\topts: err.opts,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (groupErrors) {\n\t\t\t\tconst errors: FieldErrorMessages = {}\n\t\t\t\tfor (const { field, messages } of collectedErrors) {\n\t\t\t\t\tif (!errors[field]) {\n\t\t\t\t\t\terrors[field] = []\n\t\t\t\t\t}\n\t\t\t\t\terrors[field].push(...messages)\n\t\t\t\t}\n\t\t\t\tthrow new ValidationError(errors)\n\t\t\t} else {\n\t\t\t\tconst allMessages: ErrorMessages = []\n\t\t\t\tfor (const { field, messages, opts } of collectedErrors) {\n\t\t\t\t\tlet label = opts.label\n\t\t\t\t\tif (label === undefined) {\n\t\t\t\t\t\tlabel = (schema.fields[field] as any)?.schema?.label\n\t\t\t\t\t}\n\t\t\t\t\tif (label === undefined) {\n\t\t\t\t\t\tlabel = capitalCase(field)\n\t\t\t\t\t}\n\t\t\t\t\tallMessages.push(\n\t\t\t\t\t\t...(label\n\t\t\t\t\t\t\t? messages.map((message) => `${label}: ${message}`)\n\t\t\t\t\t\t\t: messages)\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tthrow new ValidationError(allMessages)\n\t\t\t}\n\t\t},\n\t})\n\n\tconst { nonFieldErrorsKey } = schema\n\tif (nonFieldErrorsKey !== undefined) {\n\t\tconst wrapped_cleaner = cleaner\n\t\tcleaner = async function (value, context) {\n\t\t\ttry {\n\t\t\t\treturn await wrapped_cleaner(value, context)\n\t\t\t} catch (err) {\n\t\t\t\tif (err instanceof ValidationError && err.messages) {\n\t\t\t\t\tthrow new ValidationError({ [nonFieldErrorsKey]: err.messages })\n\t\t\t\t} else {\n\t\t\t\t\tthrow err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn setSchema(cleaner, schema)\n}\n\nfunction parseKeys(obj: Dict, opts: ParseKeysOptions) {\n\tconst getPathFromKey =\n\t\ttypeof opts === \"function\" ? opts : (key: string) => key.split(\".\")\n\tconst res: Dict = {}\n\tfor (const key of Object.keys(obj)) {\n\t\tconst path = getPathFromKey(key)\n\t\tif (path) {\n\t\t\tsetObjPath(res, path, obj[key])\n\t\t}\n\t}\n\treturn res\n}\n\nfunction setObjPath(obj: Dict, path: string[], value: any): void {\n\tfor (let i = 0; i < path.length; ++i) {\n\t\tconst key = path[i]\n\t\tif (i < path.length - 1) {\n\t\t\tif (obj[key] === undefined) {\n\t\t\t\tobj[key] = {}\n\t\t\t}\n\t\t\tobj = obj[key]\n\t\t} else {\n\t\t\tobj[key] = value\n\t\t}\n\t}\n}\n\ncleanObject.fields = function <T extends Record<string, any>>(\n\tfields: ObjectSchema<T, T>[\"fields\"]\n) {\n\treturn cleanObject<T, T>({ fields })\n}\n","import { setSchema } from \"./any\"\nimport { cleanString, StringSchema } from \"./string\"\n\nexport type UuidSchema<T> = Omit<StringSchema<T>, \"regexp\">\n\nexport function cleanUuid<T = string, V = any>(schema: UuidSchema<T> = {}) {\n\tconst cleaner = cleanString<T, V>({\n\t\t...schema,\n\t\tregexp: /^[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}$/,\n\t})\n\treturn setSchema(cleaner, schema)\n}\n","export { cleanAny as any, AnySchema } from \"./any\"\nexport { cleanArray as array, ArraySchema } from \"./array\"\nexport { cleanBoolean as boolean, BooleanSchema } from \"./boolean\"\nexport { cleanDate as date, DateSchema } from \"./date\"\nexport { cleanEmail as email, EmailSchema } from \"./email\"\nexport { cleanFloat as float, FloatSchema } from \"./float\"\nexport { cleanInteger as integer, IntegerSchema } from \"./integer\"\nexport { cleanObject as object, ObjectSchema } from \"./object\"\nexport { cleanString as string, StringSchema } from \"./string\"\nexport { cleanUuid as uuid, UuidSchema } from \"./uuid\"\n"],"mappings":";;;;;;;AAAO,IAAM,cAAN,cAA0B,MAAM;AAAC;;;ACgBjC,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YACC,KACA,MACC;AACD,QAAI;AACJ,QAAI;AACJ,QAAI;AAEJ,QAAI,OAAO,QAAQ,UAAU;AAC5B,iBAAW,CAAC,GAAG;AACf,gBAAU;AAAA,IACX,WAAW,MAAM,QAAQ,GAAG,GAAG;AAC9B,UAAI,CAAC,IAAI,QAAQ;AAChB,cAAM,IAAI,MAAM,6CAA6C;AAAA,MAC9D;AACA,iBAA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