validup 0.2.0 → 0.2.2

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.
@@ -1,6 +1,6 @@
1
1
  import type { Path } from 'pathtrace';
2
2
  import type { Validator } from '../types';
3
- import type { ContainerOptions, ContainerRunOptions, IContainer, Mount, MountOptions } from './types';
3
+ import type { ContainerOptions, ContainerRunOptions, IContainer, Mount, MountOptions, Result } from './types';
4
4
  export declare class Container<T extends Record<string, any> = Record<string, any>> implements IContainer {
5
5
  protected options: ContainerOptions<T>;
6
6
  protected items: Mount[];
@@ -11,10 +11,12 @@ export declare class Container<T extends Record<string, any> = Record<string, an
11
11
  mount(key: Path<T> | (string & {}), options: MountOptions, data: IContainer | Validator): void;
12
12
  /**
13
13
  * @throws ValidupError
14
+ *
14
15
  * @param data
15
16
  * @param options
16
17
  */
17
18
  run(data?: Record<string, any>, options?: ContainerRunOptions<T>): Promise<T>;
19
+ safeRun(input?: Record<string, any>, options?: ContainerRunOptions<T>): Promise<Result<T>>;
18
20
  private isItemGroupIncluded;
19
21
  private mergePaths;
20
22
  protected initialize(): void;
@@ -1,5 +1,6 @@
1
1
  import type { Path } from 'pathtrace';
2
2
  import type { OptionalValue } from '../constants';
3
+ import type { ValidupError } from '../error';
3
4
  import type { ObjectLiteral, Validator } from '../types';
4
5
  export type ContainerOptions<T> = {
5
6
  /**
@@ -77,14 +78,32 @@ export type MountOptions = {
77
78
  */
78
79
  optionalInclude?: boolean;
79
80
  };
81
+ export type ResultSuccess<T> = {
82
+ success: true;
83
+ data: T;
84
+ error?: never;
85
+ };
86
+ export type ResultFailure = {
87
+ success: false;
88
+ data?: never;
89
+ error: ValidupError;
90
+ };
91
+ export type Result<T extends ObjectLiteral = ObjectLiteral> = ResultSuccess<T> | ResultFailure;
80
92
  export interface IContainer<T extends ObjectLiteral = ObjectLiteral> {
81
93
  /**
82
- * Execute container with given input.
94
+ * Run container with given input.
95
+ *
96
+ * @param input
97
+ * @param options
98
+ */
99
+ run(input?: Record<string, any>, options?: ContainerRunOptions<T>): Promise<T>;
100
+ /**
101
+ * Safe run container with given input.
83
102
  *
84
- * @param data
103
+ * @param input
85
104
  * @param options
86
105
  */
87
- run(data?: Record<string, any>, options?: ContainerRunOptions<T>): Promise<T>;
106
+ safeRun(input?: Record<string, any>, options?: ContainerRunOptions<T>): Promise<Result<T>>;
88
107
  }
89
108
  export type BaseMount = {
90
109
  options: MountOptions;
@@ -0,0 +1,5 @@
1
+ import { ValidupError } from './base';
2
+ export declare function isError(input: unknown): input is Error & {
3
+ [key: string]: any;
4
+ };
5
+ export declare function isValidupError(error: unknown): error is ValidupError;
@@ -0,0 +1,2 @@
1
+ export * from './base';
2
+ export * from './check';
@@ -1,2 +1,3 @@
1
1
  export * from './error';
2
2
  export * from './optional-value';
3
+ export * from './path-stringify';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Stringify path array to string.
3
+ *
4
+ * @param input
5
+ */
6
+ export declare function stringifyPath(input: PropertyKey[]): string;
package/dist/index.cjs CHANGED
@@ -60,21 +60,79 @@ var OptionalValue = /*#__PURE__*/ function(OptionalValue) {
60
60
  return !value;
61
61
  }
62
62
 
63
+ /**
64
+ * Stringify path array to string.
65
+ *
66
+ * @param input
67
+ */ function stringifyPath(input) {
68
+ return pathtrace.arrayToPath(input);
69
+ }
70
+
71
+ class ValidupError extends Error {
72
+ constructor(issues = []){
73
+ const paths = issues.map((issue)=>stringifyPath(issue.path));
74
+ super(buildErrorMessageForAttributes(paths));
75
+ this.issues = issues;
76
+ }
77
+ }
78
+
63
79
  /*
64
- * Copyright (c) 2024-2024.
80
+ * Copyright (c) 2024.
65
81
  * Author Peter Placzek (tada5hi)
66
82
  * For the full copyright and license information,
67
83
  * view the LICENSE file that was distributed with this source code.
68
- */ class ValidupError extends Error {
69
- constructor(issues = []){
70
- super(JSON.stringify(issues, (_, value)=>{
71
- if (typeof value === 'bigint') {
72
- return value.toString();
73
- }
74
- return value;
75
- }, 2));
76
- this.issues = issues;
84
+ */ // eslint-disable-next-line @typescript-eslint/ban-types
85
+ function hasOwnProperty(obj, prop) {
86
+ return Object.prototype.hasOwnProperty.call(obj, prop);
87
+ }
88
+
89
+ /*
90
+ * Copyright (c) 2024.
91
+ * Author Peter Placzek (tada5hi)
92
+ * For the full copyright and license information,
93
+ * view the LICENSE file that was distributed with this source code.
94
+ */ function isObject(input) {
95
+ return !!input && typeof input === 'object' && !Array.isArray(input);
96
+ }
97
+
98
+ function isIssuePath(input) {
99
+ if (!Array.isArray(input)) {
100
+ return false;
101
+ }
102
+ return input.every((el)=>typeof el === 'string' || typeof el === 'number' || typeof el === 'symbol');
103
+ }
104
+ function isBaseIssue(input) {
105
+ if (!isObject(input)) {
106
+ return false;
107
+ }
108
+ if (typeof input.message !== 'string') {
109
+ return false;
110
+ }
111
+ if (!isIssuePath(input.path)) {
112
+ return false;
113
+ }
114
+ return typeof input.meta === 'undefined' || isObject(input.meta);
115
+ }
116
+ function isIssueItem(input) {
117
+ if (!isBaseIssue(input)) {
118
+ return false;
119
+ }
120
+ if (input.type !== 'item') {
121
+ return false;
122
+ }
123
+ return typeof input.code === 'string';
124
+ }
125
+ function isIssueGroup(input) {
126
+ if (!isBaseIssue(input)) {
127
+ return false;
77
128
  }
129
+ if (input.type !== 'group') {
130
+ return false;
131
+ }
132
+ return Array.isArray(input.issues) && input.issues.every((issue)=>isIssueItem(issue) || isIssueGroup(issue));
133
+ }
134
+ function isIssue(input) {
135
+ return isIssueGroup(input) || isIssueItem(input);
78
136
  }
79
137
 
80
138
  /*
@@ -102,27 +160,27 @@ function defineIssueGroup(data) {
102
160
  };
103
161
  }
104
162
 
105
- /*
106
- * Copyright (c) 2024.
107
- * Author Peter Placzek (tada5hi)
108
- * For the full copyright and license information,
109
- * view the LICENSE file that was distributed with this source code.
110
- */ // eslint-disable-next-line @typescript-eslint/ban-types
111
- function hasOwnProperty(obj, prop) {
112
- return Object.prototype.hasOwnProperty.call(obj, prop);
163
+ function isError(input) {
164
+ if (!isObject(input)) {
165
+ return false;
166
+ }
167
+ return typeof input.message === 'string';
113
168
  }
114
-
115
- /*
116
- * Copyright (c) 2024.
117
- * Author Peter Placzek (tada5hi)
118
- * For the full copyright and license information,
119
- * view the LICENSE file that was distributed with this source code.
120
- */ function isObject(input) {
121
- return !!input && typeof input === 'object' && !Array.isArray(input);
169
+ function isValidupError(error) {
170
+ if (!isError(error)) {
171
+ return false;
172
+ }
173
+ if (error instanceof ValidupError) {
174
+ return true;
175
+ }
176
+ if (!hasOwnProperty(error, 'issues')) {
177
+ return false;
178
+ }
179
+ return Array.isArray(error.issues) && error.issues.every((issue)=>isIssue(issue));
122
180
  }
123
181
 
124
182
  function isContainer(input) {
125
- return isObject(input) && typeof input.run === 'function';
183
+ return isObject(input) && typeof input.run === 'function' && typeof input.safeRun === 'function';
126
184
  }
127
185
 
128
186
  class Container {
@@ -178,6 +236,7 @@ class Container {
178
236
  // ----------------------------------------------
179
237
  /**
180
238
  * @throws ValidupError
239
+ *
181
240
  * @param data
182
241
  * @param options
183
242
  */ async run(data = {}, options = {}) {
@@ -259,7 +318,7 @@ class Container {
259
318
  }
260
319
  } catch (e) {
261
320
  const childIssues = [];
262
- if (e instanceof ValidupError) {
321
+ if (isValidupError(e)) {
263
322
  for(let i = 0; i < e.issues.length; i++){
264
323
  const issue = e.issues[i];
265
324
  childIssues.push({
@@ -270,7 +329,7 @@ class Container {
270
329
  ]
271
330
  });
272
331
  }
273
- } else if (e instanceof Error) {
332
+ } else if (isError(e)) {
274
333
  childIssues.push(defineIssueItem({
275
334
  path: keyParts,
276
335
  message: e.message
@@ -334,6 +393,37 @@ class Container {
334
393
  }
335
394
  return temp;
336
395
  }
396
+ async safeRun(input = {}, options = {}) {
397
+ try {
398
+ const data = await this.run(input, options);
399
+ return {
400
+ success: true,
401
+ data
402
+ };
403
+ } catch (e) {
404
+ if (isValidupError(e)) {
405
+ return {
406
+ success: false,
407
+ error: e
408
+ };
409
+ }
410
+ if (isError(e)) {
411
+ return {
412
+ success: false,
413
+ error: new ValidupError([
414
+ defineIssueItem({
415
+ path: [],
416
+ message: e.message
417
+ })
418
+ ])
419
+ };
420
+ }
421
+ return {
422
+ success: false,
423
+ error: new ValidupError()
424
+ };
425
+ }
426
+ }
337
427
  isItemGroupIncluded(item, group) {
338
428
  if (group === GroupKey.WILDCARD) {
339
429
  return true;
@@ -393,6 +483,12 @@ exports.defineIssueGroup = defineIssueGroup;
393
483
  exports.defineIssueItem = defineIssueItem;
394
484
  exports.hasOwnProperty = hasOwnProperty;
395
485
  exports.isContainer = isContainer;
486
+ exports.isError = isError;
487
+ exports.isIssue = isIssue;
488
+ exports.isIssueGroup = isIssueGroup;
489
+ exports.isIssueItem = isIssueItem;
396
490
  exports.isObject = isObject;
397
491
  exports.isOptionalValue = isOptionalValue;
492
+ exports.isValidupError = isValidupError;
493
+ exports.stringifyPath = stringifyPath;
398
494
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/helpers/error.ts","../src/constants.ts","../src/helpers/optional-value.ts","../src/errors/base.ts","../src/issue/constants.ts","../src/issue/define.ts","../src/utils/has-own-property.ts","../src/utils/object.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) 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 type { Issue } from '../issue';\n\nexport class ValidupError extends Error {\n readonly issues: Issue[];\n\n constructor(issues: Issue[] = []) {\n super(JSON.stringify(\n issues,\n (_: string, value: any) => {\n if (typeof value === 'bigint') {\n return value.toString();\n }\n\n return value;\n },\n 2,\n ));\n\n this.issues = issues;\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\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) 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) 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 } from '../errors';\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 (e instanceof ValidupError) {\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 (e instanceof Error) {\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","ValidupError","Error","issues","JSON","stringify","_","toString","IssueCode","defineIssueItem","data","type","code","VALUE_INVALID","defineIssueGroup","hasOwnProperty","obj","prop","prototype","call","isObject","isContainer","run","Container","mount","args","SyntaxError","path","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","issue","message","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,kBAA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wC,KAAK,GAAGA,GAAAA;AAC9C,YAAA;AACJ,QAAA;QAEA,OAAOK,MAAAA;AACX,IAAA;AAEUmC,IAAAA,UAAAA,GAAoB,CAE9B;;IA1WA,WAAA,CAAY1C,OAAAA,GAA+B,EAAE,CAAE;QAC3C,IAAI,CAACA,OAAO,GAAGA,OAAAA;QACf,IAAI,CAACG,KAAK,GAAG,EAAE;AAEf,QAAA,IAAI,CAACuC,UAAU,EAAA;AACnB,IAAA;AAsWJ;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","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 typeof input.safeRun === '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, Result,\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 *\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 async safeRun(input: Record<string, any> = {}, options: ContainerRunOptions<T> = {}): Promise<Result<T>> {\n try {\n const data = await this.run(input, options);\n return { success: true, data };\n } catch (e) {\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\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","safeRun","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","childI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;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './helpers';
2
2
  export * from './constants';
3
- export * from './errors';
3
+ export * from './error';
4
4
  export * from './issue';
5
5
  export * from './container';
6
6
  export * from './types';
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { distinctArray } from 'smob';
2
- import { expandPath, pathToArray, getPathValue, setPathValue } from 'pathtrace';
2
+ import { arrayToPath, expandPath, pathToArray, getPathValue, setPathValue } from 'pathtrace';
3
3
 
4
4
  function buildErrorMessageForAttribute(key) {
5
5
  return `Property ${String(key)} is invalid`;
@@ -58,21 +58,79 @@ var OptionalValue = /*#__PURE__*/ function(OptionalValue) {
58
58
  return !value;
59
59
  }
60
60
 
61
+ /**
62
+ * Stringify path array to string.
63
+ *
64
+ * @param input
65
+ */ function stringifyPath(input) {
66
+ return arrayToPath(input);
67
+ }
68
+
69
+ class ValidupError extends Error {
70
+ constructor(issues = []){
71
+ const paths = issues.map((issue)=>stringifyPath(issue.path));
72
+ super(buildErrorMessageForAttributes(paths));
73
+ this.issues = issues;
74
+ }
75
+ }
76
+
61
77
  /*
62
- * Copyright (c) 2024-2024.
78
+ * Copyright (c) 2024.
63
79
  * Author Peter Placzek (tada5hi)
64
80
  * For the full copyright and license information,
65
81
  * view the LICENSE file that was distributed with this source code.
66
- */ class ValidupError extends Error {
67
- constructor(issues = []){
68
- super(JSON.stringify(issues, (_, value)=>{
69
- if (typeof value === 'bigint') {
70
- return value.toString();
71
- }
72
- return value;
73
- }, 2));
74
- this.issues = issues;
82
+ */ // eslint-disable-next-line @typescript-eslint/ban-types
83
+ function hasOwnProperty(obj, prop) {
84
+ return Object.prototype.hasOwnProperty.call(obj, prop);
85
+ }
86
+
87
+ /*
88
+ * Copyright (c) 2024.
89
+ * Author Peter Placzek (tada5hi)
90
+ * For the full copyright and license information,
91
+ * view the LICENSE file that was distributed with this source code.
92
+ */ function isObject(input) {
93
+ return !!input && typeof input === 'object' && !Array.isArray(input);
94
+ }
95
+
96
+ function isIssuePath(input) {
97
+ if (!Array.isArray(input)) {
98
+ return false;
99
+ }
100
+ return input.every((el)=>typeof el === 'string' || typeof el === 'number' || typeof el === 'symbol');
101
+ }
102
+ function isBaseIssue(input) {
103
+ if (!isObject(input)) {
104
+ return false;
105
+ }
106
+ if (typeof input.message !== 'string') {
107
+ return false;
108
+ }
109
+ if (!isIssuePath(input.path)) {
110
+ return false;
111
+ }
112
+ return typeof input.meta === 'undefined' || isObject(input.meta);
113
+ }
114
+ function isIssueItem(input) {
115
+ if (!isBaseIssue(input)) {
116
+ return false;
117
+ }
118
+ if (input.type !== 'item') {
119
+ return false;
120
+ }
121
+ return typeof input.code === 'string';
122
+ }
123
+ function isIssueGroup(input) {
124
+ if (!isBaseIssue(input)) {
125
+ return false;
75
126
  }
127
+ if (input.type !== 'group') {
128
+ return false;
129
+ }
130
+ return Array.isArray(input.issues) && input.issues.every((issue)=>isIssueItem(issue) || isIssueGroup(issue));
131
+ }
132
+ function isIssue(input) {
133
+ return isIssueGroup(input) || isIssueItem(input);
76
134
  }
77
135
 
78
136
  /*
@@ -100,27 +158,27 @@ function defineIssueGroup(data) {
100
158
  };
101
159
  }
102
160
 
103
- /*
104
- * Copyright (c) 2024.
105
- * Author Peter Placzek (tada5hi)
106
- * For the full copyright and license information,
107
- * view the LICENSE file that was distributed with this source code.
108
- */ // eslint-disable-next-line @typescript-eslint/ban-types
109
- function hasOwnProperty(obj, prop) {
110
- return Object.prototype.hasOwnProperty.call(obj, prop);
161
+ function isError(input) {
162
+ if (!isObject(input)) {
163
+ return false;
164
+ }
165
+ return typeof input.message === 'string';
111
166
  }
112
-
113
- /*
114
- * Copyright (c) 2024.
115
- * Author Peter Placzek (tada5hi)
116
- * For the full copyright and license information,
117
- * view the LICENSE file that was distributed with this source code.
118
- */ function isObject(input) {
119
- return !!input && typeof input === 'object' && !Array.isArray(input);
167
+ function isValidupError(error) {
168
+ if (!isError(error)) {
169
+ return false;
170
+ }
171
+ if (error instanceof ValidupError) {
172
+ return true;
173
+ }
174
+ if (!hasOwnProperty(error, 'issues')) {
175
+ return false;
176
+ }
177
+ return Array.isArray(error.issues) && error.issues.every((issue)=>isIssue(issue));
120
178
  }
121
179
 
122
180
  function isContainer(input) {
123
- return isObject(input) && typeof input.run === 'function';
181
+ return isObject(input) && typeof input.run === 'function' && typeof input.safeRun === 'function';
124
182
  }
125
183
 
126
184
  class Container {
@@ -176,6 +234,7 @@ class Container {
176
234
  // ----------------------------------------------
177
235
  /**
178
236
  * @throws ValidupError
237
+ *
179
238
  * @param data
180
239
  * @param options
181
240
  */ async run(data = {}, options = {}) {
@@ -257,7 +316,7 @@ class Container {
257
316
  }
258
317
  } catch (e) {
259
318
  const childIssues = [];
260
- if (e instanceof ValidupError) {
319
+ if (isValidupError(e)) {
261
320
  for(let i = 0; i < e.issues.length; i++){
262
321
  const issue = e.issues[i];
263
322
  childIssues.push({
@@ -268,7 +327,7 @@ class Container {
268
327
  ]
269
328
  });
270
329
  }
271
- } else if (e instanceof Error) {
330
+ } else if (isError(e)) {
272
331
  childIssues.push(defineIssueItem({
273
332
  path: keyParts,
274
333
  message: e.message
@@ -332,6 +391,37 @@ class Container {
332
391
  }
333
392
  return temp;
334
393
  }
394
+ async safeRun(input = {}, options = {}) {
395
+ try {
396
+ const data = await this.run(input, options);
397
+ return {
398
+ success: true,
399
+ data
400
+ };
401
+ } catch (e) {
402
+ if (isValidupError(e)) {
403
+ return {
404
+ success: false,
405
+ error: e
406
+ };
407
+ }
408
+ if (isError(e)) {
409
+ return {
410
+ success: false,
411
+ error: new ValidupError([
412
+ defineIssueItem({
413
+ path: [],
414
+ message: e.message
415
+ })
416
+ ])
417
+ };
418
+ }
419
+ return {
420
+ success: false,
421
+ error: new ValidupError()
422
+ };
423
+ }
424
+ }
335
425
  isItemGroupIncluded(item, group) {
336
426
  if (group === GroupKey.WILDCARD) {
337
427
  return true;
@@ -380,5 +470,5 @@ class Container {
380
470
  }
381
471
  }
382
472
 
383
- export { Container, GroupKey, IssueCode, OptionalValue, ValidupError, buildErrorMessageForAttribute, buildErrorMessageForAttributes, defineIssueGroup, defineIssueItem, hasOwnProperty, isContainer, isObject, isOptionalValue };
473
+ export { Container, GroupKey, IssueCode, OptionalValue, ValidupError, buildErrorMessageForAttribute, buildErrorMessageForAttributes, defineIssueGroup, defineIssueItem, hasOwnProperty, isContainer, isError, isIssue, isIssueGroup, isIssueItem, isObject, isOptionalValue, isValidupError, stringifyPath };
384
474
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/helpers/error.ts","../src/constants.ts","../src/helpers/optional-value.ts","../src/errors/base.ts","../src/issue/constants.ts","../src/issue/define.ts","../src/utils/has-own-property.ts","../src/utils/object.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) 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 type { Issue } from '../issue';\n\nexport class ValidupError extends Error {\n readonly issues: Issue[];\n\n constructor(issues: Issue[] = []) {\n super(JSON.stringify(\n issues,\n (_: string, value: any) => {\n if (typeof value === 'bigint') {\n return value.toString();\n }\n\n return value;\n },\n 2,\n ));\n\n this.issues = issues;\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\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) 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) 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 } from '../errors';\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 (e instanceof ValidupError) {\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 (e instanceof Error) {\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","ValidupError","Error","issues","JSON","stringify","_","toString","IssueCode","defineIssueItem","data","type","code","VALUE_INVALID","defineIssueGroup","hasOwnProperty","obj","prop","prototype","call","isObject","isContainer","run","Container","mount","args","SyntaxError","path","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","issue","message","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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Ef,QAAA,IAAI,CAACuC,UAAU,EAAA;AACnB,IAAA;AAsWJ;;;;"}
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 typeof input.safeRun === '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, Result,\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 *\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 async safeRun(input: Record<string, any> = {}, options: ContainerRunOptions<T> = {}): Promise<Result<T>> {\n try {\n const data = await this.run(input, options);\n return { success: true, data };\n } catch (e) {\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\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","safeRun","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","success","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;IAC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AAAA,EAAO;oBAC9B,OAAO,IAAA;AACX,gBAAA;AACJ,YAAA;YAEA,OAAO,KAAA;AACX,QAAA;QAEA,OAAO,IAAA;AACX,IAAA;IAEQkB,UAAAA,CAAW,GAAGjC,IAA4B,EAAE;AAChD,QAAA,IAAIU,MAAAA,GAAkB,EAAA;AAEtB,QAAA,IAAK,IAAIN,CAAAA,GAAI,CAAA,EAAGA,IAAIJ,IAAAA,CAAKjD,MAAM,EAAEqD,CAAAA,EAAAA,CAAK;YAClC,MAAMC,GAAAA,GAAML,IAAI,CAACI,CAAAA,CAAE;AACnB,YAAA,IAAI,CAACC,GAAAA,IAAOA,GAAAA,CAAItD,MAAM,KAAK,CAAA,EAAG;AAC1B,gBAAA;AACJ,YAAA;AAEA,YAAA,IAAIsD,GAAAA,CAAIkB,EAAE,CAAC,CAAA,CAAA,KAAO,GAAA,EAAK;gBACnBb,MAAAA,IAAUL,GAAAA;YACd,CAAA,MAAO;gBACHK,MAAAA,IAAUA,MAAAA,CAAO3D,MAAM,GAAG,CAAA,GAAI,CAAC,CAAC,EAAEsD,KAAK,GAAGA,GAAAA;AAC9C,YAAA;AACJ,QAAA;QAEA,OAAOK,MAAAA;AACX,IAAA;AAEUkC,IAAAA,UAAAA,GAAoB,CAE9B;;IApYA,WAAA,CAAYzC,OAAAA,GAA+B,EAAE,CAAE;QAC3C,IAAI,CAACA,OAAO,GAAGA,OAAAA;QACf,IAAI,CAACG,KAAK,GAAG,EAAE;AAEf,QAAA,IAAI,CAACsC,UAAU,EAAA;AACnB,IAAA;AAgYJ;;;;"}
@@ -0,0 +1,4 @@
1
+ import type { Issue, IssueGroup, IssueItem } from './types';
2
+ export declare function isIssueItem(input: unknown): input is IssueItem;
3
+ export declare function isIssueGroup(input: unknown): input is IssueGroup;
4
+ export declare function isIssue(input: unknown): input is Issue;
@@ -1,3 +1,4 @@
1
+ export * from './check';
1
2
  export * from './constants';
2
3
  export * from './define';
3
4
  export * from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "validup",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "A validation library.",
5
5
  "author": {
6
6
  "name": "Peter Placzek",
@@ -1 +0,0 @@
1
- export * from './base';
File without changes