validup 0.1.7 → 0.1.9
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/README.md +5 -1
- package/dist/errors/nested.d.ts +1 -1
- package/dist/errors/validator.d.ts +2 -1
- package/dist/helpers/error.d.ts +1 -0
- package/dist/index.cjs +56 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +48 -36
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +18 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -165,7 +165,11 @@ type ValidatorContext = {
|
|
|
165
165
|
/**
|
|
166
166
|
* The input data of the current container.
|
|
167
167
|
*/
|
|
168
|
-
data: Record<string, any
|
|
168
|
+
data: Record<string, any>,
|
|
169
|
+
/**
|
|
170
|
+
* The group name for which the validator is executed.
|
|
171
|
+
*/
|
|
172
|
+
group?: string
|
|
169
173
|
};
|
|
170
174
|
```
|
|
171
175
|
|
package/dist/errors/nested.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type ValidupNestedErrorOptions = {
|
|
|
5
5
|
message?: string;
|
|
6
6
|
};
|
|
7
7
|
export declare class ValidupNestedError extends ValidupError {
|
|
8
|
-
children: ValidupValidatorError[];
|
|
8
|
+
readonly children: ValidupValidatorError[];
|
|
9
9
|
constructor(options?: ValidupNestedErrorOptions);
|
|
10
10
|
addChild(child: ValidupValidatorError): void;
|
|
11
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ValidupError } from './base';
|
|
1
2
|
export type ValidupValidatorErrorOptions = {
|
|
2
3
|
path: string;
|
|
3
4
|
pathAbsolute?: string;
|
|
@@ -6,7 +7,7 @@ export type ValidupValidatorErrorOptions = {
|
|
|
6
7
|
received?: unknown;
|
|
7
8
|
expected?: unknown;
|
|
8
9
|
};
|
|
9
|
-
export declare class ValidupValidatorError extends
|
|
10
|
+
export declare class ValidupValidatorError extends ValidupError {
|
|
10
11
|
readonly path: string;
|
|
11
12
|
readonly pathAbsolute: string;
|
|
12
13
|
readonly code?: string | null;
|
package/dist/helpers/error.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
var smob = require('smob');
|
|
4
4
|
var pathtrace = require('pathtrace');
|
|
5
5
|
|
|
6
|
+
function buildErrorMessageForAttribute(key) {
|
|
7
|
+
return `The attribute ${String(key)} is invalid.`;
|
|
8
|
+
}
|
|
6
9
|
function buildErrorMessageForAttributes(input) {
|
|
7
10
|
let names;
|
|
8
11
|
if (Array.isArray(input)) {
|
|
@@ -16,7 +19,7 @@ function buildErrorMessageForAttributes(input) {
|
|
|
16
19
|
if (names.length > 1) {
|
|
17
20
|
return `The attributes ${names.join(', ')} are invalid.`;
|
|
18
21
|
}
|
|
19
|
-
return
|
|
22
|
+
return buildErrorMessageForAttribute(names[0]);
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
/*
|
|
@@ -24,12 +27,11 @@ function buildErrorMessageForAttributes(input) {
|
|
|
24
27
|
* Author Peter Placzek (tada5hi)
|
|
25
28
|
* For the full copyright and license information,
|
|
26
29
|
* view the LICENSE file that was distributed with this source code.
|
|
27
|
-
*/
|
|
28
|
-
(function(GroupKey) {
|
|
30
|
+
*/ var GroupKey = /*#__PURE__*/ function(GroupKey) {
|
|
29
31
|
GroupKey["WILDCARD"] = "*";
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
return GroupKey;
|
|
33
|
+
}({});
|
|
34
|
+
var OptionalValue = /*#__PURE__*/ function(OptionalValue) {
|
|
33
35
|
/**
|
|
34
36
|
* value: undefined
|
|
35
37
|
*/ OptionalValue["UNDEFINED"] = "undefined";
|
|
@@ -39,7 +41,8 @@ exports.OptionalValue = void 0;
|
|
|
39
41
|
/**
|
|
40
42
|
* value: empty string, false, 0
|
|
41
43
|
*/ OptionalValue["FALSY"] = "falsy";
|
|
42
|
-
|
|
44
|
+
return OptionalValue;
|
|
45
|
+
}({});
|
|
43
46
|
|
|
44
47
|
/**
|
|
45
48
|
* Check if input value (type of) satisfies optional value type constraint.
|
|
@@ -47,11 +50,11 @@ exports.OptionalValue = void 0;
|
|
|
47
50
|
* @param value
|
|
48
51
|
* @param optionalValue
|
|
49
52
|
*/ function isOptionalValue(value, optionalValue) {
|
|
50
|
-
const optionValueNormalized = optionalValue ||
|
|
51
|
-
if (optionValueNormalized ===
|
|
52
|
-
return value === null;
|
|
53
|
+
const optionValueNormalized = optionalValue || OptionalValue.UNDEFINED;
|
|
54
|
+
if (optionValueNormalized === OptionalValue.NULL) {
|
|
55
|
+
return value === null || typeof value === 'undefined';
|
|
53
56
|
}
|
|
54
|
-
if (optionValueNormalized ===
|
|
57
|
+
if (optionValueNormalized === OptionalValue.UNDEFINED) {
|
|
55
58
|
return typeof value === 'undefined';
|
|
56
59
|
}
|
|
57
60
|
return !value;
|
|
@@ -62,7 +65,10 @@ exports.OptionalValue = void 0;
|
|
|
62
65
|
* Author Peter Placzek (tada5hi)
|
|
63
66
|
* For the full copyright and license information,
|
|
64
67
|
* view the LICENSE file that was distributed with this source code.
|
|
65
|
-
*/ class
|
|
68
|
+
*/ class ValidupError extends Error {
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
class ValidupValidatorError extends ValidupError {
|
|
66
72
|
constructor(options){
|
|
67
73
|
super(options.message);
|
|
68
74
|
this.path = options.path;
|
|
@@ -73,14 +79,6 @@ exports.OptionalValue = void 0;
|
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
/*
|
|
77
|
-
* Copyright (c) 2024-2024.
|
|
78
|
-
* Author Peter Placzek (tada5hi)
|
|
79
|
-
* For the full copyright and license information,
|
|
80
|
-
* view the LICENSE file that was distributed with this source code.
|
|
81
|
-
*/ class ValidupError extends Error {
|
|
82
|
-
}
|
|
83
|
-
|
|
84
82
|
class ValidupNestedError extends ValidupError {
|
|
85
83
|
addChild(child) {
|
|
86
84
|
this.children.push(child);
|
|
@@ -160,6 +158,12 @@ class Container {
|
|
|
160
158
|
} else if (this.options.pathsToInclude) {
|
|
161
159
|
pathsToInclude = this.options.pathsToInclude;
|
|
162
160
|
}
|
|
161
|
+
let pathsToExclude;
|
|
162
|
+
if (options.pathsToExclude) {
|
|
163
|
+
pathsToExclude = options.pathsToExclude;
|
|
164
|
+
} else if (this.options.pathsToInclude) {
|
|
165
|
+
pathsToExclude = this.options.pathsToExclude;
|
|
166
|
+
}
|
|
163
167
|
let itemCount = 0;
|
|
164
168
|
for(let i = 0; i < this.items.length; i++){
|
|
165
169
|
const item = this.items[i];
|
|
@@ -189,23 +193,24 @@ class Container {
|
|
|
189
193
|
if (typeof pathsToInclude !== 'undefined' && pathsToInclude.indexOf(path) === -1) {
|
|
190
194
|
continue;
|
|
191
195
|
}
|
|
196
|
+
if (typeof pathsToExclude !== 'undefined' && pathsToExclude.indexOf(path) !== -1) {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
192
199
|
try {
|
|
193
|
-
if (item.
|
|
194
|
-
if (item.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
output[this.mergePaths(path, tmpKeys[k])] = tmp[tmpKeys[k]];
|
|
208
|
-
}
|
|
200
|
+
if (item.optional && isOptionalValue(value, item.optionalValue)) {
|
|
201
|
+
if (item.optionalInclude) {
|
|
202
|
+
output[path] = value;
|
|
203
|
+
}
|
|
204
|
+
} else if (item.data instanceof Container) {
|
|
205
|
+
const tmp = await item.data.run(isObject(value) ? value : {}, {
|
|
206
|
+
group: options.group,
|
|
207
|
+
flat: true,
|
|
208
|
+
path: pathAbsolute,
|
|
209
|
+
pathsToInclude: options.pathsToInclude
|
|
210
|
+
});
|
|
211
|
+
const tmpKeys = Object.keys(tmp);
|
|
212
|
+
for(let k = 0; k < tmpKeys.length; k++){
|
|
213
|
+
output[this.mergePaths(path, tmpKeys[k])] = tmp[tmpKeys[k]];
|
|
209
214
|
}
|
|
210
215
|
} else {
|
|
211
216
|
output[path] = await item.data({
|
|
@@ -213,14 +218,21 @@ class Container {
|
|
|
213
218
|
pathRaw: item.path ?? '',
|
|
214
219
|
pathAbsolute,
|
|
215
220
|
value,
|
|
216
|
-
data
|
|
221
|
+
data,
|
|
222
|
+
group: options.group
|
|
217
223
|
});
|
|
218
224
|
}
|
|
219
225
|
} catch (e) {
|
|
220
226
|
if (e instanceof ValidupValidatorError) {
|
|
221
227
|
errors.push(e);
|
|
228
|
+
errorKeys.push(pathAbsolute);
|
|
222
229
|
} else if (e instanceof ValidupNestedError) {
|
|
223
230
|
errors.push(...e.children);
|
|
231
|
+
if (pathAbsolute.length > 0) {
|
|
232
|
+
errorKeys.push(pathAbsolute);
|
|
233
|
+
} else {
|
|
234
|
+
errorKeys.push(...e.children.map((child)=>child.pathAbsolute));
|
|
235
|
+
}
|
|
224
236
|
} else {
|
|
225
237
|
const error = new ValidupValidatorError({
|
|
226
238
|
path,
|
|
@@ -232,8 +244,8 @@ class Container {
|
|
|
232
244
|
error.message = e.message;
|
|
233
245
|
}
|
|
234
246
|
errors.push(error);
|
|
247
|
+
errorKeys.push(pathAbsolute);
|
|
235
248
|
}
|
|
236
|
-
errorKeys.push(pathAbsolute);
|
|
237
249
|
}
|
|
238
250
|
pathsCount++;
|
|
239
251
|
}
|
|
@@ -273,19 +285,19 @@ class Container {
|
|
|
273
285
|
return temp;
|
|
274
286
|
}
|
|
275
287
|
isItemGroupIncluded(item, group) {
|
|
276
|
-
if (group ===
|
|
288
|
+
if (group === GroupKey.WILDCARD) {
|
|
277
289
|
return true;
|
|
278
290
|
}
|
|
279
291
|
if (item.group) {
|
|
280
292
|
if (Array.isArray(item.group)) {
|
|
281
|
-
if (item.group.indexOf(
|
|
293
|
+
if (item.group.indexOf(GroupKey.WILDCARD) !== -1) {
|
|
282
294
|
return true;
|
|
283
295
|
}
|
|
284
296
|
if (group && item.group.indexOf(group) !== -1) {
|
|
285
297
|
return true;
|
|
286
298
|
}
|
|
287
299
|
} else {
|
|
288
|
-
if (item.group ===
|
|
300
|
+
if (item.group === GroupKey.WILDCARD) {
|
|
289
301
|
return true;
|
|
290
302
|
}
|
|
291
303
|
if (item.group === group) {
|
|
@@ -321,9 +333,12 @@ class Container {
|
|
|
321
333
|
}
|
|
322
334
|
|
|
323
335
|
exports.Container = Container;
|
|
336
|
+
exports.GroupKey = GroupKey;
|
|
337
|
+
exports.OptionalValue = OptionalValue;
|
|
324
338
|
exports.ValidupError = ValidupError;
|
|
325
339
|
exports.ValidupNestedError = ValidupNestedError;
|
|
326
340
|
exports.ValidupValidatorError = ValidupValidatorError;
|
|
341
|
+
exports.buildErrorMessageForAttribute = buildErrorMessageForAttribute;
|
|
327
342
|
exports.buildErrorMessageForAttributes = buildErrorMessageForAttributes;
|
|
328
343
|
exports.hasOwnProperty = hasOwnProperty;
|
|
329
344
|
exports.isObject = isObject;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/helpers/error.ts","../src/constants.ts","../src/helpers/optional-value.ts","../src/errors/validator.ts","../src/errors/base.ts","../src/errors/nested.ts","../src/utils/has-own-property.ts","../src/utils/object.ts","../src/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 buildErrorMessageForAttributes(input: (number | string)[] | Record<string, any>) {\n let names: string[];\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 'An unexpected error occurred.';\n }\n\n if (names.length > 1) {\n return `The attributes ${names.join(', ')} are invalid.`;\n }\n\n return `The attribute ${String(names[0])} is invalid.`;\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;\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\nexport type ValidupValidatorErrorOptions = {\n path: string,\n pathAbsolute?: string,\n message?: string,\n code?: string | null,\n received?: unknown,\n expected?: unknown\n};\n\nexport class ValidupValidatorError extends Error {\n readonly path: string;\n\n readonly pathAbsolute : string;\n\n readonly code?: string | null;\n\n readonly received?: unknown;\n\n readonly expected?: unknown;\n\n constructor(options: ValidupValidatorErrorOptions) {\n super(options.message);\n\n this.path = options.path;\n this.pathAbsolute = options.pathAbsolute ?? options.path;\n this.code = options.code;\n this.received = options.received;\n this.expected = options.expected;\n }\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\nexport class ValidupError extends Error {\n\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 { ValidupValidatorError } from './validator';\nimport { ValidupError } from './base';\n\nexport type ValidupNestedErrorOptions = {\n children?: ValidupValidatorError[],\n message?: string\n};\n\nexport class ValidupNestedError extends ValidupError {\n children: ValidupValidatorError[];\n\n constructor(options: ValidupNestedErrorOptions = {}) {\n super(options.message || 'One or many attributes may be invalid.');\n\n this.children = options.children || [];\n }\n\n addChild(child: ValidupValidatorError) {\n this.children.push(child);\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) 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 { expandPath, getPathValue, setPathValue } from 'pathtrace';\nimport { GroupKey } from './constants';\nimport { ValidupNestedError, ValidupValidatorError } from './errors';\nimport { buildErrorMessageForAttributes, isOptionalValue } from './helpers';\nimport type {\n ContainerItem,\n ContainerMountOptions,\n ContainerOptions,\n ContainerRunOptions,\n ObjectPropertyPath,\n ObjectPropertyPathExtended,\n Validator,\n} from './types';\nimport { hasOwnProperty, isObject } from './utils';\n\nexport class Container<\n T extends Record<string, any> = Record<string, any>,\n> {\n protected options : ContainerOptions<T>;\n\n protected items : ContainerItem[];\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: Container) : void;\n\n mount(\n options: ContainerMountOptions,\n container: Container\n ): void;\n\n mount(\n key: ObjectPropertyPathExtended<T>,\n data: Container | Validator\n ) : void;\n\n mount(\n key: ObjectPropertyPathExtended<T>,\n options: ContainerMountOptions,\n data: Container | 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: Container | Validator | undefined;\n let dataIsContainer : boolean = false;\n\n let options: ContainerMountOptions = {};\n\n for (let i = 0; i < args.length; i++) {\n if (typeof args[i] === 'string') {\n path = args[i];\n continue;\n }\n\n if (typeof args[i] === 'function') {\n data = args[i];\n continue;\n }\n\n if (args[i] instanceof Container) {\n data = args[i];\n dataIsContainer = true;\n continue;\n }\n\n if (isObject(args[i])) {\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 this.items.push({\n ...options,\n data,\n path,\n });\n }\n\n // ----------------------------------------------\n\n async run(\n data: Record<string, any> = {},\n options: ContainerRunOptions<T> = {},\n ): Promise<T> {\n const output: Record<string, any> = {};\n\n const errors: ValidupValidatorError[] = [];\n const errorKeys : string[] = [];\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 itemCount = 0;\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 continue;\n }\n\n let pathsCount = 0;\n\n let paths : string[];\n if (item.path) {\n paths = expandPath(data, item.path);\n } else {\n paths = [''];\n }\n\n for (let j = 0; j < paths.length; j++) {\n const path = paths[j];\n const pathAbsolute = this.mergePaths(options.path, paths[j]);\n\n let value : unknown;\n if (hasOwnProperty(output, path)) {\n value = output[path];\n } else if (path.length > 0) {\n value = getPathValue(data, path);\n } else {\n value = data;\n }\n\n if (\n typeof pathsToInclude !== 'undefined' &&\n pathsToInclude.indexOf(path) === -1\n ) {\n continue;\n }\n\n try {\n if (item.data instanceof Container) {\n if (\n item.optional &&\n isOptionalValue(value, item.optionalValue)\n ) {\n if (item.optionalInclude) {\n output[path] = value;\n }\n } else {\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(path, tmpKeys[k])] = tmp[tmpKeys[k]];\n }\n }\n } else {\n output[path] = await item.data({\n path,\n pathRaw: item.path ?? '',\n\n pathAbsolute,\n value,\n data,\n });\n }\n } catch (e) {\n if (e instanceof ValidupValidatorError) {\n errors.push(e);\n } else if (e instanceof ValidupNestedError) {\n errors.push(...e.children);\n } else {\n const error = new ValidupValidatorError({\n path,\n pathAbsolute,\n received: value,\n });\n\n if (e instanceof Error) {\n error.cause = e;\n error.message = e.message;\n }\n\n errors.push(error);\n }\n\n errorKeys.push(pathAbsolute);\n }\n\n pathsCount++;\n }\n\n if (pathsCount > 0) {\n itemCount++;\n }\n }\n\n if (this.options.oneOf) {\n if (errors.length === itemCount) {\n throw new ValidupNestedError({ message: buildErrorMessageForAttributes(errorKeys), children: errors });\n }\n } else if (errors.length > 0) {\n throw new ValidupNestedError({ message: buildErrorMessageForAttributes(errorKeys), children: errors });\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 ObjectPropertyPath<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: ContainerItem,\n group?: string,\n ) : boolean {\n if (group === GroupKey.WILDCARD) {\n return true;\n }\n\n if (item.group) {\n if (Array.isArray(item.group)) {\n if (item.group.indexOf(GroupKey.WILDCARD) !== -1) {\n return true;\n }\n\n if (group && item.group.indexOf(group) !== -1) {\n return true;\n }\n } else {\n if (item.group === GroupKey.WILDCARD) {\n return true;\n }\n\n if (item.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":["buildErrorMessageForAttributes","input","names","Array","isArray","distinctArray","Object","keys","length","join","String","GroupKey","OptionalValue","isOptionalValue","value","optionalValue","optionValueNormalized","UNDEFINED","NULL","ValidupValidatorError","Error","constructor","options","message","path","pathAbsolute","code","received","expected","ValidupError","ValidupNestedError","addChild","child","children","push","hasOwnProperty","obj","prop","prototype","call","isObject","Container","mount","args","SyntaxError","data","dataIsContainer","i","items","run","output","errors","errorKeys","pathsToInclude","itemCount","item","isItemGroupIncluded","group","pathsCount","paths","expandPath","j","mergePaths","getPathValue","indexOf","optional","optionalInclude","tmp","flat","tmpKeys","k","pathRaw","e","error","cause","oneOf","defaults","defaultKeys","temp","setPathValue","WILDCARD","arg","at","initialize"],"mappings":";;;;;AASO,SAASA,+BAA+BC,KAAgD,EAAA;IAC3F,IAAIC,KAAAA,CAAAA;IACJ,IAAIC,KAAAA,CAAMC,OAAO,CAACH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AIyE,GAAIC,CAAAA,EAAE,CAAC,CAAA,CAAA,KAAO,GAAK,EAAA;gBACnBhC,MAAU+B,IAAAA,GAAAA,CAAAA;aACP,MAAA;gBACH/B,MAAUA,IAAAA,MAAAA,CAAO1C,MAAM,GAAG,CAAA,GAAI,CAAC,CAAC,EAAEyE,GAAI,CAAA,CAAC,GAAGA,GAAAA,CAAAA;AAC9C,aAAA;AACJ,SAAA;QAEA,OAAO/B,MAAAA,CAAAA;AACX,KAAA;AAEUiC,IAAAA,UAAAA,GAAoB,EAE9B;;IAjSA9D,WAAYC,CAAAA,OAAAA,GAA+B,EAAE,CAAE;QAC3C,IAAI,CAACA,OAAO,GAAGA,OAAAA,CAAAA;QACf,IAAI,CAAC0B,KAAK,GAAG,EAAE,CAAA;AAEf,QAAA,IAAI,CAACmC,UAAU,EAAA,CAAA;AACnB,KAAA;AA6RJ;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/helpers/error.ts","../src/constants.ts","../src/helpers/optional-value.ts","../src/errors/base.ts","../src/errors/validator.ts","../src/errors/nested.ts","../src/utils/has-own-property.ts","../src/utils/object.ts","../src/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: string | number) {\n return `The attribute ${String(key)} is invalid.`;\n}\n\nexport function buildErrorMessageForAttributes(input: (number | string)[] | Record<string, any>) {\n let names: string[];\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 'An unexpected error occurred.';\n }\n\n if (names.length > 1) {\n return `The attributes ${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\nexport class ValidupError extends Error {\n\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 { ValidupError } from './base';\n\nexport type ValidupValidatorErrorOptions = {\n path: string,\n pathAbsolute?: string,\n message?: string,\n code?: string | null,\n received?: unknown,\n expected?: unknown\n};\n\nexport class ValidupValidatorError extends ValidupError {\n readonly path: string;\n\n readonly pathAbsolute : string;\n\n readonly code?: string | null;\n\n readonly received?: unknown;\n\n readonly expected?: unknown;\n\n constructor(options: ValidupValidatorErrorOptions) {\n super(options.message);\n\n this.path = options.path;\n this.pathAbsolute = options.pathAbsolute ?? options.path;\n this.code = options.code;\n this.received = options.received;\n this.expected = options.expected;\n }\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 { ValidupValidatorError } from './validator';\nimport { ValidupError } from './base';\n\nexport type ValidupNestedErrorOptions = {\n children?: ValidupValidatorError[],\n message?: string\n};\n\nexport class ValidupNestedError extends ValidupError {\n readonly children: ValidupValidatorError[];\n\n constructor(options: ValidupNestedErrorOptions = {}) {\n super(options.message || 'One or many attributes may be invalid.');\n\n this.children = options.children || [];\n }\n\n addChild(child: ValidupValidatorError) {\n this.children.push(child);\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) 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 { expandPath, getPathValue, setPathValue } from 'pathtrace';\nimport { GroupKey } from './constants';\nimport { ValidupNestedError, ValidupValidatorError } from './errors';\nimport { buildErrorMessageForAttributes, isOptionalValue } from './helpers';\nimport type {\n ContainerItem,\n ContainerMountOptions,\n ContainerOptions,\n ContainerRunOptions,\n ObjectPropertyPath,\n ObjectPropertyPathExtended,\n Validator,\n} from './types';\nimport { hasOwnProperty, isObject } from './utils';\n\nexport class Container<\n T extends Record<string, any> = Record<string, any>,\n> {\n protected options : ContainerOptions<T>;\n\n protected items : ContainerItem[];\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: Container) : void;\n\n mount(\n options: ContainerMountOptions,\n container: Container\n ): void;\n\n mount(\n key: ObjectPropertyPathExtended<T>,\n data: Container | Validator\n ) : void;\n\n mount(\n key: ObjectPropertyPathExtended<T>,\n options: ContainerMountOptions,\n data: Container | 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: Container | Validator | undefined;\n let dataIsContainer : boolean = false;\n\n let options: ContainerMountOptions = {};\n\n for (let i = 0; i < args.length; i++) {\n if (typeof args[i] === 'string') {\n path = args[i];\n continue;\n }\n\n if (typeof args[i] === 'function') {\n data = args[i];\n continue;\n }\n\n if (args[i] instanceof Container) {\n data = args[i];\n dataIsContainer = true;\n continue;\n }\n\n if (isObject(args[i])) {\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 this.items.push({\n ...options,\n data,\n path,\n });\n }\n\n // ----------------------------------------------\n\n async run(\n data: Record<string, any> = {},\n options: ContainerRunOptions<T> = {},\n ): Promise<T> {\n const output: Record<string, any> = {};\n\n const errors: ValidupValidatorError[] = [];\n const errorKeys : string[] = [];\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.pathsToInclude) {\n pathsToExclude = this.options.pathsToExclude as string[];\n }\n\n let itemCount = 0;\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 continue;\n }\n\n let pathsCount = 0;\n\n let paths : string[];\n if (item.path) {\n paths = expandPath(data, item.path);\n } else {\n paths = [''];\n }\n\n for (let j = 0; j < paths.length; j++) {\n const path = paths[j];\n const pathAbsolute = this.mergePaths(options.path, paths[j]);\n\n let value : unknown;\n if (hasOwnProperty(output, path)) {\n value = output[path];\n } else if (path.length > 0) {\n value = getPathValue(data, path);\n } else {\n value = data;\n }\n\n if (\n typeof pathsToInclude !== 'undefined' &&\n pathsToInclude.indexOf(path) === -1\n ) {\n continue;\n }\n\n if (\n typeof pathsToExclude !== 'undefined' &&\n pathsToExclude.indexOf(path) !== -1\n ) {\n continue;\n }\n\n try {\n if (\n item.optional &&\n isOptionalValue(value, item.optionalValue)\n ) {\n if (item.optionalInclude) {\n output[path] = value;\n }\n } else if (item.data instanceof 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(path, tmpKeys[k])] = tmp[tmpKeys[k]];\n }\n } else {\n output[path] = await item.data({\n path,\n pathRaw: item.path ?? '',\n\n pathAbsolute,\n value,\n data,\n group: options.group,\n });\n }\n } catch (e) {\n if (e instanceof ValidupValidatorError) {\n errors.push(e);\n errorKeys.push(pathAbsolute);\n } else if (e instanceof ValidupNestedError) {\n errors.push(...e.children);\n\n if (pathAbsolute.length > 0) {\n errorKeys.push(pathAbsolute);\n } else {\n errorKeys.push(...e.children.map((child) => child.pathAbsolute));\n }\n } else {\n const error = new ValidupValidatorError({\n path,\n pathAbsolute,\n received: value,\n });\n\n if (e instanceof Error) {\n error.cause = e;\n error.message = e.message;\n }\n\n errors.push(error);\n errorKeys.push(pathAbsolute);\n }\n }\n\n pathsCount++;\n }\n\n if (pathsCount > 0) {\n itemCount++;\n }\n }\n\n if (this.options.oneOf) {\n if (errors.length === itemCount) {\n throw new ValidupNestedError({ message: buildErrorMessageForAttributes(errorKeys), children: errors });\n }\n } else if (errors.length > 0) {\n throw new ValidupNestedError({ message: buildErrorMessageForAttributes(errorKeys), children: errors });\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 ObjectPropertyPath<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: ContainerItem,\n group?: string,\n ) : boolean {\n if (group === GroupKey.WILDCARD) {\n return true;\n }\n\n if (item.group) {\n if (Array.isArray(item.group)) {\n if (item.group.indexOf(GroupKey.WILDCARD) !== -1) {\n return true;\n }\n\n if (group && item.group.indexOf(group) !== -1) {\n return true;\n }\n } else {\n if (item.group === GroupKey.WILDCARD) {\n return true;\n }\n\n if (item.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","ValidupValidatorError","options","message","path","pathAbsolute","code","received","expected","ValidupNestedError","addChild","child","children","push","hasOwnProperty","obj","prop","prototype","call","isObject","Container","mount","args","SyntaxError","data","dataIsContainer","i","items","run","output","errors","errorKeys","pathsToInclude","pathsToExclude","itemCount","item","isItemGroupIncluded","group","pathsCount","paths","expandPath","j","mergePaths","getPathValue","indexOf","optional","optionalInclude","tmp","flat","tmpKeys","k","pathRaw","e","map","error","cause","oneOf","defaults","defaultKeys","temp","setPathValue","WILDCARD","arg","at","initialize"],"mappings":";;;;;AASO,SAASA,8BAA8BC,GAAoB,EAAA;AAC9D,IAAA,OAAO,CAAC,cAAc,EAAEC,MAAAA,CAAOD,GAAAA,CAAAA,CAAK,YAAY,CAAC;AACrD;AAEO,SAASE,+BAA+BC,KAAgD,EAAA;IAC3F,IAAIC,KAAAA;IACJ,IAAIC,KAAAA,CAAMC,OAAO,CAACH,KAAAA,CAAAA,EAAQ;AACtBC,QAAAA,KAAAA,GAAQG,kBAAAA,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,+BAAA;AACX,IAAA;IAEA,IAAIN,KAAAA,CAAMM,MAAM,GAAG,CAAA,EAAG;QAClB,OAAO,CAAC,eAAe,EAAEN,KAAAA,CAAMO,IAAI,CAAC,IAAA,CAAA,CAAM,aAAa,CAAC;AAC5D,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,WAAA;AAED;;AAEC,QAAA,aAAA,CAAA,MAAA,CAAA,GAAA,MAAA;AAED;;AAEC,QAAA,aA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|
1
1
|
import { distinctArray } from 'smob';
|
|
2
2
|
import { expandPath, getPathValue, setPathValue } from 'pathtrace';
|
|
3
3
|
|
|
4
|
+
function buildErrorMessageForAttribute(key) {
|
|
5
|
+
return `The attribute ${String(key)} is invalid.`;
|
|
6
|
+
}
|
|
4
7
|
function buildErrorMessageForAttributes(input) {
|
|
5
8
|
let names;
|
|
6
9
|
if (Array.isArray(input)) {
|
|
@@ -14,7 +17,7 @@ function buildErrorMessageForAttributes(input) {
|
|
|
14
17
|
if (names.length > 1) {
|
|
15
18
|
return `The attributes ${names.join(', ')} are invalid.`;
|
|
16
19
|
}
|
|
17
|
-
return
|
|
20
|
+
return buildErrorMessageForAttribute(names[0]);
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
/*
|
|
@@ -22,12 +25,11 @@ function buildErrorMessageForAttributes(input) {
|
|
|
22
25
|
* Author Peter Placzek (tada5hi)
|
|
23
26
|
* For the full copyright and license information,
|
|
24
27
|
* view the LICENSE file that was distributed with this source code.
|
|
25
|
-
*/ var GroupKey
|
|
26
|
-
(function(GroupKey) {
|
|
28
|
+
*/ var GroupKey = /*#__PURE__*/ function(GroupKey) {
|
|
27
29
|
GroupKey["WILDCARD"] = "*";
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
return GroupKey;
|
|
31
|
+
}({});
|
|
32
|
+
var OptionalValue = /*#__PURE__*/ function(OptionalValue) {
|
|
31
33
|
/**
|
|
32
34
|
* value: undefined
|
|
33
35
|
*/ OptionalValue["UNDEFINED"] = "undefined";
|
|
@@ -37,7 +39,8 @@ var OptionalValue;
|
|
|
37
39
|
/**
|
|
38
40
|
* value: empty string, false, 0
|
|
39
41
|
*/ OptionalValue["FALSY"] = "falsy";
|
|
40
|
-
|
|
42
|
+
return OptionalValue;
|
|
43
|
+
}({});
|
|
41
44
|
|
|
42
45
|
/**
|
|
43
46
|
* Check if input value (type of) satisfies optional value type constraint.
|
|
@@ -47,7 +50,7 @@ var OptionalValue;
|
|
|
47
50
|
*/ function isOptionalValue(value, optionalValue) {
|
|
48
51
|
const optionValueNormalized = optionalValue || OptionalValue.UNDEFINED;
|
|
49
52
|
if (optionValueNormalized === OptionalValue.NULL) {
|
|
50
|
-
return value === null;
|
|
53
|
+
return value === null || typeof value === 'undefined';
|
|
51
54
|
}
|
|
52
55
|
if (optionValueNormalized === OptionalValue.UNDEFINED) {
|
|
53
56
|
return typeof value === 'undefined';
|
|
@@ -60,7 +63,10 @@ var OptionalValue;
|
|
|
60
63
|
* Author Peter Placzek (tada5hi)
|
|
61
64
|
* For the full copyright and license information,
|
|
62
65
|
* view the LICENSE file that was distributed with this source code.
|
|
63
|
-
*/ class
|
|
66
|
+
*/ class ValidupError extends Error {
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
class ValidupValidatorError extends ValidupError {
|
|
64
70
|
constructor(options){
|
|
65
71
|
super(options.message);
|
|
66
72
|
this.path = options.path;
|
|
@@ -71,14 +77,6 @@ var OptionalValue;
|
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
|
|
74
|
-
/*
|
|
75
|
-
* Copyright (c) 2024-2024.
|
|
76
|
-
* Author Peter Placzek (tada5hi)
|
|
77
|
-
* For the full copyright and license information,
|
|
78
|
-
* view the LICENSE file that was distributed with this source code.
|
|
79
|
-
*/ class ValidupError extends Error {
|
|
80
|
-
}
|
|
81
|
-
|
|
82
80
|
class ValidupNestedError extends ValidupError {
|
|
83
81
|
addChild(child) {
|
|
84
82
|
this.children.push(child);
|
|
@@ -158,6 +156,12 @@ class Container {
|
|
|
158
156
|
} else if (this.options.pathsToInclude) {
|
|
159
157
|
pathsToInclude = this.options.pathsToInclude;
|
|
160
158
|
}
|
|
159
|
+
let pathsToExclude;
|
|
160
|
+
if (options.pathsToExclude) {
|
|
161
|
+
pathsToExclude = options.pathsToExclude;
|
|
162
|
+
} else if (this.options.pathsToInclude) {
|
|
163
|
+
pathsToExclude = this.options.pathsToExclude;
|
|
164
|
+
}
|
|
161
165
|
let itemCount = 0;
|
|
162
166
|
for(let i = 0; i < this.items.length; i++){
|
|
163
167
|
const item = this.items[i];
|
|
@@ -187,23 +191,24 @@ class Container {
|
|
|
187
191
|
if (typeof pathsToInclude !== 'undefined' && pathsToInclude.indexOf(path) === -1) {
|
|
188
192
|
continue;
|
|
189
193
|
}
|
|
194
|
+
if (typeof pathsToExclude !== 'undefined' && pathsToExclude.indexOf(path) !== -1) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
190
197
|
try {
|
|
191
|
-
if (item.
|
|
192
|
-
if (item.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
output[this.mergePaths(path, tmpKeys[k])] = tmp[tmpKeys[k]];
|
|
206
|
-
}
|
|
198
|
+
if (item.optional && isOptionalValue(value, item.optionalValue)) {
|
|
199
|
+
if (item.optionalInclude) {
|
|
200
|
+
output[path] = value;
|
|
201
|
+
}
|
|
202
|
+
} else if (item.data instanceof Container) {
|
|
203
|
+
const tmp = await item.data.run(isObject(value) ? value : {}, {
|
|
204
|
+
group: options.group,
|
|
205
|
+
flat: true,
|
|
206
|
+
path: pathAbsolute,
|
|
207
|
+
pathsToInclude: options.pathsToInclude
|
|
208
|
+
});
|
|
209
|
+
const tmpKeys = Object.keys(tmp);
|
|
210
|
+
for(let k = 0; k < tmpKeys.length; k++){
|
|
211
|
+
output[this.mergePaths(path, tmpKeys[k])] = tmp[tmpKeys[k]];
|
|
207
212
|
}
|
|
208
213
|
} else {
|
|
209
214
|
output[path] = await item.data({
|
|
@@ -211,14 +216,21 @@ class Container {
|
|
|
211
216
|
pathRaw: item.path ?? '',
|
|
212
217
|
pathAbsolute,
|
|
213
218
|
value,
|
|
214
|
-
data
|
|
219
|
+
data,
|
|
220
|
+
group: options.group
|
|
215
221
|
});
|
|
216
222
|
}
|
|
217
223
|
} catch (e) {
|
|
218
224
|
if (e instanceof ValidupValidatorError) {
|
|
219
225
|
errors.push(e);
|
|
226
|
+
errorKeys.push(pathAbsolute);
|
|
220
227
|
} else if (e instanceof ValidupNestedError) {
|
|
221
228
|
errors.push(...e.children);
|
|
229
|
+
if (pathAbsolute.length > 0) {
|
|
230
|
+
errorKeys.push(pathAbsolute);
|
|
231
|
+
} else {
|
|
232
|
+
errorKeys.push(...e.children.map((child)=>child.pathAbsolute));
|
|
233
|
+
}
|
|
222
234
|
} else {
|
|
223
235
|
const error = new ValidupValidatorError({
|
|
224
236
|
path,
|
|
@@ -230,8 +242,8 @@ class Container {
|
|
|
230
242
|
error.message = e.message;
|
|
231
243
|
}
|
|
232
244
|
errors.push(error);
|
|
245
|
+
errorKeys.push(pathAbsolute);
|
|
233
246
|
}
|
|
234
|
-
errorKeys.push(pathAbsolute);
|
|
235
247
|
}
|
|
236
248
|
pathsCount++;
|
|
237
249
|
}
|
|
@@ -318,5 +330,5 @@ class Container {
|
|
|
318
330
|
}
|
|
319
331
|
}
|
|
320
332
|
|
|
321
|
-
export { Container, GroupKey, OptionalValue, ValidupError, ValidupNestedError, ValidupValidatorError, buildErrorMessageForAttributes, hasOwnProperty, isObject, isOptionalValue };
|
|
333
|
+
export { Container, GroupKey, OptionalValue, ValidupError, ValidupNestedError, ValidupValidatorError, buildErrorMessageForAttribute, buildErrorMessageForAttributes, hasOwnProperty, isObject, isOptionalValue };
|
|
322
334
|
//# sourceMappingURL=index.mjs.map
|
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/errors/validator.ts","../src/errors/base.ts","../src/errors/nested.ts","../src/utils/has-own-property.ts","../src/utils/object.ts","../src/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 buildErrorMessageForAttributes(input: (number | string)[] | Record<string, any>) {\n let names: string[];\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 'An unexpected error occurred.';\n }\n\n if (names.length > 1) {\n return `The attributes ${names.join(', ')} are invalid.`;\n }\n\n return `The attribute ${String(names[0])} is invalid.`;\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;\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\nexport type ValidupValidatorErrorOptions = {\n path: string,\n pathAbsolute?: string,\n message?: string,\n code?: string | null,\n received?: unknown,\n expected?: unknown\n};\n\nexport class ValidupValidatorError extends Error {\n readonly path: string;\n\n readonly pathAbsolute : string;\n\n readonly code?: string | null;\n\n readonly received?: unknown;\n\n readonly expected?: unknown;\n\n constructor(options: ValidupValidatorErrorOptions) {\n super(options.message);\n\n this.path = options.path;\n this.pathAbsolute = options.pathAbsolute ?? options.path;\n this.code = options.code;\n this.received = options.received;\n this.expected = options.expected;\n }\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\nexport class ValidupError extends Error {\n\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 { ValidupValidatorError } from './validator';\nimport { ValidupError } from './base';\n\nexport type ValidupNestedErrorOptions = {\n children?: ValidupValidatorError[],\n message?: string\n};\n\nexport class ValidupNestedError extends ValidupError {\n children: ValidupValidatorError[];\n\n constructor(options: ValidupNestedErrorOptions = {}) {\n super(options.message || 'One or many attributes may be invalid.');\n\n this.children = options.children || [];\n }\n\n addChild(child: ValidupValidatorError) {\n this.children.push(child);\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) 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 { expandPath, getPathValue, setPathValue } from 'pathtrace';\nimport { GroupKey } from './constants';\nimport { ValidupNestedError, ValidupValidatorError } from './errors';\nimport { buildErrorMessageForAttributes, isOptionalValue } from './helpers';\nimport type {\n ContainerItem,\n ContainerMountOptions,\n ContainerOptions,\n ContainerRunOptions,\n ObjectPropertyPath,\n ObjectPropertyPathExtended,\n Validator,\n} from './types';\nimport { hasOwnProperty, isObject } from './utils';\n\nexport class Container<\n T extends Record<string, any> = Record<string, any>,\n> {\n protected options : ContainerOptions<T>;\n\n protected items : ContainerItem[];\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: Container) : void;\n\n mount(\n options: ContainerMountOptions,\n container: Container\n ): void;\n\n mount(\n key: ObjectPropertyPathExtended<T>,\n data: Container | Validator\n ) : void;\n\n mount(\n key: ObjectPropertyPathExtended<T>,\n options: ContainerMountOptions,\n data: Container | 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: Container | Validator | undefined;\n let dataIsContainer : boolean = false;\n\n let options: ContainerMountOptions = {};\n\n for (let i = 0; i < args.length; i++) {\n if (typeof args[i] === 'string') {\n path = args[i];\n continue;\n }\n\n if (typeof args[i] === 'function') {\n data = args[i];\n continue;\n }\n\n if (args[i] instanceof Container) {\n data = args[i];\n dataIsContainer = true;\n continue;\n }\n\n if (isObject(args[i])) {\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 this.items.push({\n ...options,\n data,\n path,\n });\n }\n\n // ----------------------------------------------\n\n async run(\n data: Record<string, any> = {},\n options: ContainerRunOptions<T> = {},\n ): Promise<T> {\n const output: Record<string, any> = {};\n\n const errors: ValidupValidatorError[] = [];\n const errorKeys : string[] = [];\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 itemCount = 0;\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 continue;\n }\n\n let pathsCount = 0;\n\n let paths : string[];\n if (item.path) {\n paths = expandPath(data, item.path);\n } else {\n paths = [''];\n }\n\n for (let j = 0; j < paths.length; j++) {\n const path = paths[j];\n const pathAbsolute = this.mergePaths(options.path, paths[j]);\n\n let value : unknown;\n if (hasOwnProperty(output, path)) {\n value = output[path];\n } else if (path.length > 0) {\n value = getPathValue(data, path);\n } else {\n value = data;\n }\n\n if (\n typeof pathsToInclude !== 'undefined' &&\n pathsToInclude.indexOf(path) === -1\n ) {\n continue;\n }\n\n try {\n if (item.data instanceof Container) {\n if (\n item.optional &&\n isOptionalValue(value, item.optionalValue)\n ) {\n if (item.optionalInclude) {\n output[path] = value;\n }\n } else {\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(path, tmpKeys[k])] = tmp[tmpKeys[k]];\n }\n }\n } else {\n output[path] = await item.data({\n path,\n pathRaw: item.path ?? '',\n\n pathAbsolute,\n value,\n data,\n });\n }\n } catch (e) {\n if (e instanceof ValidupValidatorError) {\n errors.push(e);\n } else if (e instanceof ValidupNestedError) {\n errors.push(...e.children);\n } else {\n const error = new ValidupValidatorError({\n path,\n pathAbsolute,\n received: value,\n });\n\n if (e instanceof Error) {\n error.cause = e;\n error.message = e.message;\n }\n\n errors.push(error);\n }\n\n errorKeys.push(pathAbsolute);\n }\n\n pathsCount++;\n }\n\n if (pathsCount > 0) {\n itemCount++;\n }\n }\n\n if (this.options.oneOf) {\n if (errors.length === itemCount) {\n throw new ValidupNestedError({ message: buildErrorMessageForAttributes(errorKeys), children: errors });\n }\n } else if (errors.length > 0) {\n throw new ValidupNestedError({ message: buildErrorMessageForAttributes(errorKeys), children: errors });\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 ObjectPropertyPath<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: ContainerItem,\n group?: string,\n ) : boolean {\n if (group === GroupKey.WILDCARD) {\n return true;\n }\n\n if (item.group) {\n if (Array.isArray(item.group)) {\n if (item.group.indexOf(GroupKey.WILDCARD) !== -1) {\n return true;\n }\n\n if (group && item.group.indexOf(group) !== -1) {\n return true;\n }\n } else {\n if (item.group === GroupKey.WILDCARD) {\n return true;\n }\n\n if (item.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":["buildErrorMessageForAttributes","input","names","Array","isArray","distinctArray","Object","keys","length","join","String","GroupKey","OptionalValue","isOptionalValue","value","optionalValue","optionValueNormalized","UNDEFINED","NULL","ValidupValidatorError","Error","constructor","options","message","path","pathAbsolute","code","received","expected","ValidupError","ValidupNestedError","addChild","child","children","push","hasOwnProperty","obj","prop","prototype","call","isObject","Container","mount","args","SyntaxError","data","dataIsContainer","i","items","run","output","errors","errorKeys","pathsToInclude","itemCount","item","isItemGroupIncluded","group","pathsCount","paths","expandPath","j","mergePaths","getPathValue","indexOf","optional","optionalInclude","tmp","flat","tmpKeys","k","pathRaw","e","error","cause","oneOf","defaults","defaultKeys","temp","setPathValue","WILDCARD","arg","at","initialize"],"mappings":";;;AASO,SAASA,+BAA+BC,KAAgD,EAAA;IAC3F,IAAIC,KAAAA,CAAAA;IACJ,IAAIC,KAAAA,CAAMC,OAAO,CAACH,KAAQ,CAAA,EAAA;AACtBC,QAAAA,KAAAA,GAAQG,aAAcJ,CAAAA,KAAAA,CAAAA,CAAAA;KACnB,MAAA;QACHC,KAAQI,GAAAA,MAAAA,CAAOC,IAAI,CAACN,KAAAA,CAAAA,CAAAA;AACxB,KAAA;IAEA,IAAIC,KAAAA,CAAMM,MAAM,KAAK,CAAG,EAAA;QACpB,OAAO,+BAAA,CAAA;AACX,KAAA;IAEA,IAAIN,KAAAA,CAAMM,MAAM,GAAG,CAAG,EAAA;QAClB,OAAO,CAAC,eAAe,EAAEN,KAAAA,CAAMO,IAAI,CAAC,IAAA,CAAA,CAAM,aAAa,CAAC,CAAA;AAC5D,KAAA;IAEA,OAAO,CAAC,cAAc,EAAEC,MAAAA,CAAOR,KAAK,CAAC,CAAA,CAAE,CAAE,CAAA,YAAY,CAAC,CAAA;AAC1D;;AC1BA;;;;;AAKC,IAAA,IAAA,SAAA;AAEWS,CAAAA,SAAAA,QAAAA,EAAAA;;GAAAA,QAAAA,KAAAA,QAAAA,GAAAA,EAAAA,CAAAA,CAAAA,CAAAA;;AAIAC,CAAAA,SAAAA,aAAAA,EAAAA;AACR;;AAEC,QAAA,aAAA,CAAA,WAAA,CAAA,GAAA,WAAA,CAAA;AAED;;AAEC,QAAA,aAAA,CAAA,MAAA,CAAA,GAAA,MAAA,CAAA;AAED;;AAEC,QAAA,aAAA,CAAA,OAAA,CAAA,GAAA,OAAA,CAAA;GAXOA,aAAAA,KAAAA,a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AAA,CAAA;AAEtB,QAAA,IAAK,IAAIH,CAAI,GAAA,CAAA,EAAGA,IAAIJ,IAAKnC,CAAAA,MAAM,EAAEuC,CAAK,EAAA,CAAA;YAClC,MAAMkC,GAAAA,GAAMtC,IAAI,CAACI,CAAE,CAAA,CAAA;AACnB,YAAA,IAAI,CAACkC,GAAAA,IAAOA,GAAIzE,CAAAA,MAAM,KAAK,CAAG,EAAA;AAC1B,gBAAA,SAAA;AACJ,aAAA;AAEA,YAAA,IAAIyE,GAAIC,CAAAA,EAAE,CAAC,CAAA,CAAA,KAAO,GAAK,EAAA;gBACnBhC,MAAU+B,IAAAA,GAAAA,CAAAA;aACP,MAAA;gBACH/B,MAAUA,IAAAA,MAAAA,CAAO1C,MAAM,GAAG,CAAA,GAAI,CAAC,CAAC,EAAEyE,GAAI,CAAA,CAAC,GAAGA,GAAAA,CAAAA;AAC9C,aAAA;AACJ,SAAA;QAEA,OAAO/B,MAAAA,CAAAA;AACX,KAAA;AAEUiC,IAAAA,UAAAA,GAAoB,EAE9B;;IAjSA9D,WAAYC,CAAAA,OAAAA,GAA+B,EAAE,CAAE;QAC3C,IAAI,CAACA,OAAO,GAAGA,OAAAA,CAAAA;QACf,IAAI,CAAC0B,KAAK,GAAG,EAAE,CAAA;AAEf,QAAA,IAAI,CAACmC,UAAU,EAAA,CAAA;AACnB,KAAA;AA6RJ;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/helpers/error.ts","../src/constants.ts","../src/helpers/optional-value.ts","../src/errors/base.ts","../src/errors/validator.ts","../src/errors/nested.ts","../src/utils/has-own-property.ts","../src/utils/object.ts","../src/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: string | number) {\n return `The attribute ${String(key)} is invalid.`;\n}\n\nexport function buildErrorMessageForAttributes(input: (number | string)[] | Record<string, any>) {\n let names: string[];\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 'An unexpected error occurred.';\n }\n\n if (names.length > 1) {\n return `The attributes ${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\nexport class ValidupError extends Error {\n\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 { ValidupError } from './base';\n\nexport type ValidupValidatorErrorOptions = {\n path: string,\n pathAbsolute?: string,\n message?: string,\n code?: string | null,\n received?: unknown,\n expected?: unknown\n};\n\nexport class ValidupValidatorError extends ValidupError {\n readonly path: string;\n\n readonly pathAbsolute : string;\n\n readonly code?: string | null;\n\n readonly received?: unknown;\n\n readonly expected?: unknown;\n\n constructor(options: ValidupValidatorErrorOptions) {\n super(options.message);\n\n this.path = options.path;\n this.pathAbsolute = options.pathAbsolute ?? options.path;\n this.code = options.code;\n this.received = options.received;\n this.expected = options.expected;\n }\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 { ValidupValidatorError } from './validator';\nimport { ValidupError } from './base';\n\nexport type ValidupNestedErrorOptions = {\n children?: ValidupValidatorError[],\n message?: string\n};\n\nexport class ValidupNestedError extends ValidupError {\n readonly children: ValidupValidatorError[];\n\n constructor(options: ValidupNestedErrorOptions = {}) {\n super(options.message || 'One or many attributes may be invalid.');\n\n this.children = options.children || [];\n }\n\n addChild(child: ValidupValidatorError) {\n this.children.push(child);\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) 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 { expandPath, getPathValue, setPathValue } from 'pathtrace';\nimport { GroupKey } from './constants';\nimport { ValidupNestedError, ValidupValidatorError } from './errors';\nimport { buildErrorMessageForAttributes, isOptionalValue } from './helpers';\nimport type {\n ContainerItem,\n ContainerMountOptions,\n ContainerOptions,\n ContainerRunOptions,\n ObjectPropertyPath,\n ObjectPropertyPathExtended,\n Validator,\n} from './types';\nimport { hasOwnProperty, isObject } from './utils';\n\nexport class Container<\n T extends Record<string, any> = Record<string, any>,\n> {\n protected options : ContainerOptions<T>;\n\n protected items : ContainerItem[];\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: Container) : void;\n\n mount(\n options: ContainerMountOptions,\n container: Container\n ): void;\n\n mount(\n key: ObjectPropertyPathExtended<T>,\n data: Container | Validator\n ) : void;\n\n mount(\n key: ObjectPropertyPathExtended<T>,\n options: ContainerMountOptions,\n data: Container | 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: Container | Validator | undefined;\n let dataIsContainer : boolean = false;\n\n let options: ContainerMountOptions = {};\n\n for (let i = 0; i < args.length; i++) {\n if (typeof args[i] === 'string') {\n path = args[i];\n continue;\n }\n\n if (typeof args[i] === 'function') {\n data = args[i];\n continue;\n }\n\n if (args[i] instanceof Container) {\n data = args[i];\n dataIsContainer = true;\n continue;\n }\n\n if (isObject(args[i])) {\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 this.items.push({\n ...options,\n data,\n path,\n });\n }\n\n // ----------------------------------------------\n\n async run(\n data: Record<string, any> = {},\n options: ContainerRunOptions<T> = {},\n ): Promise<T> {\n const output: Record<string, any> = {};\n\n const errors: ValidupValidatorError[] = [];\n const errorKeys : string[] = [];\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.pathsToInclude) {\n pathsToExclude = this.options.pathsToExclude as string[];\n }\n\n let itemCount = 0;\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 continue;\n }\n\n let pathsCount = 0;\n\n let paths : string[];\n if (item.path) {\n paths = expandPath(data, item.path);\n } else {\n paths = [''];\n }\n\n for (let j = 0; j < paths.length; j++) {\n const path = paths[j];\n const pathAbsolute = this.mergePaths(options.path, paths[j]);\n\n let value : unknown;\n if (hasOwnProperty(output, path)) {\n value = output[path];\n } else if (path.length > 0) {\n value = getPathValue(data, path);\n } else {\n value = data;\n }\n\n if (\n typeof pathsToInclude !== 'undefined' &&\n pathsToInclude.indexOf(path) === -1\n ) {\n continue;\n }\n\n if (\n typeof pathsToExclude !== 'undefined' &&\n pathsToExclude.indexOf(path) !== -1\n ) {\n continue;\n }\n\n try {\n if (\n item.optional &&\n isOptionalValue(value, item.optionalValue)\n ) {\n if (item.optionalInclude) {\n output[path] = value;\n }\n } else if (item.data instanceof 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(path, tmpKeys[k])] = tmp[tmpKeys[k]];\n }\n } else {\n output[path] = await item.data({\n path,\n pathRaw: item.path ?? '',\n\n pathAbsolute,\n value,\n data,\n group: options.group,\n });\n }\n } catch (e) {\n if (e instanceof ValidupValidatorError) {\n errors.push(e);\n errorKeys.push(pathAbsolute);\n } else if (e instanceof ValidupNestedError) {\n errors.push(...e.children);\n\n if (pathAbsolute.length > 0) {\n errorKeys.push(pathAbsolute);\n } else {\n errorKeys.push(...e.children.map((child) => child.pathAbsolute));\n }\n } else {\n const error = new ValidupValidatorError({\n path,\n pathAbsolute,\n received: value,\n });\n\n if (e instanceof Error) {\n error.cause = e;\n error.message = e.message;\n }\n\n errors.push(error);\n errorKeys.push(pathAbsolute);\n }\n }\n\n pathsCount++;\n }\n\n if (pathsCount > 0) {\n itemCount++;\n }\n }\n\n if (this.options.oneOf) {\n if (errors.length === itemCount) {\n throw new ValidupNestedError({ message: buildErrorMessageForAttributes(errorKeys), children: errors });\n }\n } else if (errors.length > 0) {\n throw new ValidupNestedError({ message: buildErrorMessageForAttributes(errorKeys), children: errors });\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 ObjectPropertyPath<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: ContainerItem,\n group?: string,\n ) : boolean {\n if (group === GroupKey.WILDCARD) {\n return true;\n }\n\n if (item.group) {\n if (Array.isArray(item.group)) {\n if (item.group.indexOf(GroupKey.WILDCARD) !== -1) {\n return true;\n }\n\n if (group && item.group.indexOf(group) !== -1) {\n return true;\n }\n } else {\n if (item.group === GroupKey.WILDCARD) {\n return true;\n }\n\n if (item.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","ValidupValidatorError","options","message","path","pathAbsolute","code","received","expected","ValidupNestedError","addChild","child","children","push","hasOwnProperty","obj","prop","prototype","call","isObject","Container","mount","args","SyntaxError","data","dataIsContainer","i","items","run","output","errors","errorKeys","pathsToInclude","pathsToExclude","itemCount","item","isItemGroupIncluded","group","pathsCount","paths","expandPath","j","mergePaths","getPathValue","indexOf","optional","optionalInclude","tmp","flat","tmpKeys","k","pathRaw","e","map","error","cause","oneOf","defaults","defaultKeys","temp","setPathValue","WILDCARD","arg","at","initialize"],"mappings":";;;AASO,SAASA,8BAA8BC,GAAoB,EAAA;AAC9D,IAAA,OAAO,CAAC,cAAc,EAAEC,MAAAA,CAAOD,GAAAA,CAAAA,CAAK,YAAY,CAAC;AACrD;AAEO,SAASE,+BAA+BC,KAAgD,EAAA;IAC3F,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,+BAAA;AACX,IAAA;IAEA,IAAIN,KAAAA,CAAMM,MAAM,GAAG,CAAA,EAAG;QAClB,OAAO,CAAC,eAAe,EAAEN,KAAAA,CAAMO,IAAI,CAAC,IAAA,CAAA,CAAM,aAAa,CAAC;AAC5D,IAAA;IAEA,OAAOZ,6BAAAA,CAA8BK,KAAK,CAAC,CAAA,CAAE,CAAA;AACjD;;AC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A;AAEUmC,IAAAA,UAAAA,GAAoB,CAE9B;;IApTA,WAAA,CAAY9D,OAAAA,GAA+B,EAAE,CAAE;QAC3C,IAAI,CAACA,OAAO,GAAGA,OAAAA;QACf,IAAI,CAACyB,KAAK,GAAG,EAAE;AAEf,QAAA,IAAI,CAACqC,UAAU,EAAA;AACnB,IAAA;AAgTJ;;;;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ export type ContainerOptions<T> = {
|
|
|
12
12
|
* be considered for execution.
|
|
13
13
|
*/
|
|
14
14
|
pathsToInclude?: ObjectPropertyPath<T>[];
|
|
15
|
+
/**
|
|
16
|
+
* Exclude mounted paths on execution.
|
|
17
|
+
* By default, all mounted containers/validators will
|
|
18
|
+
* be considered for execution.
|
|
19
|
+
*/
|
|
20
|
+
pathsToExclude?: ObjectPropertyPath<T>[];
|
|
15
21
|
};
|
|
16
22
|
export type ContainerRunOptions<T extends Record<string, any> = Record<string, any>> = {
|
|
17
23
|
/**
|
|
@@ -38,6 +44,12 @@ export type ContainerRunOptions<T extends Record<string, any> = Record<string, a
|
|
|
38
44
|
* be considered for execution.
|
|
39
45
|
*/
|
|
40
46
|
pathsToInclude?: ObjectPropertyPath<T>[];
|
|
47
|
+
/**
|
|
48
|
+
* Exclude mounted paths on execution.
|
|
49
|
+
* By default, all mounted containers/validators will
|
|
50
|
+
* be considered for execution.
|
|
51
|
+
*/
|
|
52
|
+
pathsToExclude?: ObjectPropertyPath<T>[];
|
|
41
53
|
};
|
|
42
54
|
export type ValidatorContext = {
|
|
43
55
|
/**
|
|
@@ -60,6 +72,10 @@ export type ValidatorContext = {
|
|
|
60
72
|
* The input data of the current container.
|
|
61
73
|
*/
|
|
62
74
|
data: Record<string, any>;
|
|
75
|
+
/**
|
|
76
|
+
* The group name for which the validator is executed.
|
|
77
|
+
*/
|
|
78
|
+
group?: string;
|
|
63
79
|
};
|
|
64
80
|
export type Validator = (ctx: ValidatorContext) => Promise<unknown> | unknown;
|
|
65
81
|
export type ContainerMountOptions = {
|
|
@@ -68,13 +84,8 @@ export type ContainerMountOptions = {
|
|
|
68
84
|
*/
|
|
69
85
|
group?: string | string[];
|
|
70
86
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* be considered for execution.
|
|
74
|
-
*/
|
|
75
|
-
pathsToInclude?: string[];
|
|
76
|
-
/**
|
|
77
|
-
* Specify if the mounted container has to be evaluated successfully.
|
|
87
|
+
* Specify if an optional value is also acceptable for the mount key.
|
|
88
|
+
* An optional value won't be passed to the underlying container/validator.
|
|
78
89
|
*
|
|
79
90
|
* default: false
|
|
80
91
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "validup",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "A validation library.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Peter Placzek",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"keywords": [],
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"pathtrace": "^1.
|
|
43
|
+
"pathtrace": "^1.1.0",
|
|
44
44
|
"smob": "^1.5.0"
|
|
45
45
|
}
|
|
46
46
|
}
|