validup 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -21
- package/README.md +668 -113
- package/dist/index.d.mts +614 -0
- package/dist/index.mjs +766 -406
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -18
- package/dist/constants.d.ts +0 -17
- package/dist/container/check.d.ts +0 -2
- package/dist/container/index.d.ts +0 -3
- package/dist/container/module.d.ts +0 -21
- package/dist/container/types.d.ts +0 -101
- package/dist/error/base.d.ts +0 -5
- package/dist/error/check.d.ts +0 -5
- package/dist/error/index.d.ts +0 -2
- package/dist/helpers/error.d.ts +0 -2
- package/dist/helpers/index.d.ts +0 -3
- package/dist/helpers/optional-value.d.ts +0 -8
- package/dist/helpers/path-stringify.d.ts +0 -6
- package/dist/index.cjs +0 -462
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/issue/check.d.ts +0 -4
- package/dist/issue/constants.d.ts +0 -4
- package/dist/issue/define.d.ts +0 -5
- package/dist/issue/index.d.ts +0 -4
- package/dist/issue/types.d.ts +0 -47
- package/dist/types.d.ts +0 -24
- package/dist/utils/has-own-property.d.ts +0 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/object.d.ts +0 -1
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/helpers/error.ts","../src/constants.ts","../src/helpers/optional-value.ts","../src/helpers/path-stringify.ts","../src/error/base.ts","../src/utils/has-own-property.ts","../src/utils/object.ts","../src/issue/check.ts","../src/issue/constants.ts","../src/issue/define.ts","../src/error/check.ts","../src/container/check.ts","../src/container/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { distinctArray } from 'smob';\n\nexport function buildErrorMessageForAttribute(key: PropertyKey) {\n return `Property ${String(key)} is invalid`;\n}\n\nexport function buildErrorMessageForAttributes(input: PropertyKey[] | Record<string, any>) {\n let names: PropertyKey[];\n if (Array.isArray(input)) {\n names = distinctArray(input);\n } else {\n names = Object.keys(input);\n }\n\n if (names.length === 0) {\n return 'Properties are invalid';\n }\n\n if (names.length > 1) {\n return `Properties ${names.join(', ')} are invalid.`;\n }\n\n return buildErrorMessageForAttribute(names[0]);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum GroupKey {\n WILDCARD = '*',\n}\n\nexport enum OptionalValue {\n /**\n * value: undefined\n */\n UNDEFINED = 'undefined',\n /**\n * value: null & undefined\n */\n NULL = 'null',\n /**\n * value: empty string, false, 0\n */\n FALSY = 'falsy',\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { OptionalValue } from '../constants';\n\n/**\n * Check if input value (type of) satisfies optional value type constraint.\n *\n * @param value\n * @param optionalValue\n */\nexport function isOptionalValue(\n value: unknown,\n optionalValue?: `${OptionalValue}`,\n) {\n const optionValueNormalized = optionalValue || OptionalValue.UNDEFINED;\n\n if (optionValueNormalized === OptionalValue.NULL) {\n return value === null || typeof value === 'undefined';\n }\n\n if (optionValueNormalized === OptionalValue.UNDEFINED) {\n return typeof value === 'undefined';\n }\n\n return !value;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { arrayToPath } from 'pathtrace';\n\n/**\n * Stringify path array to string.\n *\n * @param input\n */\nexport function stringifyPath(input: PropertyKey[]) : string {\n return arrayToPath(input);\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { buildErrorMessageForAttributes, stringifyPath } from '../helpers';\nimport type { Issue } from '../issue';\n\nexport class ValidupError extends Error {\n readonly issues: Issue[];\n\n constructor(issues: Issue[] = []) {\n const paths = issues.map((issue) => stringifyPath(issue.path));\n super(buildErrorMessageForAttributes(paths));\n\n this.issues = issues;\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function hasOwnProperty<X extends {}, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isObject(input: unknown) : input is Record<string, any> {\n return !!input &&\n typeof input === 'object' &&\n !Array.isArray(input);\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '../utils';\nimport type {\n Issue, IssueBase, IssueGroup, IssueItem,\n} from './types';\n\nfunction isIssuePath(input: unknown) : input is PropertyKey[] {\n if (!Array.isArray(input)) {\n return false;\n }\n\n return input.every((el) => typeof el === 'string' ||\n typeof el === 'number' ||\n typeof el === 'symbol');\n}\n\nfunction isBaseIssue(input: unknown) : input is IssueBase & {[ke: string]: any} {\n if (!isObject(input)) {\n return false;\n }\n\n if (typeof input.message !== 'string') {\n return false;\n }\n\n if (!isIssuePath(input.path)) {\n return false;\n }\n\n return typeof input.meta === 'undefined' ||\n isObject(input.meta);\n}\n\nexport function isIssueItem(input: unknown) : input is IssueItem {\n if (!isBaseIssue(input)) {\n return false;\n }\n\n if (input.type !== 'item') {\n return false;\n }\n\n return typeof input.code === 'string';\n}\n\nexport function isIssueGroup(input: unknown) : input is IssueGroup {\n if (!isBaseIssue(input)) {\n return false;\n }\n\n if (input.type !== 'group') {\n return false;\n }\n\n return Array.isArray(input.issues) &&\n input.issues.every((issue) => isIssueItem(issue) || isIssueGroup(issue));\n}\n\nexport function isIssue(input: unknown) : input is Issue {\n return isIssueGroup(input) || isIssueItem(input);\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum IssueCode {\n VALUE_INVALID = 'value_invalid',\n\n ONE_OF_FAILED = 'one_of_failed',\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { IssueCode } from './constants';\nimport type { IssueGroup, IssueItem } from './types';\n\ntype PartialProps<T extends Record<PropertyKey, any>, K extends keyof T> = Pick<T, Exclude<keyof T, K>> & Partial<Pick<T, K>>;\n\nexport function defineIssueItem(data: Omit<PartialProps<IssueItem, 'code'>, 'type'>): IssueItem {\n return {\n type: 'item',\n ...data,\n code: IssueCode.VALUE_INVALID || data.code,\n };\n}\n\nexport function defineIssueGroup(data: Omit<IssueGroup, 'type'>): IssueGroup {\n return {\n type: 'group',\n ...data,\n };\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isIssue } from '../issue';\nimport { hasOwnProperty, isObject } from '../utils';\nimport { ValidupError } from './base';\n\nexport function isError(input: unknown) : input is Error & { [key: string]: any } {\n if (!isObject(input)) {\n return false;\n }\n\n return typeof input.message === 'string';\n}\n\nexport function isValidupError(error: unknown) : error is ValidupError {\n if (!isError(error)) {\n return false;\n }\n\n if (error instanceof ValidupError) {\n return true;\n }\n\n if (!hasOwnProperty(error, 'issues')) {\n return false;\n }\n\n return Array.isArray(error.issues) &&\n error.issues.every((issue) => isIssue(issue));\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '../utils';\nimport type { IContainer } from './types';\n\nexport function isContainer(input: unknown) : input is IContainer {\n return isObject(input) &&\n typeof input.run === 'function';\n}\n","/*\n * Copyright (c) 2024-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Path } from 'pathtrace';\nimport {\n expandPath, getPathValue, pathToArray, setPathValue,\n} from 'pathtrace';\nimport { GroupKey } from '../constants';\nimport { ValidupError, isError, isValidupError } from '../error';\nimport { buildErrorMessageForAttribute, isOptionalValue } from '../helpers';\nimport type { Validator } from '../types';\nimport { hasOwnProperty, isObject } from '../utils';\nimport { isContainer } from './check';\nimport type {\n ContainerOptions, ContainerRunOptions, IContainer, Mount, MountOptions,\n} from './types';\nimport type { Issue } from '../issue';\nimport { IssueCode, defineIssueGroup, defineIssueItem } from '../issue';\n\nexport class Container<\n T extends Record<string, any> = Record<string, any>,\n> implements IContainer {\n protected options : ContainerOptions<T>;\n\n protected items : Mount[];\n\n // ----------------------------------------------\n\n constructor(options: ContainerOptions<T> = {}) {\n this.options = options;\n this.items = [];\n\n this.initialize();\n }\n\n // ----------------------------------------------\n\n mount(container: IContainer) : void;\n\n mount(\n options: MountOptions,\n container: IContainer\n ): void;\n\n mount(\n // eslint-disable-next-line @typescript-eslint/ban-types\n key: Path<T> | (string & {}),\n data: IContainer | Validator\n ) : void;\n\n mount(\n // eslint-disable-next-line @typescript-eslint/ban-types\n key: Path<T> | (string & {}),\n options: MountOptions,\n data: IContainer | Validator\n ) : void;\n\n mount(...args: any[]) : void {\n if (args.length < 1) {\n throw new SyntaxError('The mount method requires at least one argument');\n }\n\n let path : string | undefined;\n\n let data: IContainer | Validator | undefined;\n let dataIsContainer : boolean = false;\n\n let options: MountOptions = {};\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n\n if (typeof arg === 'string') {\n path = arg;\n continue;\n }\n\n if (typeof arg === 'function') {\n data = arg;\n continue;\n }\n\n if (isContainer(arg)) {\n data = arg;\n dataIsContainer = true;\n continue;\n }\n\n if (isObject(arg)) {\n options = args[i];\n }\n }\n\n if (\n !dataIsContainer &&\n (typeof path === 'undefined' || path.length === 0)\n ) {\n throw new SyntaxError('Only a container can be mounted without a key.');\n }\n\n if (typeof data === 'undefined') {\n throw new SyntaxError('No container/validator could be extracted from the fn arguments.');\n }\n\n if (isContainer(data)) {\n this.items.push({\n options,\n data,\n path,\n type: 'container',\n });\n\n return;\n }\n\n this.items.push({\n options,\n data,\n path,\n type: 'validator',\n });\n }\n\n // ----------------------------------------------\n\n /**\n * @throws ValidupError\n * @param data\n * @param options\n */\n async run(\n data: Record<string, any> = {},\n options: ContainerRunOptions<T> = {},\n ): Promise<T> {\n let pathsToInclude : string[] | undefined;\n if (options.pathsToInclude) {\n pathsToInclude = options.pathsToInclude as string[];\n } else if (this.options.pathsToInclude) {\n pathsToInclude = this.options.pathsToInclude as string[];\n }\n\n let pathsToExclude : string[] | undefined;\n if (options.pathsToExclude) {\n pathsToExclude = options.pathsToExclude as string[];\n } else if (this.options.pathsToInclude) {\n pathsToExclude = this.options.pathsToExclude as string[];\n }\n\n const output: Record<string, any> = {};\n\n const issues : Issue[] = [];\n\n let itemCount : number = 0;\n let errorCount : number = 0;\n\n for (let i = 0; i < this.items.length; i++) {\n const item = this.items[i];\n\n if (!this.isItemGroupIncluded(item, options.group)) {\n // todo: maybe add issue info\n continue;\n }\n\n let pathCount = 0;\n let pathFailed = false;\n\n let keys : string[];\n if (item.path) {\n keys = expandPath(data, item.path);\n } else {\n keys = [''];\n }\n\n for (let j = 0; j < keys.length; j++) {\n const key = keys[j];\n const keyParts = key ? pathToArray(key) : [];\n\n const pathRelative = keyParts.at(-1);\n const pathAbsolute = [\n ...(options.path ? options.path : []),\n ...keyParts,\n ];\n\n let value : unknown;\n if (key.length > 0) {\n value = hasOwnProperty(output, key) ?\n output[key] :\n getPathValue(data, key);\n } else {\n value = data;\n }\n\n if (\n typeof pathsToInclude !== 'undefined' &&\n pathsToInclude.indexOf(key) === -1\n ) {\n // todo: maybe add issue info\n continue;\n }\n\n if (\n typeof pathsToExclude !== 'undefined' &&\n pathsToExclude.indexOf(key) !== -1\n ) {\n // todo: maybe add issue info\n continue;\n }\n\n try {\n if (\n item.options.optional &&\n isOptionalValue(value, item.options.optionalValue)\n ) {\n if (item.options.optionalInclude) {\n output[key] = value;\n }\n } else if (item.type === 'container') {\n const tmp = await item.data.run(\n isObject(value) ? value : {},\n {\n group: options.group,\n flat: true,\n path: pathAbsolute,\n pathsToInclude: options.pathsToInclude,\n // todo: extract defaults for container\n },\n );\n\n const tmpKeys = Object.keys(tmp);\n for (let k = 0; k < tmpKeys.length; k++) {\n output[this.mergePaths(key, tmpKeys[k])] = tmp[tmpKeys[k]];\n }\n } else if (item.type === 'validator') {\n output[key] = await item.data({\n key,\n path: pathAbsolute,\n\n value,\n data,\n group: options.group,\n });\n }\n } catch (e) {\n const childIssues : Issue[] = [];\n\n if (isValidupError(e)) {\n for (let i = 0; i < e.issues.length; i++) {\n const issue = e.issues[i];\n\n childIssues.push({\n ...issue,\n path: [\n ...keyParts,\n ...(issue.path || []),\n ],\n });\n }\n } else if (isError(e)) {\n childIssues.push(defineIssueItem({\n path: keyParts,\n message: e.message,\n }));\n }\n\n if (pathRelative) {\n if (item.type === 'container' || childIssues.length > 1) {\n const group = defineIssueGroup({\n message: buildErrorMessageForAttribute(pathRelative),\n path: keyParts,\n issues: childIssues,\n });\n\n issues.push(group);\n } else {\n issues.push(...childIssues);\n }\n } else {\n issues.push(...childIssues);\n }\n\n pathFailed = true;\n }\n\n pathCount++;\n }\n\n if (pathCount > 0) {\n itemCount++;\n\n if (pathFailed) {\n errorCount++;\n }\n }\n }\n\n if (this.options.oneOf) {\n if (errorCount === itemCount) {\n const group = defineIssueGroup({\n code: IssueCode.ONE_OF_FAILED,\n message: 'None of the branches succeeded',\n issues,\n path: options.path ? options.path : [],\n });\n\n throw new ValidupError([group]);\n }\n } else if (errorCount > 0) {\n throw new ValidupError(issues);\n }\n\n if (options.defaults) {\n const defaultKeys = Object.keys(options.defaults);\n for (let i = 0; i < defaultKeys.length; i++) {\n if (\n !hasOwnProperty(output, defaultKeys[i]) ||\n typeof output[defaultKeys[i]] === 'undefined'\n ) {\n output[defaultKeys[i]] = options.defaults[defaultKeys[i] as unknown as Path<T>];\n }\n }\n }\n\n if (options.flat) {\n return output as T;\n }\n\n const temp : Record<string, any> = {};\n\n const keys = Object.keys(output);\n for (let i = 0; i < keys.length; i++) {\n setPathValue(temp, keys[i], output[keys[i]]);\n }\n\n return temp as T;\n }\n\n private isItemGroupIncluded(\n item: Mount,\n group?: string,\n ) : boolean {\n if (group === GroupKey.WILDCARD) {\n return true;\n }\n\n if (item.options.group) {\n if (Array.isArray(item.options.group)) {\n if (item.options.group.indexOf(GroupKey.WILDCARD) !== -1) {\n return true;\n }\n\n if (group && item.options.group.indexOf(group) !== -1) {\n return true;\n }\n } else {\n if (item.options.group === GroupKey.WILDCARD) {\n return true;\n }\n\n if (item.options.group === group) {\n return true;\n }\n }\n\n return false;\n }\n\n return true;\n }\n\n private mergePaths(...args: (string | undefined)[]) {\n let output : string = '';\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (!arg || arg.length === 0) {\n continue;\n }\n\n if (arg.at(0) === '.') {\n output += arg;\n } else {\n output += output.length > 0 ? `.${arg}` : arg;\n }\n }\n\n return output;\n }\n\n protected initialize() : void {\n\n }\n}\n"],"names":["buildErrorMessageForAttribute","key","String","buildErrorMessageForAttributes","input","names","Array","isArray","distinctArray","Object","keys","length","join","GroupKey","OptionalValue","isOptionalValue","value","optionalValue","optionValueNormalized","UNDEFINED","NULL","stringifyPath","arrayToPath","ValidupError","Error","issues","paths","map","issue","path","hasOwnProperty","obj","prop","prototype","call","isObject","isIssuePath","every","el","isBaseIssue","message","meta","isIssueItem","type","code","isIssueGroup","isIssue","IssueCode","defineIssueItem","data","VALUE_INVALID","defineIssueGroup","isError","isValidupError","error","isContainer","run","Container","mount","args","SyntaxError","dataIsContainer","options","i","arg","items","push","pathsToInclude","pathsToExclude","output","itemCount","errorCount","item","isItemGroupIncluded","group","pathCount","pathFailed","expandPath","j","keyParts","pathToArray","pathRelative","at","pathAbsolute","getPathValue","indexOf","optional","optionalInclude","tmp","flat","tmpKeys","k","mergePaths","e","childIssues","oneOf","ONE_OF_FAILED","defaults","defaultKeys","temp","setPathValue","WILDCARD","initialize"],"mappings":";;;AASO,SAASA,8BAA8BC,GAAgB,EAAA;AAC1D,IAAA,OAAO,CAAC,SAAS,EAAEC,MAAAA,CAAOD,GAAAA,CAAAA,CAAK,WAAW,CAAC;AAC/C;AAEO,SAASE,+BAA+BC,KAA0C,EAAA;IACrF,IAAIC,KAAAA;IACJ,IAAIC,KAAAA,CAAMC,OAAO,CAACH,KAAAA,CAAAA,EAAQ;AACtBC,QAAAA,KAAAA,GAAQG,aAAAA,CAAcJ,KAAAA,CAAAA;IAC1B,CAAA,MAAO;QACHC,KAAAA,GAAQI,MAAAA,CAAOC,IAAI,CAACN,KAAAA,CAAAA;AACxB,IAAA;IAEA,IAAIC,KAAAA,CAAMM,MAAM,KAAK,CAAA,EAAG;QACpB,OAAO,wBAAA;AACX,IAAA;IAEA,IAAIN,KAAAA,CAAMM,MAAM,GAAG,CAAA,EAAG;QAClB,OAAO,CAAC,WAAW,EAAEN,KAAAA,CAAMO,IAAI,CAAC,IAAA,CAAA,CAAM,aAAa,CAAC;AACxD,IAAA;IAEA,OAAOZ,6BAAAA,CAA8BK,KAAK,CAAC,CAAA,CAAE,CAAA;AACjD;;AC9BA;;;;;IAOO,IAAKQ,QAAAA,iBAAAA,SAAAA,QAAAA,EAAAA;;AAAAA,IAAAA,OAAAA,QAAAA;AAEX,CAAA,CAAA,EAAA;AAEM,IAAA,aAAKC,iBAAAA,SAAAA,aAAAA,EAAAA;AACR;;AAEC,QAAA,aAAA,CAAA,WAAA,CAAA,GAAA,W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GAAAA,IAAOA,GAAAA,CAAIrD,MAAM,KAAK,CAAA,EAAG;AAC1B,gBAAA;AACJ,YAAA;AAEA,YAAA,IAAIqD,GAAAA,CAAIkB,EAAE,CAAC,CAAA,CAAA,KAAO,GAAA,EAAK;gBACnBb,MAAAA,IAAUL,GAAAA;YACd,CAAA,MAAO;gBACHK,MAAAA,IAAUA,MAAAA,CAAO1D,MAAM,GAAG,CAAA,GAAI,CAAC,CAAC,EAAEqD,KAAK,GAAGA,GAAAA;AAC9C,YAAA;AACJ,QAAA;QAEA,OAAOK,MAAAA;AACX,IAAA;AAEUiC,IAAAA,UAAAA,GAAoB,CAE9B;;IA1WA,WAAA,CAAYxC,OAAAA,GAA+B,EAAE,CAAE;QAC3C,IAAI,CAACA,OAAO,GAAGA,OAAAA;QACf,IAAI,CAACG,KAAK,GAAG,EAAE;AAEf,QAAA,IAAI,CAACqC,UAAU,EAAA;AACnB,IAAA;AAsWJ;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["interpolate"],"sources":["../src/helpers/defaults.ts","../src/helpers/error.ts","../src/constants.ts","../src/helpers/optional-value.ts","../src/helpers/path-filter.ts","../src/helpers/path-stringify.ts","../src/error/base.ts","../src/utils/has-own-property.ts","../src/utils/object.ts","../src/issue/check.ts","../src/issue/constants.ts","../src/issue/define.ts","../src/issue/flatten.ts","../src/issue/format.ts","../src/error/check.ts","../src/container/check.ts","../src/container/run-sync-violation.ts","../src/container/module.ts","../src/builder/module.ts"],"sourcesContent":["/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n/**\n * Slice a parent `defaults` map down to entries that target paths inside a\n * single nested container mount, with the mount-key prefix stripped so the\n * child sees them as local keys. Exact-key matches (the default targets the\n * mount root itself) are skipped — the parent's post-loop fill handles those\n * once the child has returned, since the child is run with `flat: true` and\n * cannot address its own root.\n */\nexport function resolveDefaults(\n defaults: Record<string, any> | undefined,\n key: string,\n): Record<string, any> | undefined {\n if (typeof defaults === 'undefined') {\n return undefined;\n }\n if (key.length === 0) {\n return defaults;\n }\n\n const output: Record<string, any> = {};\n let matched = false;\n const keys = Object.keys(defaults);\n for (const k of keys) {\n if (k.startsWith(`${key}.`)) {\n output[k.slice(key.length + 1)] = defaults[k];\n matched = true;\n }\n }\n return matched ? output : undefined;\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { distinctArray } from 'smob';\n\nexport function buildErrorMessageForAttribute(key: PropertyKey) {\n return `Property ${String(key)} is invalid`;\n}\n\nexport function buildErrorMessageForAttributes(input: PropertyKey[] | Record<string, any>) {\n let names: PropertyKey[];\n if (Array.isArray(input)) {\n names = distinctArray(input);\n } else {\n names = Object.keys(input);\n }\n\n if (names.length === 0) {\n return 'Properties are invalid';\n }\n\n if (names.length > 1) {\n return `Properties ${names.join(', ')} are invalid.`;\n }\n\n return buildErrorMessageForAttribute(names[0]);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum GroupKey {\n WILDCARD = '*',\n}\n\nexport enum OptionalValue {\n /**\n * value: undefined\n */\n UNDEFINED = 'undefined',\n /**\n * value: null & undefined\n */\n NULL = 'null',\n /**\n * value: empty string, false, 0\n */\n FALSY = 'falsy',\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { OptionalValue } from '../constants';\n\n/**\n * Check if input value (type of) satisfies optional value type constraint.\n *\n * @param value\n * @param optionalValue\n */\nexport function isOptionalValue(\n value: unknown,\n optionalValue?: `${OptionalValue}`,\n) {\n const optionValueNormalized = optionalValue || OptionalValue.UNDEFINED;\n\n if (optionValueNormalized === OptionalValue.NULL) {\n return value === null || typeof value === 'undefined';\n }\n\n if (optionValueNormalized === OptionalValue.UNDEFINED) {\n return typeof value === 'undefined';\n }\n\n return !value;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport type PathFilterResolution = {\n skip: boolean,\n pathsToInclude: string[] | undefined,\n pathsToExclude: string[] | undefined,\n};\n\n/**\n * Resolve `pathsToInclude` / `pathsToExclude` against a single mounted item's\n * (already-expanded) local `key`. Returns whether to skip the item, plus the\n * filter sub-lists to forward into a child container — with the parent prefix\n * stripped so the child can match purely against its own local keys.\n *\n * Semantics:\n * - Un-keyed container mount (`key === ''`) shares the parent's namespace, so\n * filters are forwarded verbatim.\n * - Exact match in `pathsToInclude` / `pathsToExclude` matches the whole mount.\n * - Prefix match (`<key>.…`) only descends into container mounts; leaf\n * validators with deeper-target filters fall through (skipped for include,\n * kept for exclude).\n */\nexport function resolvePathFilter(\n pathsToInclude: string[] | undefined,\n pathsToExclude: string[] | undefined,\n key: string,\n isContainer: boolean,\n): PathFilterResolution {\n if (key.length === 0) {\n return {\n skip: false,\n pathsToInclude,\n pathsToExclude,\n };\n }\n\n let includeForward: string[] | undefined;\n if (typeof pathsToInclude !== 'undefined') {\n let exact = false;\n const stripped: string[] = [];\n for (const path of pathsToInclude) {\n if (path === key) {\n exact = true;\n } else if (isContainer && path.startsWith(`${key}.`)) {\n stripped.push(path.slice(key.length + 1));\n }\n }\n if (exact) {\n includeForward = undefined;\n } else if (stripped.length > 0) {\n includeForward = stripped;\n } else {\n return {\n skip: true,\n pathsToInclude: undefined,\n pathsToExclude: undefined,\n };\n }\n }\n\n let excludeForward: string[] | undefined;\n if (typeof pathsToExclude !== 'undefined') {\n const stripped: string[] = [];\n for (const path of pathsToExclude) {\n if (path === key) {\n return {\n skip: true,\n pathsToInclude: undefined,\n pathsToExclude: undefined,\n };\n }\n if (isContainer && path.startsWith(`${key}.`)) {\n stripped.push(path.slice(key.length + 1));\n }\n }\n if (stripped.length > 0) {\n excludeForward = stripped;\n }\n }\n\n return {\n skip: false,\n pathsToInclude: includeForward,\n pathsToExclude: excludeForward,\n };\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { arrayToPath } from 'pathtrace';\n\n/**\n * Stringify path array to string.\n *\n * @param input\n */\nexport function stringifyPath(input: PropertyKey[]) : string {\n return arrayToPath(input);\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BaseError } from '@ebec/core';\nimport { buildErrorMessageForAttributes, stringifyPath } from '../helpers';\nimport type { Issue } from '../issue';\n\nexport class ValidupError extends BaseError {\n readonly issues: Issue[];\n\n constructor(issues: Issue[] = []) {\n const paths = issues.map((issue) => stringifyPath(issue.path));\n super({ message: buildErrorMessageForAttributes(paths) });\n\n this.issues = issues;\n }\n\n override toJSON(): ReturnType<BaseError['toJSON']> & { issues: Issue[] } {\n return {\n ...super.toJSON(),\n issues: this.issues,\n };\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function hasOwnProperty<X extends {}, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isObject(input: unknown) : input is Record<string, any> {\n return !!input &&\n typeof input === 'object' &&\n !Array.isArray(input);\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '../utils';\nimport type {\n Issue, \n IssueBase, \n IssueGroup, \n IssueItem,\n} from './types';\n\nfunction isIssuePath(input: unknown) : input is PropertyKey[] {\n if (!Array.isArray(input)) {\n return false;\n }\n\n return input.every((el) => typeof el === 'string' ||\n typeof el === 'number' ||\n typeof el === 'symbol');\n}\n\nfunction isBaseIssue(input: unknown) : input is IssueBase & { [ke: string]: any } {\n if (!isObject(input)) {\n return false;\n }\n\n if (typeof input.message !== 'string') {\n return false;\n }\n\n if (!isIssuePath(input.path)) {\n return false;\n }\n\n return typeof input.meta === 'undefined' ||\n isObject(input.meta);\n}\n\nexport function isIssueItem(input: unknown) : input is IssueItem {\n if (!isBaseIssue(input)) {\n return false;\n }\n\n if (input.type !== 'item') {\n return false;\n }\n\n return typeof input.code === 'string';\n}\n\nexport function isIssueGroup(input: unknown) : input is IssueGroup {\n if (!isBaseIssue(input)) {\n return false;\n }\n\n if (input.type !== 'group') {\n return false;\n }\n\n return Array.isArray(input.issues) &&\n input.issues.every((issue) => isIssueItem(issue) || isIssueGroup(issue));\n}\n\nexport function isIssue(input: unknown) : input is Issue {\n return isIssueGroup(input) || isIssueItem(input);\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n/**\n * Registry of well-known issue codes. Third-party packages can extend the\n * union via TypeScript declaration merging:\n *\n * ```ts\n * declare module 'validup' {\n * interface IssueCodeRegistry {\n * email_taken: 'email_taken';\n * }\n * }\n * ```\n *\n * After augmentation, `IssueCode` widens to include the new literal so\n * `defineIssueItem({ code: 'email_taken', ... })` is type-checked.\n */\nexport interface IssueCodeRegistry {\n VALUE_INVALID: 'value_invalid',\n ONE_OF_FAILED: 'one_of_failed',\n}\n\nexport type IssueCode = IssueCodeRegistry[keyof IssueCodeRegistry];\n\nexport const IssueCode = {\n VALUE_INVALID: 'value_invalid',\n ONE_OF_FAILED: 'one_of_failed',\n} as const satisfies { [K in keyof IssueCodeRegistry]: IssueCodeRegistry[K] };\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { IssueCode } from './constants';\nimport type { IssueGroup, IssueItem } from './types';\n\ntype PartialProps<T extends Record<PropertyKey, any>, K extends keyof T> = Pick<T, Exclude<keyof T, K>> & Partial<Pick<T, K>>;\n\nexport function defineIssueItem(data: Omit<PartialProps<IssueItem, 'code'>, 'type'>): IssueItem {\n return {\n type: 'item',\n ...data,\n code: data.code || IssueCode.VALUE_INVALID,\n };\n}\n\nexport function defineIssueGroup(data: Omit<IssueGroup, 'type'>): IssueGroup {\n return {\n type: 'group',\n ...data,\n };\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isIssueGroup, isIssueItem } from './check';\nimport type { Issue, IssueGroup, IssueItem } from './types';\n\nexport function flattenIssueItems(issues: Issue[]): IssueItem[] {\n const output: IssueItem[] = [];\n for (const issue of issues) {\n if (isIssueItem(issue)) {\n output.push(issue);\n } else {\n output.push(...flattenIssueItems(issue.issues));\n }\n }\n return output;\n}\n\nexport function flattenIssueGroups(issues: Issue[]): IssueGroup[] {\n const output: IssueGroup[] = [];\n for (const issue of issues) {\n if (isIssueGroup(issue)) {\n output.push(issue);\n output.push(...flattenIssueGroups(issue.issues));\n }\n }\n return output;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { interpolate } from '@ebec/core';\nimport type { IssueCode } from './constants';\nimport type { Issue } from './types';\n\n/**\n * Map of issue `code` → message template. Templates use `{name}` placeholders\n * — the same syntax `@ebec/core`'s `interpolate` understands — and are\n * resolved against `Issue.params` at format time.\n *\n * ```ts\n * const de: IssueMessageTemplates = {\n * value_invalid: 'Wert ist ungültig',\n * one_of_failed: 'Keine der Varianten war erfolgreich',\n * };\n * ```\n */\nexport type IssueMessageTemplates = Partial<Record<IssueCode, string>> & Record<string, string>;\n\n/**\n * Render an issue's user-facing message.\n *\n * Resolution order:\n * 1. If `templates[code]` exists, return `interpolate(template, issue.params)`.\n * 2. Else return `issue.message` (the default English rendering set at\n * construction time).\n * 3. Else return `fallback`.\n */\nexport function formatIssue(\n issue: Issue,\n templates?: IssueMessageTemplates,\n fallback: string = '',\n): string {\n if (templates && issue.code) {\n const template = templates[issue.code];\n if (typeof template === 'string') {\n return interpolate(template, issue.params || {});\n }\n }\n if (typeof issue.message === 'string' && issue.message.length > 0) {\n return issue.message;\n }\n return fallback;\n}\n\n// Re-export ebec's `interpolate` so consumers writing custom formatters don't\n// need a direct dependency on `@ebec/core`. Same `{name}` placeholder syntax.\nexport { interpolate } from '@ebec/core';\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isIssue } from '../issue';\nimport { hasOwnProperty, isObject } from '../utils';\nimport { ValidupError } from './base';\n\nexport function isError(input: unknown) : input is Error & { [key: string]: any } {\n // Primary check: anything that walks like an Error in this realm.\n // Keeps cross-realm fallbacks (e.g. errors from another iframe / vm\n // context where `instanceof Error` is false) duck-typed via the\n // `message` shape — which also matches `ValidupError`-shaped throws\n // from a duplicate copy of the package.\n if (input instanceof Error) {\n return true;\n }\n\n if (!isObject(input)) {\n return false;\n }\n\n return typeof input.message === 'string' && typeof input.name === 'string';\n}\n\nexport function isValidupError(error: unknown) : error is ValidupError {\n if (!isError(error)) {\n return false;\n }\n\n if (error instanceof ValidupError) {\n return true;\n }\n\n if (!hasOwnProperty(error, 'issues')) {\n return false;\n }\n\n return Array.isArray(error.issues) &&\n error.issues.every((issue) => isIssue(issue));\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '../utils';\nimport type { IContainer } from './types';\n\nexport function isContainer(input: unknown) : input is IContainer {\n return isObject(input) &&\n typeof input.run === 'function' &&\n typeof input.safeRun === 'function';\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n/**\n * Thrown by `Container.runSync` when a validator returns a Promise or a\n * nested container does not implement `runSync`. Marked separately from\n * generic `Error` so the per-mount catch can re-throw it instead of folding\n * it into the issue list (otherwise users would get \"Property X is invalid\"\n * instead of the structural diagnostic).\n *\n * Internal — not exported from the package barrel.\n */\nexport class RunSyncViolationError extends Error {\n override readonly name = 'RunSyncViolationError';\n}\n\n/**\n * Duck-typed check — robust against `instanceof` mismatches when a duplicate\n * copy of the package exists in the dependency tree, or when the throw\n * crosses a realm boundary. Mirrors the `isValidupError` pattern.\n */\nexport function isRunSyncViolation(e: unknown): e is RunSyncViolationError {\n if (e instanceof RunSyncViolationError) {\n return true;\n }\n return (\n typeof e === 'object' &&\n e !== null &&\n (e as { name?: unknown }).name === 'RunSyncViolationError'\n );\n}\n","/*\n * Copyright (c) 2024-2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Path } from 'pathtrace';\nimport {\n expandPath, \n getPathValue, \n pathToArray, \n setPathValue,\n} from 'pathtrace';\nimport { GroupKey } from '../constants';\nimport { ValidupError, isError, isValidupError } from '../error';\nimport {\n buildErrorMessageForAttribute,\n isOptionalValue,\n resolveDefaults,\n resolvePathFilter,\n} from '../helpers';\nimport type { Validator } from '../types';\nimport { hasOwnProperty, isObject } from '../utils';\nimport { isContainer } from './check';\nimport type {\n ContainerOptions,\n ContainerRunOptions,\n IContainer,\n Mount,\n MountOptions,\n Result,\n} from './types';\nimport type { Issue } from '../issue';\nimport { IssueCode, defineIssueGroup, defineIssueItem } from '../issue';\nimport { RunSyncViolationError, isRunSyncViolation } from './run-sync-violation';\n\nexport class Container<\n T extends Record<string, any> = Record<string, any>,\n C = unknown,\n> implements IContainer<T, C> {\n protected options : ContainerOptions<T>;\n\n protected items : Mount<C>[];\n\n // ----------------------------------------------\n\n constructor(options: ContainerOptions<T> = {}) {\n this.options = options;\n this.items = [];\n\n this.initialize();\n }\n\n // ----------------------------------------------\n\n mount(container: IContainer<any, any>) : void;\n\n mount(\n options: MountOptions,\n container: IContainer<any, any>\n ): void;\n\n mount(\n key: Path<T> | (string & {}),\n data: IContainer<any, any> | Validator<C>\n ) : void;\n\n mount(\n key: Path<T> | (string & {}),\n options: MountOptions,\n data: IContainer<any, any> | Validator<C>\n ) : void;\n\n mount(...args: any[]) : void {\n if (args.length < 1) {\n throw new SyntaxError('The mount method requires at least one argument');\n }\n\n let path : string | undefined;\n\n let data: IContainer<any, any> | Validator<C> | undefined;\n let dataIsContainer : boolean = false;\n\n let options: MountOptions = {};\n\n for (const arg of args) {\n if (typeof arg === 'string') {\n path = arg;\n continue;\n }\n\n if (typeof arg === 'function') {\n data = arg;\n continue;\n }\n\n if (isContainer(arg)) {\n data = arg;\n dataIsContainer = true;\n continue;\n }\n\n if (isObject(arg)) {\n options = arg;\n }\n }\n\n if (\n !dataIsContainer &&\n (typeof path === 'undefined' || path.length === 0)\n ) {\n throw new SyntaxError('Only a container can be mounted without a key.');\n }\n\n if (typeof data === 'undefined') {\n throw new SyntaxError('No container/validator could be extracted from the fn arguments.');\n }\n\n if (isContainer(data)) {\n this.items.push({\n options,\n data,\n path,\n type: 'container',\n });\n\n return;\n }\n\n this.items.push({\n options,\n data: data as Validator<C>,\n path,\n type: 'validator',\n });\n }\n\n // ----------------------------------------------\n\n /**\n * @throws ValidupError\n *\n * @param data\n * @param options\n */\n async run(\n data: Record<string, any> = {},\n options: ContainerRunOptions<T, C> = {},\n ): Promise<T> {\n if (options.parallel) {\n return this.runParallel(data, options);\n }\n\n const { pathsToInclude, pathsToExclude } = this.resolveContainerFilters(options);\n\n const output: Record<string, any> = {};\n const issues: Issue[] = [];\n\n let itemCount = 0;\n let errorCount = 0;\n\n for (let i = 0; i < this.items.length; i++) {\n // Pre-mount abort check — cheap and short-circuits cleanly without\n // entering the per-mount try/catch (so aborts don't get rewritten\n // into validation issues).\n options.signal?.throwIfAborted();\n\n const item = this.items[i];\n\n if (!this.isItemGroupIncluded(item, options.group)) {\n continue;\n }\n\n let pathCount = 0;\n let pathFailed = false;\n\n const keys: string[] = item.path ? expandPath(data, item.path) : [''];\n\n for (const key of keys) {\n const keyParts = key ? pathToArray(key) : [];\n\n const pathRelative = keyParts.at(-1);\n const pathAbsolute = [\n ...(options.path ? options.path : []),\n ...keyParts,\n ];\n\n let value: unknown;\n if (key.length > 0) {\n value = hasOwnProperty(output, key) ?\n output[key] :\n getPathValue(data, key);\n } else {\n value = data;\n }\n\n const filter = resolvePathFilter(\n pathsToInclude,\n pathsToExclude,\n key,\n item.type === 'container',\n );\n if (filter.skip) {\n continue;\n }\n\n try {\n const isOptional = typeof item.options.optional === 'function' ?\n item.options.optional(value) :\n item.options.optional &&\n isOptionalValue(value, item.options.optionalValue);\n\n if (isOptional) {\n if (item.options.optionalInclude) {\n output[key] = value;\n }\n } else if (item.type === 'container') {\n const tmp = await item.data.run(\n isObject(value) ? value : {},\n {\n group: options.group,\n flat: true,\n path: pathAbsolute,\n pathsToInclude: filter.pathsToInclude,\n pathsToExclude: filter.pathsToExclude,\n defaults: resolveDefaults(options.defaults, key),\n context: options.context,\n signal: options.signal,\n },\n );\n\n const tmpKeys = Object.keys(tmp);\n for (const tmpKey of tmpKeys) {\n output[this.mergePaths(key, tmpKey)] = tmp[tmpKey];\n }\n } else if (item.type === 'validator') {\n output[key] = await item.data({\n key,\n path: pathAbsolute,\n\n value,\n data,\n group: options.group,\n context: options.context as C,\n signal: options.signal,\n });\n }\n } catch (e) {\n this.recordMountError(e, item, keyParts, pathRelative, issues, options.signal);\n pathFailed = true;\n }\n\n pathCount++;\n }\n\n if (pathCount > 0) {\n itemCount++;\n\n if (pathFailed) {\n errorCount++;\n }\n }\n }\n\n return this.finalizeOutput(output, options, issues, errorCount, itemCount);\n }\n\n /**\n * Parallel-execution variant of `run()`. All mounts kick off their\n * promises eagerly and the results are merged after `Promise.allSettled`.\n * See `ContainerRunOptions.parallel` for the trade-off note.\n */\n private async runParallel(\n data: Record<string, any>,\n options: ContainerRunOptions<T, C>,\n ): Promise<T> {\n const { pathsToInclude, pathsToExclude } = this.resolveContainerFilters(options);\n\n const output: Record<string, any> = {};\n const issues: Issue[] = [];\n\n type KeyTask = {\n key: string,\n keyParts: PropertyKey[],\n pathRelative: PropertyKey | undefined,\n promise: Promise<unknown>,\n kind: 'container' | 'validator',\n };\n\n type ItemGroup = {\n item: Mount<C>,\n tasks: KeyTask[],\n // optional/skip paths that completed inline still count toward\n // the per-item pathCount used for oneOf / errorCount tracking.\n syncPathCount: number,\n };\n\n const itemGroups: ItemGroup[] = [];\n\n for (let i = 0; i < this.items.length; i++) {\n options.signal?.throwIfAborted();\n\n const item = this.items[i];\n if (!this.isItemGroupIncluded(item, options.group)) {\n continue;\n }\n\n const tasks: KeyTask[] = [];\n let syncPathCount = 0;\n\n const keys: string[] = item.path ? expandPath(data, item.path) : [''];\n for (const key of keys) {\n const keyParts = key ? pathToArray(key) : [];\n const pathRelative = keyParts.at(-1);\n const pathAbsolute = [\n ...(options.path ? options.path : []),\n ...keyParts,\n ];\n\n let value: unknown;\n if (key.length > 0) {\n // Parallel mode reads `data` only — `output[key]` from a\n // sibling mount is intentionally NOT consulted (the\n // sibling may not have completed yet).\n value = getPathValue(data, key);\n } else {\n value = data;\n }\n\n const filter = resolvePathFilter(\n pathsToInclude,\n pathsToExclude,\n key,\n item.type === 'container',\n );\n if (filter.skip) {\n continue;\n }\n\n const isOptional = typeof item.options.optional === 'function' ?\n item.options.optional(value) :\n item.options.optional &&\n isOptionalValue(value, item.options.optionalValue);\n\n if (isOptional) {\n if (item.options.optionalInclude) {\n output[key] = value;\n }\n syncPathCount++;\n continue;\n }\n\n let promise: Promise<unknown>;\n if (item.type === 'container') {\n promise = item.data.run(\n isObject(value) ? value : {},\n {\n group: options.group,\n flat: true,\n path: pathAbsolute,\n pathsToInclude: filter.pathsToInclude,\n pathsToExclude: filter.pathsToExclude,\n defaults: resolveDefaults(options.defaults, key),\n context: options.context,\n signal: options.signal,\n parallel: true,\n },\n );\n } else {\n // Wrap sync validators in a microtask so the surrounding\n // `Promise.allSettled` always sees a thenable.\n const itemData = item.data;\n promise = (async () => itemData({\n key,\n path: pathAbsolute,\n value,\n data,\n group: options.group,\n context: options.context as C,\n signal: options.signal,\n }))();\n }\n\n tasks.push({\n key,\n keyParts,\n pathRelative,\n promise,\n kind: item.type,\n });\n }\n\n if (tasks.length > 0 || syncPathCount > 0) {\n itemGroups.push({\n item, \n tasks, \n syncPathCount, \n });\n }\n }\n\n // Wait for all groups concurrently. Promises were already kicked off\n // eagerly above; this just collects their settled state.\n const settledByGroup = await Promise.all(itemGroups.map(\n (group) => Promise.allSettled(group.tasks.map((t) => t.promise)),\n ));\n\n // Re-check the abort signal after settling. Sequential `run`/`runSync`\n // probe between every mount; the parallel variant can only check here\n // and before `finalizeOutput`. Without this, validators that ignore\n // `ctx.signal` would let an aborted run resolve to a successful result.\n options.signal?.throwIfAborted();\n\n let itemCount = 0;\n let errorCount = 0;\n\n for (const [i, {\n item, \n tasks, \n syncPathCount, \n }] of itemGroups.entries()) {\n const settled = settledByGroup[i];\n\n let pathFailed = false;\n for (const [j, task] of tasks.entries()) {\n const result = settled[j];\n\n if (result.status === 'fulfilled') {\n if (task.kind === 'container') {\n const tmp = result.value as Record<string, any>;\n const tmpKeys = Object.keys(tmp);\n for (const tmpKey of tmpKeys) {\n output[this.mergePaths(task.key, tmpKey)] = tmp[tmpKey];\n }\n } else {\n output[task.key] = result.value;\n }\n } else {\n this.recordMountError(\n result.reason,\n item,\n task.keyParts,\n task.pathRelative,\n issues,\n options.signal,\n );\n pathFailed = true;\n }\n }\n\n if (tasks.length + syncPathCount > 0) {\n itemCount++;\n if (pathFailed) {\n errorCount++;\n }\n }\n }\n\n // Final guard before returning a (potentially successful) value — if\n // the run was aborted after the post-settle check but before the merge\n // loop finished, propagate the abort instead of returning stale data.\n options.signal?.throwIfAborted();\n\n return this.finalizeOutput(output, options, issues, errorCount, itemCount);\n }\n\n async safeRun(input: Record<string, any> = {}, options: ContainerRunOptions<T, C> = {}): Promise<Result<T>> {\n try {\n const data = await this.run(input, options);\n return { success: true, data };\n } catch (e) {\n return this.wrapSafeRunError(e, options);\n }\n }\n\n /**\n * @throws ValidupError\n *\n * Synchronous variant of `run()`. Throws synchronously if any validator\n * returns a thenable, or if a nested container does not implement\n * `runSync`. Use it for purely synchronous validator graphs where the\n * microtask overhead of `await` per mount matters (e.g. driving a\n * reactive UI without a `pending` flicker).\n */\n runSync(\n data: Record<string, any> = {},\n options: ContainerRunOptions<T, C> = {},\n ): T {\n const { pathsToInclude, pathsToExclude } = this.resolveContainerFilters(options);\n\n const output: Record<string, any> = {};\n const issues: Issue[] = [];\n\n let itemCount = 0;\n let errorCount = 0;\n\n for (let i = 0; i < this.items.length; i++) {\n options.signal?.throwIfAborted();\n\n const item = this.items[i];\n\n if (!this.isItemGroupIncluded(item, options.group)) {\n continue;\n }\n\n let pathCount = 0;\n let pathFailed = false;\n\n const keys: string[] = item.path ? expandPath(data, item.path) : [''];\n\n for (const key of keys) {\n const keyParts = key ? pathToArray(key) : [];\n\n const pathRelative = keyParts.at(-1);\n const pathAbsolute = [\n ...(options.path ? options.path : []),\n ...keyParts,\n ];\n\n let value: unknown;\n if (key.length > 0) {\n value = hasOwnProperty(output, key) ?\n output[key] :\n getPathValue(data, key);\n } else {\n value = data;\n }\n\n const filter = resolvePathFilter(\n pathsToInclude,\n pathsToExclude,\n key,\n item.type === 'container',\n );\n if (filter.skip) {\n continue;\n }\n\n try {\n const isOptional = typeof item.options.optional === 'function' ?\n item.options.optional(value) :\n item.options.optional &&\n isOptionalValue(value, item.options.optionalValue);\n\n if (isOptional) {\n if (item.options.optionalInclude) {\n output[key] = value;\n }\n } else if (item.type === 'container') {\n const childRunSync = (\n item.data as IContainer<any, any> & {\n runSync?: (...args: any[]) => any\n }\n ).runSync;\n if (typeof childRunSync !== 'function') {\n throw new RunSyncViolationError(`runSync: nested container at \"${key || '<root>'}\" does not implement runSync`);\n }\n\n const tmp = childRunSync.call(item.data, isObject(value) ? value : {}, {\n group: options.group,\n flat: true,\n path: pathAbsolute,\n pathsToInclude: filter.pathsToInclude,\n pathsToExclude: filter.pathsToExclude,\n defaults: resolveDefaults(options.defaults, key),\n context: options.context,\n signal: options.signal,\n });\n\n const tmpKeys = Object.keys(tmp);\n for (const tmpKey of tmpKeys) {\n output[this.mergePaths(key, tmpKey)] = tmp[tmpKey];\n }\n } else if (item.type === 'validator') {\n const result = item.data({\n key,\n path: pathAbsolute,\n\n value,\n data,\n group: options.group,\n context: options.context as C,\n signal: options.signal,\n });\n if (\n result !== null &&\n typeof result === 'object' &&\n typeof (result as { then?: unknown }).then === 'function'\n ) {\n throw new RunSyncViolationError(`runSync: validator at \"${key || '<root>'}\" returned a Promise`);\n }\n output[key] = result;\n }\n } catch (e) {\n this.recordMountError(e, item, keyParts, pathRelative, issues, options.signal);\n pathFailed = true;\n }\n\n pathCount++;\n }\n\n if (pathCount > 0) {\n itemCount++;\n\n if (pathFailed) {\n errorCount++;\n }\n }\n }\n\n return this.finalizeOutput(output, options, issues, errorCount, itemCount);\n }\n\n safeRunSync(input: Record<string, any> = {}, options: ContainerRunOptions<T, C> = {}): Result<T> {\n try {\n const data = this.runSync(input, options);\n return { success: true, data };\n } catch (e) {\n return this.wrapSafeRunError(e, options);\n }\n }\n\n private resolveContainerFilters(options: ContainerRunOptions<T, C>): {\n pathsToInclude: string[] | undefined,\n pathsToExclude: string[] | undefined,\n } {\n let pathsToInclude: string[] | undefined;\n if (options.pathsToInclude) {\n pathsToInclude = options.pathsToInclude as string[];\n } else if (this.options.pathsToInclude) {\n pathsToInclude = this.options.pathsToInclude as string[];\n }\n\n let pathsToExclude: string[] | undefined;\n if (options.pathsToExclude) {\n pathsToExclude = options.pathsToExclude as string[];\n } else if (this.options.pathsToExclude) {\n pathsToExclude = this.options.pathsToExclude as string[];\n }\n\n return { pathsToInclude, pathsToExclude };\n }\n\n /**\n * Prepend `keyParts` to a child issue's `path` and — when the child is\n * an `IssueGroup` — recurse into its nested issues so every leaf carries\n * the parent prefix. Without recursion, a child container that already\n * wrapped its own multi-issue mount in a group (or a `oneOf` child) would\n * surface inner items with paths missing the parent segment, breaking\n * downstream consumers that rely on `flattenIssueItems` for per-field\n * lookup (e.g. `@validup/vue`).\n */\n private prefixIssuePath(issue: Issue, keyParts: PropertyKey[]): Issue {\n const prefixed: Issue = {\n ...issue,\n path: [...keyParts, ...(issue.path || [])],\n };\n if (prefixed.type === 'group') {\n prefixed.issues = prefixed.issues.map(\n (nested) => this.prefixIssuePath(nested, keyParts),\n );\n }\n return prefixed;\n }\n\n /**\n * Translate a per-mount throw into accumulated `issues`. Re-throws when\n * the run was aborted (signal-aware validators) so abort errors are not\n * mangled into validation issues. `keyParts` is the current mount's\n * expanded path (used to prepend to nested `ValidupError` issues).\n */\n private recordMountError(\n e: unknown,\n item: Mount<C>,\n keyParts: PropertyKey[],\n pathRelative: PropertyKey | undefined,\n issues: Issue[],\n signal: AbortSignal | undefined,\n ): void {\n if (signal?.aborted) {\n throw e;\n }\n // Structural runSync violations are not validation outcomes — they\n // mean the caller can't use runSync against this graph. Surface the\n // diagnostic verbatim instead of wrapping it as \"Property X is invalid\".\n if (isRunSyncViolation(e)) {\n throw e;\n }\n\n const childIssues: Issue[] = [];\n\n if (isValidupError(e)) {\n for (let i = 0; i < e.issues.length; i++) {\n childIssues.push(this.prefixIssuePath(e.issues[i], keyParts));\n }\n } else if (isError(e)) {\n childIssues.push(defineIssueItem({\n path: keyParts,\n message: e.message,\n }));\n }\n\n if (pathRelative) {\n if (item.type === 'container' || childIssues.length > 1) {\n issues.push(defineIssueGroup({\n message: buildErrorMessageForAttribute(String(pathRelative)),\n params: { name: String(pathRelative) },\n path: keyParts,\n issues: childIssues,\n }));\n } else {\n issues.push(...childIssues);\n }\n } else {\n issues.push(...childIssues);\n }\n }\n\n /**\n * Apply post-loop semantics: oneOf aggregation, error throw, defaults\n * fill, and flat-vs-nested output expansion.\n */\n private finalizeOutput(\n output: Record<string, any>,\n options: ContainerRunOptions<T, C>,\n issues: Issue[],\n errorCount: number,\n itemCount: number,\n ): T {\n if (this.options.oneOf) {\n // Guard against the \"all branches filtered out\" case (group /\n // pathsToInclude / pathsToExclude can leave itemCount === 0).\n // Without it, a oneOf container with nothing to run would throw\n // ONE_OF_FAILED with an empty issues list.\n if (itemCount > 0 && errorCount === itemCount) {\n const group = defineIssueGroup({\n code: IssueCode.ONE_OF_FAILED,\n message: 'None of the branches succeeded',\n issues,\n path: options.path ? options.path : [],\n });\n throw new ValidupError([group]);\n }\n } else if (errorCount > 0) {\n throw new ValidupError(issues);\n }\n\n if (options.defaults) {\n const defaultKeys = Object.keys(options.defaults);\n for (const defaultKey of defaultKeys) {\n if (\n !hasOwnProperty(output, defaultKey) ||\n typeof output[defaultKey] === 'undefined'\n ) {\n output[defaultKey] = (options.defaults as Record<string, any>)[defaultKey];\n }\n }\n }\n\n if (options.flat) {\n return output as T;\n }\n\n const temp: Record<string, any> = {};\n const keys = Object.keys(output);\n for (const key of keys) {\n setPathValue(temp, key, output[key]);\n }\n return temp as T;\n }\n\n private wrapSafeRunError(e: unknown, options: ContainerRunOptions<T, C>): Result<T> {\n // Abort is not a validation outcome — propagate it. Wrapping it\n // as a synthetic `Result.failure` would produce a misleading\n // \"AbortError\" issue at path `[]`.\n if (options.signal?.aborted) {\n throw e;\n }\n // Same reasoning for `runSync` structural violations.\n if (isRunSyncViolation(e)) {\n throw e;\n }\n\n if (isValidupError(e)) {\n return { success: false, error: e };\n }\n\n if (isError(e)) {\n return {\n success: false,\n error: new ValidupError([\n defineIssueItem({\n path: [],\n message: e.message,\n }),\n ]),\n };\n }\n\n return { success: false, error: new ValidupError() };\n }\n\n private isItemGroupIncluded(\n item: Mount<C>,\n group?: string,\n ) : boolean {\n if (group === GroupKey.WILDCARD) {\n return true;\n }\n\n if (item.options.group) {\n if (Array.isArray(item.options.group)) {\n if (item.options.group.includes(GroupKey.WILDCARD)) {\n return true;\n }\n\n if (group && item.options.group.includes(group)) {\n return true;\n }\n } else {\n if (item.options.group === GroupKey.WILDCARD) {\n return true;\n }\n\n if (item.options.group === group) {\n return true;\n }\n }\n\n return false;\n }\n\n return true;\n }\n\n /**\n * Join flat-output keys with `.` separators, preserving any pre-existing\n * leading dot on the right-hand side. Note: keys containing a *literal*\n * dot collide with the dotted-path syntax used for nested-output\n * expansion (see `setPathValue` in `pathtrace`) and will produce\n * ambiguous output when re-expanded — avoid mounting/returning such keys.\n */\n private mergePaths(...args: (string | undefined)[]) {\n let output : string = '';\n\n for (const arg of args) {\n if (!arg || arg.length === 0) {\n continue;\n }\n\n if (arg.at(0) === '.') {\n output += arg;\n } else {\n output += output.length > 0 ? `.${arg}` : arg;\n }\n }\n\n return output;\n }\n\n protected initialize() : void {\n\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { Container, isContainer } from '../container';\nimport type {\n ContainerOptions,\n IContainer,\n MountOptions,\n} from '../container/types';\nimport type { Validator } from '../types';\nimport type { IBuilder, MountTarget } from './types';\n\ntype ValidatorStep<C> = {\n kind: 'validator',\n key: string,\n validator: Validator<C>,\n options: MountOptions,\n};\n\ntype NestStep<C> = {\n kind: 'nest',\n key: string,\n child: IContainer<any, C>,\n options: MountOptions,\n};\n\ntype Step<C> = ValidatorStep<C> | NestStep<C>;\n\nfunction isBuilder(value: unknown): value is IBuilder<Record<string, any>, unknown> {\n return typeof value === 'object' &&\n value !== null &&\n typeof (value as { build?: unknown }).build === 'function' &&\n typeof (value as { mount?: unknown }).mount === 'function';\n}\n\nexport class Builder<T extends Record<string, any>, C> implements IBuilder<T, C> {\n private readonly options: ContainerOptions<any>;\n\n private readonly steps: ReadonlyArray<Step<C>>;\n\n constructor(options: ContainerOptions<any>, steps: ReadonlyArray<Step<C>>) {\n this.options = options;\n this.steps = steps;\n }\n\n mount(key: string, ...rest: unknown[]): IBuilder<any, C> {\n let options: MountOptions = {};\n let target: MountTarget<C>;\n\n if (rest.length === 1) {\n target = rest[0] as MountTarget<C>;\n } else {\n options = rest[0] as MountOptions;\n target = rest[1] as MountTarget<C>;\n }\n\n let step: Step<C>;\n if (isBuilder(target)) {\n step = {\n kind: 'nest',\n key,\n child: (target as IBuilder<any, C>).build(),\n options,\n };\n } else if (isContainer(target)) {\n step = {\n kind: 'nest',\n key,\n child: target as IContainer<any, C>,\n options,\n };\n } else {\n step = {\n kind: 'validator',\n key,\n validator: target as Validator<C>,\n options,\n };\n }\n\n return new Builder<any, C>(this.options, [...this.steps, step]);\n }\n\n oneOf(): IBuilder<T, C> {\n return new Builder<T, C>(\n { ...this.options, oneOf: true },\n this.steps,\n );\n }\n\n pathsToInclude(...paths: (keyof T & string)[]): IBuilder<T, C> {\n return new Builder<T, C>(\n {\n ...this.options,\n pathsToInclude: [\n ...((this.options.pathsToInclude as string[]) ?? []),\n ...paths,\n ] as ContainerOptions<any>['pathsToInclude'],\n },\n this.steps,\n );\n }\n\n pathsToExclude(...paths: (keyof T & string)[]): IBuilder<T, C> {\n return new Builder<T, C>(\n {\n ...this.options,\n pathsToExclude: [\n ...((this.options.pathsToExclude as string[]) ?? []),\n ...paths,\n ] as ContainerOptions<any>['pathsToExclude'],\n },\n this.steps,\n );\n }\n\n build(): Container<T, C> {\n const container = new Container<T, C>(this.options as ContainerOptions<T>);\n for (const step of this.steps) {\n if (step.kind === 'nest') {\n container.mount(step.key, step.options, step.child);\n } else {\n container.mount(step.key, step.options, step.validator);\n }\n }\n return container;\n }\n}\n\n/**\n * Entry point for the compile-time-typed schema builder. The accumulator\n * starts at `{}` and grows as `.mount(...)` calls are chained;\n * `.build()` returns a `Container<T, C>` whose `run()` reflects the\n * accumulated shape.\n *\n * Pass the context type as the generic parameter to flow it through nested\n * builders and validator factories: `defineSchema<MyContext>()`.\n */\nexport function defineSchema<C = unknown>(): IBuilder<{}, C> {\n return new Builder<{}, C>({}, []);\n}\n"],"mappings":";;;;;;;;;;;;AAeA,SAAgB,gBACZ,UACA,KAC+B;CAC/B,IAAI,OAAO,aAAa,aACpB;CAEJ,IAAI,IAAI,WAAW,GACf,OAAO;CAGX,MAAM,SAA8B,CAAC;CACrC,IAAI,UAAU;CACd,MAAM,OAAO,OAAO,KAAK,QAAQ;CACjC,KAAK,MAAM,KAAK,MACZ,IAAI,EAAE,WAAW,GAAG,IAAI,EAAE,GAAG;EACzB,OAAO,EAAE,MAAM,IAAI,SAAS,CAAC,KAAK,SAAS;EAC3C,UAAU;CACd;CAEJ,OAAO,UAAU,SAAS,KAAA;AAC9B;;;AC3BA,SAAgB,8BAA8B,KAAkB;CAC5D,OAAO,YAAY,OAAO,GAAG,EAAE;AACnC;AAEA,SAAgB,+BAA+B,OAA4C;CACvF,IAAI;CACJ,IAAI,MAAM,QAAQ,KAAK,GACnB,QAAQ,cAAc,KAAK;MAE3B,QAAQ,OAAO,KAAK,KAAK;CAG7B,IAAI,MAAM,WAAW,GACjB,OAAO;CAGX,IAAI,MAAM,SAAS,GACf,OAAO,cAAc,MAAM,KAAK,IAAI,EAAE;CAG1C,OAAO,8BAA8B,MAAM,EAAE;AACjD;;;ACvBA,IAAY,WAAL,yBAAA,UAAA;CACH,SAAA,cAAA;;AACJ,EAAA,CAAA,CAAA;AAEA,IAAY,gBAAL,yBAAA,eAAA;;;;CAIH,cAAA,eAAA;;;;CAIA,cAAA,UAAA;;;;CAIA,cAAA,WAAA;;AACJ,EAAA,CAAA,CAAA;;;;;;;;;ACTA,SAAgB,gBACZ,OACA,eACF;CACE,MAAM,wBAAwB,iBAAA;CAE9B,IAAI,0BAAA,QACA,OAAO,UAAU,QAAQ,OAAO,UAAU;CAG9C,IAAI,0BAAA,aACA,OAAO,OA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KAAK,SAAS;EAG9D,OAAO;CACX;AACJ;;;;;;;;;;AAWA,SAAgB,eAA6C;CACzD,OAAO,IAAI,QAAe,CAAC,GAAG,CAAC,CAAC;AACpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "validup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "A validation library.",
|
|
5
6
|
"author": {
|
|
6
7
|
"name": "Peter Placzek",
|
|
@@ -11,37 +12,34 @@
|
|
|
11
12
|
"type": "git",
|
|
12
13
|
"url": "https://github.com/tada5hi/validup.git"
|
|
13
14
|
},
|
|
14
|
-
"main": "dist/index.
|
|
15
|
-
"
|
|
16
|
-
"types": "dist/index.d.ts",
|
|
15
|
+
"main": "dist/index.mjs",
|
|
16
|
+
"types": "dist/index.d.mts",
|
|
17
17
|
"exports": {
|
|
18
18
|
"./package.json": "./package.json",
|
|
19
19
|
".": {
|
|
20
|
-
"types": "./dist/index.d.
|
|
21
|
-
"import": "./dist/index.mjs"
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
"./bin/*": "./bin/*"
|
|
20
|
+
"types": "./dist/index.d.mts",
|
|
21
|
+
"import": "./dist/index.mjs"
|
|
22
|
+
}
|
|
25
23
|
},
|
|
26
24
|
"files": [
|
|
27
|
-
"bin",
|
|
28
25
|
"dist"
|
|
29
26
|
],
|
|
30
27
|
"engines": {
|
|
31
|
-
"node": ">=
|
|
28
|
+
"node": ">=22.0.0"
|
|
32
29
|
},
|
|
33
30
|
"scripts": {
|
|
34
|
-
"build:types": "tsc --
|
|
35
|
-
"build:js": "
|
|
36
|
-
"build": "
|
|
37
|
-
"test": "
|
|
38
|
-
"test:coverage": "
|
|
31
|
+
"build:types": "tsc --noEmit",
|
|
32
|
+
"build:js": "tsdown",
|
|
33
|
+
"build": "npm run build:types && npm run build:js",
|
|
34
|
+
"test": "vitest --config test/vitest.config.ts --run",
|
|
35
|
+
"test:coverage": "vitest --config test/vitest.config.ts --run --coverage"
|
|
39
36
|
},
|
|
40
37
|
"keywords": [],
|
|
41
|
-
"license": "
|
|
38
|
+
"license": "Apache-2.0",
|
|
42
39
|
"dependencies": {
|
|
40
|
+
"@ebec/core": "^1.1.0",
|
|
43
41
|
"pathtrace": "^2.1.2",
|
|
44
|
-
"smob": "^1.
|
|
42
|
+
"smob": "^1.6.2"
|
|
45
43
|
},
|
|
46
44
|
"publishConfig": {
|
|
47
45
|
"access": "public"
|
package/dist/constants.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare enum GroupKey {
|
|
2
|
-
WILDCARD = "*"
|
|
3
|
-
}
|
|
4
|
-
export declare enum OptionalValue {
|
|
5
|
-
/**
|
|
6
|
-
* value: undefined
|
|
7
|
-
*/
|
|
8
|
-
UNDEFINED = "undefined",
|
|
9
|
-
/**
|
|
10
|
-
* value: null & undefined
|
|
11
|
-
*/
|
|
12
|
-
NULL = "null",
|
|
13
|
-
/**
|
|
14
|
-
* value: empty string, false, 0
|
|
15
|
-
*/
|
|
16
|
-
FALSY = "falsy"
|
|
17
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Path } from 'pathtrace';
|
|
2
|
-
import type { Validator } from '../types';
|
|
3
|
-
import type { ContainerOptions, ContainerRunOptions, IContainer, Mount, MountOptions } from './types';
|
|
4
|
-
export declare class Container<T extends Record<string, any> = Record<string, any>> implements IContainer {
|
|
5
|
-
protected options: ContainerOptions<T>;
|
|
6
|
-
protected items: Mount[];
|
|
7
|
-
constructor(options?: ContainerOptions<T>);
|
|
8
|
-
mount(container: IContainer): void;
|
|
9
|
-
mount(options: MountOptions, container: IContainer): void;
|
|
10
|
-
mount(key: Path<T> | (string & {}), data: IContainer | Validator): void;
|
|
11
|
-
mount(key: Path<T> | (string & {}), options: MountOptions, data: IContainer | Validator): void;
|
|
12
|
-
/**
|
|
13
|
-
* @throws ValidupError
|
|
14
|
-
* @param data
|
|
15
|
-
* @param options
|
|
16
|
-
*/
|
|
17
|
-
run(data?: Record<string, any>, options?: ContainerRunOptions<T>): Promise<T>;
|
|
18
|
-
private isItemGroupIncluded;
|
|
19
|
-
private mergePaths;
|
|
20
|
-
protected initialize(): void;
|
|
21
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { Path } from 'pathtrace';
|
|
2
|
-
import type { OptionalValue } from '../constants';
|
|
3
|
-
import type { ObjectLiteral, Validator } from '../types';
|
|
4
|
-
export type ContainerOptions<T> = {
|
|
5
|
-
/**
|
|
6
|
-
* Only one of the mounted container/validators must succeed.
|
|
7
|
-
*/
|
|
8
|
-
oneOf?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Limit mounted paths on execution.
|
|
11
|
-
* By default, all mounted containers/validators will
|
|
12
|
-
* be considered for execution.
|
|
13
|
-
*/
|
|
14
|
-
pathsToInclude?: Path<T>[];
|
|
15
|
-
/**
|
|
16
|
-
* Exclude mounted paths on execution.
|
|
17
|
-
* By default, all mounted containers/validators will
|
|
18
|
-
* be considered for execution.
|
|
19
|
-
*/
|
|
20
|
-
pathsToExclude?: Path<T>[];
|
|
21
|
-
};
|
|
22
|
-
export type ContainerRunOptions<T extends Record<string, any> = Record<string, any>> = {
|
|
23
|
-
/**
|
|
24
|
-
* Default values for the container output.
|
|
25
|
-
*/
|
|
26
|
-
defaults?: {
|
|
27
|
-
[Key in Path<T>]: any;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Group to execute.
|
|
31
|
-
*/
|
|
32
|
-
group?: string;
|
|
33
|
-
/**
|
|
34
|
-
* Output flat object?
|
|
35
|
-
*/
|
|
36
|
-
flat?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Passed path from the parent container.
|
|
39
|
-
*/
|
|
40
|
-
path?: PropertyKey[];
|
|
41
|
-
/**
|
|
42
|
-
* Limit mounted paths on execution.
|
|
43
|
-
* By default, all mounted containers/validators will
|
|
44
|
-
* be considered for execution.
|
|
45
|
-
*/
|
|
46
|
-
pathsToInclude?: Path<T>[];
|
|
47
|
-
/**
|
|
48
|
-
* Exclude mounted paths on execution.
|
|
49
|
-
* By default, all mounted containers/validators will
|
|
50
|
-
* be considered for execution.
|
|
51
|
-
*/
|
|
52
|
-
pathsToExclude?: Path<T>[];
|
|
53
|
-
};
|
|
54
|
-
export type MountOptions = {
|
|
55
|
-
/**
|
|
56
|
-
* Group(s) to execute.
|
|
57
|
-
*/
|
|
58
|
-
group?: string | string[];
|
|
59
|
-
/**
|
|
60
|
-
* Specify if an optional value is also acceptable for the mount key.
|
|
61
|
-
* An optional value won't be passed to the underlying container/validator.
|
|
62
|
-
*
|
|
63
|
-
* default: false
|
|
64
|
-
*/
|
|
65
|
-
optional?: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Which values are considered optional.
|
|
68
|
-
* An optional value won't be passed to the underlying container/validator.
|
|
69
|
-
*
|
|
70
|
-
* default: 'undefined'
|
|
71
|
-
*/
|
|
72
|
-
optionalValue?: `${OptionalValue}`;
|
|
73
|
-
/**
|
|
74
|
-
* Include optional value as property in output.
|
|
75
|
-
*
|
|
76
|
-
* default: false
|
|
77
|
-
*/
|
|
78
|
-
optionalInclude?: boolean;
|
|
79
|
-
};
|
|
80
|
-
export interface IContainer<T extends ObjectLiteral = ObjectLiteral> {
|
|
81
|
-
/**
|
|
82
|
-
* Execute container with given input.
|
|
83
|
-
*
|
|
84
|
-
* @param data
|
|
85
|
-
* @param options
|
|
86
|
-
*/
|
|
87
|
-
run(data?: Record<string, any>, options?: ContainerRunOptions<T>): Promise<T>;
|
|
88
|
-
}
|
|
89
|
-
export type BaseMount = {
|
|
90
|
-
options: MountOptions;
|
|
91
|
-
path?: string;
|
|
92
|
-
};
|
|
93
|
-
export type ContainerMount = BaseMount & {
|
|
94
|
-
type: 'container';
|
|
95
|
-
data: IContainer;
|
|
96
|
-
};
|
|
97
|
-
export type ValidatorMount = BaseMount & {
|
|
98
|
-
type: 'validator';
|
|
99
|
-
data: Validator;
|
|
100
|
-
};
|
|
101
|
-
export type Mount = ContainerMount | ValidatorMount;
|
package/dist/error/base.d.ts
DELETED
package/dist/error/check.d.ts
DELETED
package/dist/error/index.d.ts
DELETED
package/dist/helpers/error.d.ts
DELETED
package/dist/helpers/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { OptionalValue } from '../constants';
|
|
2
|
-
/**
|
|
3
|
-
* Check if input value (type of) satisfies optional value type constraint.
|
|
4
|
-
*
|
|
5
|
-
* @param value
|
|
6
|
-
* @param optionalValue
|
|
7
|
-
*/
|
|
8
|
-
export declare function isOptionalValue(value: unknown, optionalValue?: `${OptionalValue}`): boolean;
|