@amazon/vinyl-validation 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1325 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +1308 -0
- package/dist/index.js.map +7 -0
- package/dist/types/current/index.d.ts +18 -0
- package/dist/types/current/index.d.ts.map +1 -0
- package/dist/types/current/index.js +17 -0
- package/dist/types/current/tsconfig.tsbuildinfo +1 -0
- package/dist/types/current/validation/ArraySchema.d.ts +82 -0
- package/dist/types/current/validation/ArraySchema.d.ts.map +1 -0
- package/dist/types/current/validation/ArraySchema.js +148 -0
- package/dist/types/current/validation/FunctionSchema.d.ts +21 -0
- package/dist/types/current/validation/FunctionSchema.d.ts.map +1 -0
- package/dist/types/current/validation/FunctionSchema.js +42 -0
- package/dist/types/current/validation/NumberSchema.d.ts +100 -0
- package/dist/types/current/validation/NumberSchema.d.ts.map +1 -0
- package/dist/types/current/validation/NumberSchema.js +146 -0
- package/dist/types/current/validation/ObjectSchema.d.ts +54 -0
- package/dist/types/current/validation/ObjectSchema.d.ts.map +1 -0
- package/dist/types/current/validation/ObjectSchema.js +125 -0
- package/dist/types/current/validation/PropertyValidator.d.ts +23 -0
- package/dist/types/current/validation/PropertyValidator.d.ts.map +1 -0
- package/dist/types/current/validation/PropertyValidator.js +5 -0
- package/dist/types/current/validation/RecordSchema.d.ts +58 -0
- package/dist/types/current/validation/RecordSchema.d.ts.map +1 -0
- package/dist/types/current/validation/RecordSchema.js +101 -0
- package/dist/types/current/validation/SchemaBase.d.ts +65 -0
- package/dist/types/current/validation/SchemaBase.d.ts.map +1 -0
- package/dist/types/current/validation/SchemaBase.js +90 -0
- package/dist/types/current/validation/SetSchema.d.ts +38 -0
- package/dist/types/current/validation/SetSchema.d.ts.map +1 -0
- package/dist/types/current/validation/SetSchema.js +74 -0
- package/dist/types/current/validation/StringSchema.d.ts +68 -0
- package/dist/types/current/validation/StringSchema.d.ts.map +1 -0
- package/dist/types/current/validation/StringSchema.js +109 -0
- package/dist/types/current/validation/Validator.d.ts +88 -0
- package/dist/types/current/validation/Validator.d.ts.map +1 -0
- package/dist/types/current/validation/Validator.js +95 -0
- package/dist/types/current/validation/ValidatorWithPartial.d.ts +26 -0
- package/dist/types/current/validation/ValidatorWithPartial.d.ts.map +1 -0
- package/dist/types/current/validation/ValidatorWithPartial.js +31 -0
- package/dist/types/current/validation/ValueSchema.d.ts +52 -0
- package/dist/types/current/validation/ValueSchema.d.ts.map +1 -0
- package/dist/types/current/validation/ValueSchema.js +81 -0
- package/dist/types/current/validation/andValidators.d.ts +19 -0
- package/dist/types/current/validation/andValidators.d.ts.map +1 -0
- package/dist/types/current/validation/andValidators.js +48 -0
- package/dist/types/current/validation/orValidators.d.ts +19 -0
- package/dist/types/current/validation/orValidators.d.ts.map +1 -0
- package/dist/types/current/validation/orValidators.js +74 -0
- package/dist/types/current/validation/typeOfValidators.d.ts +15 -0
- package/dist/types/current/validation/typeOfValidators.d.ts.map +1 -0
- package/dist/types/current/validation/typeOfValidators.js +58 -0
- package/dist/types/current/validation/validators.d.ts +127 -0
- package/dist/types/current/validation/validators.d.ts.map +1 -0
- package/dist/types/current/validation/validators.js +168 -0
- package/dist/types/ts3.7/index.d.ts +18 -0
- package/dist/types/ts3.7/validation/ArraySchema.d.ts +86 -0
- package/dist/types/ts3.7/validation/FunctionSchema.d.ts +21 -0
- package/dist/types/ts3.7/validation/NumberSchema.d.ts +100 -0
- package/dist/types/ts3.7/validation/ObjectSchema.d.ts +56 -0
- package/dist/types/ts3.7/validation/PropertyValidator.d.ts +23 -0
- package/dist/types/ts3.7/validation/RecordSchema.d.ts +58 -0
- package/dist/types/ts3.7/validation/SchemaBase.d.ts +65 -0
- package/dist/types/ts3.7/validation/SetSchema.d.ts +38 -0
- package/dist/types/ts3.7/validation/StringSchema.d.ts +68 -0
- package/dist/types/ts3.7/validation/Validator.d.ts +88 -0
- package/dist/types/ts3.7/validation/ValidatorWithPartial.d.ts +26 -0
- package/dist/types/ts3.7/validation/ValueSchema.d.ts +52 -0
- package/dist/types/ts3.7/validation/andValidators.d.ts +19 -0
- package/dist/types/ts3.7/validation/orValidators.d.ts +19 -0
- package/dist/types/ts3.7/validation/typeOfValidators.d.ts +15 -0
- package/dist/types/ts3.7/validation/validators.d.ts +127 -0
- package/dist/types/ts4.1/index.d.ts +18 -0
- package/dist/types/ts4.1/validation/ArraySchema.d.ts +86 -0
- package/dist/types/ts4.1/validation/FunctionSchema.d.ts +21 -0
- package/dist/types/ts4.1/validation/NumberSchema.d.ts +100 -0
- package/dist/types/ts4.1/validation/ObjectSchema.d.ts +56 -0
- package/dist/types/ts4.1/validation/PropertyValidator.d.ts +23 -0
- package/dist/types/ts4.1/validation/RecordSchema.d.ts +58 -0
- package/dist/types/ts4.1/validation/SchemaBase.d.ts +65 -0
- package/dist/types/ts4.1/validation/SetSchema.d.ts +38 -0
- package/dist/types/ts4.1/validation/StringSchema.d.ts +68 -0
- package/dist/types/ts4.1/validation/Validator.d.ts +88 -0
- package/dist/types/ts4.1/validation/ValidatorWithPartial.d.ts +26 -0
- package/dist/types/ts4.1/validation/ValueSchema.d.ts +52 -0
- package/dist/types/ts4.1/validation/andValidators.d.ts +19 -0
- package/dist/types/ts4.1/validation/orValidators.d.ts +19 -0
- package/dist/types/ts4.1/validation/typeOfValidators.d.ts +15 -0
- package/dist/types/ts4.1/validation/validators.d.ts +128 -0
- package/dist/types/ts4.7/index.d.ts +18 -0
- package/dist/types/ts4.7/validation/ArraySchema.d.ts +86 -0
- package/dist/types/ts4.7/validation/FunctionSchema.d.ts +21 -0
- package/dist/types/ts4.7/validation/NumberSchema.d.ts +100 -0
- package/dist/types/ts4.7/validation/ObjectSchema.d.ts +56 -0
- package/dist/types/ts4.7/validation/PropertyValidator.d.ts +23 -0
- package/dist/types/ts4.7/validation/RecordSchema.d.ts +58 -0
- package/dist/types/ts4.7/validation/SchemaBase.d.ts +65 -0
- package/dist/types/ts4.7/validation/SetSchema.d.ts +38 -0
- package/dist/types/ts4.7/validation/StringSchema.d.ts +68 -0
- package/dist/types/ts4.7/validation/Validator.d.ts +88 -0
- package/dist/types/ts4.7/validation/ValidatorWithPartial.d.ts +26 -0
- package/dist/types/ts4.7/validation/ValueSchema.d.ts +52 -0
- package/dist/types/ts4.7/validation/andValidators.d.ts +19 -0
- package/dist/types/ts4.7/validation/orValidators.d.ts +19 -0
- package/dist/types/ts4.7/validation/typeOfValidators.d.ts +15 -0
- package/dist/types/ts4.7/validation/validators.d.ts +127 -0
- package/docs/VALIDATION.md +344 -0
- package/package.json +82 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1325 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __export = (target, all) => {
|
|
24
|
+
for (var name in all)
|
|
25
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
+
};
|
|
27
|
+
var __copyProps = (to, from, except, desc) => {
|
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
+
for (let key of __getOwnPropNames(from))
|
|
30
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
+
}
|
|
33
|
+
return to;
|
|
34
|
+
};
|
|
35
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
37
|
+
|
|
38
|
+
// src/index.ts
|
|
39
|
+
var index_exports = {};
|
|
40
|
+
__export(index_exports, {
|
|
41
|
+
ArraySchema: () => ArraySchema,
|
|
42
|
+
FunctionSchema: () => FunctionSchema,
|
|
43
|
+
NumberSchema: () => NumberSchema,
|
|
44
|
+
ObjectSchema: () => ObjectSchema,
|
|
45
|
+
RecordSchema: () => RecordSchema,
|
|
46
|
+
SchemaBase: () => SchemaBase,
|
|
47
|
+
SetSchema: () => SetSchema,
|
|
48
|
+
StringSchema: () => StringSchema,
|
|
49
|
+
ValueSchema: () => ValueSchema,
|
|
50
|
+
andValidators: () => andValidators,
|
|
51
|
+
any: () => any,
|
|
52
|
+
array: () => array,
|
|
53
|
+
arrayValidators: () => arrayValidators,
|
|
54
|
+
boolean: () => boolean,
|
|
55
|
+
createDeepValidator: () => createDeepValidator,
|
|
56
|
+
createValidationExpectationMessage: () => createValidationExpectationMessage,
|
|
57
|
+
createValidator: () => createValidator,
|
|
58
|
+
custom: () => custom,
|
|
59
|
+
enumOf: () => enumOf,
|
|
60
|
+
exactlyNull: () => exactlyNull,
|
|
61
|
+
exactlyUndefined: () => exactlyUndefined,
|
|
62
|
+
func: () => func,
|
|
63
|
+
functionValidators: () => functionValidators,
|
|
64
|
+
instanceOf: () => instanceOf,
|
|
65
|
+
isOneOf: () => isOneOf,
|
|
66
|
+
isValidatorWithPartial: () => isValidatorWithPartial,
|
|
67
|
+
maybeToDeepPartial: () => maybeToDeepPartial,
|
|
68
|
+
maybeToPartial: () => maybeToPartial,
|
|
69
|
+
nullish: () => nullish,
|
|
70
|
+
number: () => number,
|
|
71
|
+
numberValidators: () => numberValidators,
|
|
72
|
+
object: () => object,
|
|
73
|
+
objectValidators: () => objectValidators,
|
|
74
|
+
orValidators: () => orValidators,
|
|
75
|
+
record: () => record,
|
|
76
|
+
recordValidators: () => recordValidators,
|
|
77
|
+
recordValues: () => recordValues,
|
|
78
|
+
set: () => set,
|
|
79
|
+
setValidators: () => setValidators,
|
|
80
|
+
string: () => string,
|
|
81
|
+
stringValidators: () => stringValidators,
|
|
82
|
+
symbol: () => symbol,
|
|
83
|
+
tuple: () => tuple,
|
|
84
|
+
typeOfValidators: () => typeOfValidators,
|
|
85
|
+
valueValidators: () => valueValidators
|
|
86
|
+
});
|
|
87
|
+
module.exports = __toCommonJS(index_exports);
|
|
88
|
+
|
|
89
|
+
// src/validation/validators.ts
|
|
90
|
+
var import_vinyl_util14 = require("@amazon/vinyl-util");
|
|
91
|
+
|
|
92
|
+
// src/validation/ArraySchema.ts
|
|
93
|
+
var import_vinyl_util6 = require("@amazon/vinyl-util");
|
|
94
|
+
|
|
95
|
+
// src/validation/andValidators.ts
|
|
96
|
+
var import_vinyl_util3 = require("@amazon/vinyl-util");
|
|
97
|
+
|
|
98
|
+
// src/validation/Validator.ts
|
|
99
|
+
var import_vinyl_util = require("@amazon/vinyl-util");
|
|
100
|
+
var import_vinyl_util2 = require("@amazon/vinyl-util");
|
|
101
|
+
var validatorLocale = {
|
|
102
|
+
/**
|
|
103
|
+
* The expectation template string with the following replacement tokens:
|
|
104
|
+
*
|
|
105
|
+
* `{expected}` - The expected description.
|
|
106
|
+
* `{actual}` - The actual value.
|
|
107
|
+
* `{path}` - The path, dot separated.
|
|
108
|
+
*/
|
|
109
|
+
template: "Expected: {expected}, but was: {actual}. At: {path}"
|
|
110
|
+
};
|
|
111
|
+
function createValidationExpectationMessage(expectationMessage, input, path, inputStringify = (input2) => (0, import_vinyl_util2.stringifyForPrint)(input2, 500)) {
|
|
112
|
+
return (0, import_vinyl_util2.substitute)(validatorLocale.template, {
|
|
113
|
+
expected: expectationMessage,
|
|
114
|
+
actual: inputStringify(input),
|
|
115
|
+
path: path.join(".")
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function createValidator(expectationMessage, isValid, inputStringify = (input) => (0, import_vinyl_util2.stringifyForPrint)(input, 500)) {
|
|
119
|
+
return {
|
|
120
|
+
description: expectationMessage,
|
|
121
|
+
isValid(input) {
|
|
122
|
+
return isValid(input);
|
|
123
|
+
},
|
|
124
|
+
validate(input, _, path = []) {
|
|
125
|
+
if (!isValid(input)) {
|
|
126
|
+
return [
|
|
127
|
+
{
|
|
128
|
+
message: createValidationExpectationMessage(
|
|
129
|
+
expectationMessage,
|
|
130
|
+
input,
|
|
131
|
+
path,
|
|
132
|
+
inputStringify
|
|
133
|
+
),
|
|
134
|
+
path
|
|
135
|
+
}
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
return [];
|
|
139
|
+
},
|
|
140
|
+
assert: (input, origin, path = []) => {
|
|
141
|
+
if (!isValid(input)) {
|
|
142
|
+
throw new import_vinyl_util.ValidationError(
|
|
143
|
+
createValidationExpectationMessage(
|
|
144
|
+
expectationMessage,
|
|
145
|
+
input,
|
|
146
|
+
path,
|
|
147
|
+
inputStringify
|
|
148
|
+
),
|
|
149
|
+
origin,
|
|
150
|
+
path
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function createDeepValidator(description, validate) {
|
|
157
|
+
return {
|
|
158
|
+
description,
|
|
159
|
+
isValid(input) {
|
|
160
|
+
return validate(input, { all: false }, []).length === 0;
|
|
161
|
+
},
|
|
162
|
+
validate(input, options, path = []) {
|
|
163
|
+
return validate(input, options != null ? options : { all: false }, path);
|
|
164
|
+
},
|
|
165
|
+
assert: (input, origin, path = []) => {
|
|
166
|
+
const errors = validate(input, { all: false }, path);
|
|
167
|
+
if (errors.length) {
|
|
168
|
+
const error = errors[0];
|
|
169
|
+
throw new import_vinyl_util.ValidationError(error.message, origin, error.path);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/validation/andValidators.ts
|
|
176
|
+
var locale = {
|
|
177
|
+
/**
|
|
178
|
+
* {value} The child validators' descriptions, joined with `separator`.
|
|
179
|
+
*
|
|
180
|
+
* groupings of and validators is unimportant,
|
|
181
|
+
* and(and(a, b), c) is the same as and(a, and(b, c)), so `a & b & c` is an accurate
|
|
182
|
+
* representation for either.
|
|
183
|
+
*/
|
|
184
|
+
template: "{value}",
|
|
185
|
+
/**
|
|
186
|
+
* The separator with which to join child validator descriptions.
|
|
187
|
+
*/
|
|
188
|
+
separator: " & "
|
|
189
|
+
};
|
|
190
|
+
function andValidators(...validators) {
|
|
191
|
+
return createDeepValidator(
|
|
192
|
+
(0, import_vinyl_util3.substitute)(locale.template, {
|
|
193
|
+
value: validators.map((v) => v.description).join(locale.separator)
|
|
194
|
+
}),
|
|
195
|
+
(input, options, path) => {
|
|
196
|
+
for (const validator of validators) {
|
|
197
|
+
const errors = validator.validate(input, options, path);
|
|
198
|
+
if (errors.length) return errors;
|
|
199
|
+
}
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// src/validation/orValidators.ts
|
|
206
|
+
var import_vinyl_util4 = require("@amazon/vinyl-util");
|
|
207
|
+
var locale2 = {
|
|
208
|
+
/**
|
|
209
|
+
* {value} - The child validators' descriptions, joined with `separator`.
|
|
210
|
+
*/
|
|
211
|
+
template: "({value})",
|
|
212
|
+
/**
|
|
213
|
+
* The separator with which to join child validator descriptions.
|
|
214
|
+
*/
|
|
215
|
+
separator: " | "
|
|
216
|
+
};
|
|
217
|
+
function orValidators(...validators) {
|
|
218
|
+
const description = (0, import_vinyl_util4.substitute)(locale2.template, {
|
|
219
|
+
value: validators.map((v) => v.description).join(locale2.separator)
|
|
220
|
+
});
|
|
221
|
+
return createDeepValidator(description, (input, options, path) => {
|
|
222
|
+
let longestErrors = [];
|
|
223
|
+
let longestPath = 0;
|
|
224
|
+
for (const validator of validators) {
|
|
225
|
+
const errors = validator.validate(input, options, path);
|
|
226
|
+
if (!errors.length) return errors;
|
|
227
|
+
const pathLength = errors.reduce(
|
|
228
|
+
(max, m) => Math.max(m.path.length, max),
|
|
229
|
+
0
|
|
230
|
+
);
|
|
231
|
+
if (pathLength >= longestPath) {
|
|
232
|
+
longestErrors = errors;
|
|
233
|
+
longestPath = pathLength;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return longestPath > path.length ? longestErrors : [
|
|
237
|
+
{
|
|
238
|
+
message: createValidationExpectationMessage(
|
|
239
|
+
description,
|
|
240
|
+
input,
|
|
241
|
+
path
|
|
242
|
+
),
|
|
243
|
+
path
|
|
244
|
+
}
|
|
245
|
+
];
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/validation/SchemaBase.ts
|
|
250
|
+
var import_vinyl_util5 = require("@amazon/vinyl-util");
|
|
251
|
+
var requiredValidationOptions = {
|
|
252
|
+
optional: false
|
|
253
|
+
};
|
|
254
|
+
var SchemaBase = class {
|
|
255
|
+
constructor(currentValidator, previousSchema, operation) {
|
|
256
|
+
this.currentValidator = currentValidator;
|
|
257
|
+
this.previousSchema = previousSchema;
|
|
258
|
+
this.operation = operation;
|
|
259
|
+
__publicField(this, "__type", /* @__PURE__ */ (0, import_vinyl_util5.invariant)());
|
|
260
|
+
__publicField(this, "validator");
|
|
261
|
+
__publicField(this, "_options", requiredValidationOptions);
|
|
262
|
+
__publicField(this, "assert", (input, origin, path) => {
|
|
263
|
+
this.validator.assert(input, origin, path);
|
|
264
|
+
});
|
|
265
|
+
__publicField(this, "isValid", (input) => this.validator.isValid(input));
|
|
266
|
+
__publicField(this, "validate", (input, options, path) => this.validator.validate(input, options, path));
|
|
267
|
+
this.validator = operation == null ? currentValidator : operation(previousSchema, currentValidator);
|
|
268
|
+
}
|
|
269
|
+
get options() {
|
|
270
|
+
return this._options;
|
|
271
|
+
}
|
|
272
|
+
get description() {
|
|
273
|
+
return this.validator.description;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Clones this schema, transforming all validators with the given mutator.
|
|
277
|
+
*
|
|
278
|
+
* @param transform A transformer which takes an existing validator in the chain and returns
|
|
279
|
+
* a new one. Validators should be considered to be immutable; transform should not change the
|
|
280
|
+
* input but instead return a new validator.
|
|
281
|
+
*/
|
|
282
|
+
clone(transform = (v) => v) {
|
|
283
|
+
const cloned = this.operation ? this.self(
|
|
284
|
+
transform(this.currentValidator),
|
|
285
|
+
this.previousSchema.clone(transform),
|
|
286
|
+
this.operation
|
|
287
|
+
) : this.self(transform(this.currentValidator));
|
|
288
|
+
cloned._options = this._options;
|
|
289
|
+
return cloned;
|
|
290
|
+
}
|
|
291
|
+
self(current, previous, operation) {
|
|
292
|
+
if (this.constructor.length > 3) {
|
|
293
|
+
throw new import_vinyl_util5.IllegalArgumentError(
|
|
294
|
+
"constructor should have at most three required arguments"
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
return new this.constructor(current, previous, operation);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Constructs a new schema with a validator chaining the current validator with the
|
|
301
|
+
* provided next in an AND operation.
|
|
302
|
+
*
|
|
303
|
+
* @param nextValidator The validator to run after the current.
|
|
304
|
+
* @return Returns a new Schema instance the same class with a new validator chaining the
|
|
305
|
+
* current validator with the given next in an AND operation.
|
|
306
|
+
*/
|
|
307
|
+
chain(nextValidator) {
|
|
308
|
+
return this.self(nextValidator, this, andValidators);
|
|
309
|
+
}
|
|
310
|
+
optional() {
|
|
311
|
+
const cloned = this.clone();
|
|
312
|
+
cloned._options = __spreadProps(__spreadValues({}, cloned.options), {
|
|
313
|
+
optional: true
|
|
314
|
+
});
|
|
315
|
+
return cloned;
|
|
316
|
+
}
|
|
317
|
+
required() {
|
|
318
|
+
const cloned = this.clone();
|
|
319
|
+
cloned._options = __spreadProps(__spreadValues({}, cloned.options), {
|
|
320
|
+
optional: false
|
|
321
|
+
});
|
|
322
|
+
return cloned;
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
// src/validation/ValueSchema.ts
|
|
327
|
+
var locale3 = {
|
|
328
|
+
null: "null",
|
|
329
|
+
nullish: "nullish",
|
|
330
|
+
undefined: "undefined"
|
|
331
|
+
};
|
|
332
|
+
var valueValidators = {
|
|
333
|
+
any() {
|
|
334
|
+
return createValidator("", () => true);
|
|
335
|
+
},
|
|
336
|
+
/**
|
|
337
|
+
* Creates a validator that asserts that the input is nullish.
|
|
338
|
+
*/
|
|
339
|
+
nullish() {
|
|
340
|
+
return createValidator(locale3.nullish, (input) => input == null);
|
|
341
|
+
},
|
|
342
|
+
/**
|
|
343
|
+
* Creates a validator that asserts that the input is strictly null.
|
|
344
|
+
*/
|
|
345
|
+
null() {
|
|
346
|
+
return createValidator(locale3.null, (input) => input === null);
|
|
347
|
+
},
|
|
348
|
+
/**
|
|
349
|
+
* Creates a validator that asserts that the input is strictly undefined.
|
|
350
|
+
*/
|
|
351
|
+
undefined() {
|
|
352
|
+
return createValidator(locale3.undefined, (input) => input === void 0);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
var ValueSchema = class _ValueSchema extends SchemaBase {
|
|
356
|
+
/**
|
|
357
|
+
* Prepends this validator allowing for null or undefined.
|
|
358
|
+
*/
|
|
359
|
+
maybe() {
|
|
360
|
+
return this.or(valueValidators.nullish());
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Prepends this validator allowing for null.
|
|
364
|
+
*/
|
|
365
|
+
orNull() {
|
|
366
|
+
return this.or(valueValidators.null());
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Prepends this validator allowing for undefined.
|
|
370
|
+
*/
|
|
371
|
+
orUndefined() {
|
|
372
|
+
return this.or(valueValidators.undefined());
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Returns a validator that asserts if this validator and the next passes.
|
|
376
|
+
*
|
|
377
|
+
* @see andValidators
|
|
378
|
+
*
|
|
379
|
+
* @param nextValidator The validator to run after the current.
|
|
380
|
+
* @return Returns a new ValueSchema intersecting this validator and the next.
|
|
381
|
+
*/
|
|
382
|
+
and(nextValidator) {
|
|
383
|
+
return new _ValueSchema(nextValidator, this, andValidators);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Returns a validator that asserts if this validator or the next passes.
|
|
387
|
+
*
|
|
388
|
+
* Implementation note:
|
|
389
|
+
* subclasses should not change the schema instance returned unless all chainable validators
|
|
390
|
+
* accept input type 'unknown'.
|
|
391
|
+
*
|
|
392
|
+
* @param nextValidator The validator to run after the current.
|
|
393
|
+
* @return Returns a new ValueSchema providing the union of this validator and the next.
|
|
394
|
+
*/
|
|
395
|
+
or(nextValidator) {
|
|
396
|
+
return new _ValueSchema(nextValidator, this, orValidators);
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
// src/validation/ArraySchema.ts
|
|
401
|
+
var locale4 = {
|
|
402
|
+
array: "array",
|
|
403
|
+
minLength: "at least {value} elements",
|
|
404
|
+
maxLength: "at most {value} elements",
|
|
405
|
+
exactlyLength: "exactly {value} elements",
|
|
406
|
+
actualLength: "length {value}",
|
|
407
|
+
withElements: "({value})[]",
|
|
408
|
+
tuple: "[{value}]"
|
|
409
|
+
};
|
|
410
|
+
var arrayValidators = {
|
|
411
|
+
/**
|
|
412
|
+
* Creates a validator that asserts that the input is an array.
|
|
413
|
+
*
|
|
414
|
+
* Note: arrays can only be readonly by type system, there is no native readonly
|
|
415
|
+
* js array. This validator assumes mutability, use the ArraySchema readonly() method
|
|
416
|
+
* to cast to a readonly array.
|
|
417
|
+
*/
|
|
418
|
+
isArray() {
|
|
419
|
+
return createValidator(
|
|
420
|
+
locale4.array,
|
|
421
|
+
(input) => Array.isArray(input)
|
|
422
|
+
);
|
|
423
|
+
},
|
|
424
|
+
/**
|
|
425
|
+
* Creates a validator that asserts that every element passes the given validator.
|
|
426
|
+
*
|
|
427
|
+
* @param elementValidator
|
|
428
|
+
*/
|
|
429
|
+
withElements(elementValidator) {
|
|
430
|
+
return createDeepValidator(
|
|
431
|
+
(0, import_vinyl_util6.substitute)(locale4.withElements, {
|
|
432
|
+
value: elementValidator.description
|
|
433
|
+
}),
|
|
434
|
+
(input, options, path) => {
|
|
435
|
+
const errors = [];
|
|
436
|
+
for (let i = 0; i < input.length; i++) {
|
|
437
|
+
const element = input[i];
|
|
438
|
+
errors.push(
|
|
439
|
+
...elementValidator.validate(
|
|
440
|
+
element,
|
|
441
|
+
options,
|
|
442
|
+
path.concat(i.toString())
|
|
443
|
+
)
|
|
444
|
+
);
|
|
445
|
+
if (!options.all && errors.length) return errors;
|
|
446
|
+
}
|
|
447
|
+
return errors;
|
|
448
|
+
}
|
|
449
|
+
);
|
|
450
|
+
},
|
|
451
|
+
/**
|
|
452
|
+
* Creates a validator that asserts that the input array is a tuple whose elements match
|
|
453
|
+
* the given validators.
|
|
454
|
+
*
|
|
455
|
+
* @param validators
|
|
456
|
+
*/
|
|
457
|
+
tuple(...validators) {
|
|
458
|
+
const lengthValidator = createValidator(
|
|
459
|
+
(0, import_vinyl_util6.substitute)(locale4.exactlyLength, {
|
|
460
|
+
value: validators.length
|
|
461
|
+
}),
|
|
462
|
+
(length) => length === validators.length
|
|
463
|
+
);
|
|
464
|
+
return createDeepValidator(
|
|
465
|
+
(0, import_vinyl_util6.substitute)(locale4.tuple, { value: validators.join(", ") }),
|
|
466
|
+
(input, options, path) => {
|
|
467
|
+
const errors = [];
|
|
468
|
+
errors.push(
|
|
469
|
+
...lengthValidator.validate(input.length, options, path)
|
|
470
|
+
);
|
|
471
|
+
if (!options.all && errors.length) return errors;
|
|
472
|
+
const n = Math.min(validators.length, input.length);
|
|
473
|
+
for (let i = 0; i < n; i++) {
|
|
474
|
+
const element = input[i];
|
|
475
|
+
const validator = validators[i];
|
|
476
|
+
errors.push(
|
|
477
|
+
...validator.validate(
|
|
478
|
+
element,
|
|
479
|
+
options,
|
|
480
|
+
path.concat(i.toString())
|
|
481
|
+
)
|
|
482
|
+
);
|
|
483
|
+
if (!options.all && errors.length) return errors;
|
|
484
|
+
}
|
|
485
|
+
return errors;
|
|
486
|
+
}
|
|
487
|
+
);
|
|
488
|
+
},
|
|
489
|
+
/**
|
|
490
|
+
* Creates a validator that validates the input array has the given minimum length.
|
|
491
|
+
* @param min The minimum number of elements (inclusive)
|
|
492
|
+
*/
|
|
493
|
+
minLength(min) {
|
|
494
|
+
return createValidator(
|
|
495
|
+
(0, import_vinyl_util6.substitute)(locale4.minLength, { value: min }),
|
|
496
|
+
(input) => input.length >= min,
|
|
497
|
+
(input) => (0, import_vinyl_util6.substitute)(locale4.actualLength, { value: input.length })
|
|
498
|
+
);
|
|
499
|
+
},
|
|
500
|
+
/**
|
|
501
|
+
*
|
|
502
|
+
* Creates a validator that validates the input array has the given maximum length.
|
|
503
|
+
* @param max The maximum number of elements (inclusive)
|
|
504
|
+
*/
|
|
505
|
+
maxLength(max) {
|
|
506
|
+
return createValidator(
|
|
507
|
+
(0, import_vinyl_util6.substitute)(locale4.maxLength, { value: max }),
|
|
508
|
+
(input) => input.length <= max,
|
|
509
|
+
(input) => (0, import_vinyl_util6.substitute)(locale4.actualLength, { value: input.length })
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
var _ArraySchema = class _ArraySchema extends ValueSchema {
|
|
514
|
+
/**
|
|
515
|
+
* The base ArraySchema instance validating that the input is an Array.
|
|
516
|
+
*/
|
|
517
|
+
static get base() {
|
|
518
|
+
if (this._base == null)
|
|
519
|
+
this._base = new _ArraySchema(arrayValidators.isArray());
|
|
520
|
+
return this._base;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Creates a validator that asserts that every element passes the given validator.
|
|
524
|
+
*
|
|
525
|
+
* @param elementValidator
|
|
526
|
+
*/
|
|
527
|
+
withElements(elementValidator) {
|
|
528
|
+
return this.chain(arrayValidators.withElements(elementValidator));
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Creates a validator that asserts that the input array is a tuple whose elements match
|
|
532
|
+
* the given validators.
|
|
533
|
+
*
|
|
534
|
+
* @param validators
|
|
535
|
+
*/
|
|
536
|
+
tuple(...validators) {
|
|
537
|
+
return this.chain(arrayValidators.tuple(...validators));
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Creates a validator that validates the input array has the given minimum length.
|
|
541
|
+
* @param min The minimum number of elements (inclusive)
|
|
542
|
+
*/
|
|
543
|
+
minLength(min) {
|
|
544
|
+
return this.chain(arrayValidators.minLength(min));
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
*
|
|
548
|
+
* Creates a validator that validates the input array has the given maximum length.
|
|
549
|
+
* @param max The maximum number of elements (inclusive)
|
|
550
|
+
*/
|
|
551
|
+
maxLength(max) {
|
|
552
|
+
return this.chain(arrayValidators.maxLength(max));
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Casts to a readonly array.
|
|
556
|
+
* This is a shallow cast, elements of the array will not be changed.
|
|
557
|
+
*/
|
|
558
|
+
readonly() {
|
|
559
|
+
return this;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Casts the type parameter.
|
|
563
|
+
*/
|
|
564
|
+
cast() {
|
|
565
|
+
return this;
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
__publicField(_ArraySchema, "_base", null);
|
|
569
|
+
var ArraySchema = _ArraySchema;
|
|
570
|
+
|
|
571
|
+
// src/validation/FunctionSchema.ts
|
|
572
|
+
var import_vinyl_util8 = require("@amazon/vinyl-util");
|
|
573
|
+
|
|
574
|
+
// src/validation/typeOfValidators.ts
|
|
575
|
+
var import_vinyl_util7 = require("@amazon/vinyl-util");
|
|
576
|
+
var locale5 = {
|
|
577
|
+
template: "type {value}"
|
|
578
|
+
};
|
|
579
|
+
function typeOfValidator(expected) {
|
|
580
|
+
return createValidator(
|
|
581
|
+
(0, import_vinyl_util7.substitute)(locale5.template, { value: expected }),
|
|
582
|
+
(input) => {
|
|
583
|
+
return input != null && typeof input === expected;
|
|
584
|
+
}
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
var typeOfValidatorCache = {};
|
|
588
|
+
function cachedTypeOfValidator(type) {
|
|
589
|
+
if (!(type in typeOfValidatorCache)) {
|
|
590
|
+
typeOfValidatorCache[type] = typeOfValidator(type);
|
|
591
|
+
}
|
|
592
|
+
return typeOfValidatorCache[type];
|
|
593
|
+
}
|
|
594
|
+
var typeOfValidators = {
|
|
595
|
+
get boolean() {
|
|
596
|
+
return cachedTypeOfValidator("boolean");
|
|
597
|
+
},
|
|
598
|
+
get func() {
|
|
599
|
+
return cachedTypeOfValidator("function");
|
|
600
|
+
},
|
|
601
|
+
get number() {
|
|
602
|
+
return cachedTypeOfValidator("number");
|
|
603
|
+
},
|
|
604
|
+
get object() {
|
|
605
|
+
return cachedTypeOfValidator("object");
|
|
606
|
+
},
|
|
607
|
+
get string() {
|
|
608
|
+
return cachedTypeOfValidator("string");
|
|
609
|
+
},
|
|
610
|
+
get symbol() {
|
|
611
|
+
return cachedTypeOfValidator("symbol");
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
// src/validation/FunctionSchema.ts
|
|
616
|
+
var locale6 = {
|
|
617
|
+
length: "at most {value} arguments",
|
|
618
|
+
actualLength: "{value} arguments"
|
|
619
|
+
};
|
|
620
|
+
var functionValidators = {
|
|
621
|
+
length(max) {
|
|
622
|
+
return createValidator(
|
|
623
|
+
(0, import_vinyl_util8.substitute)(locale6.length, { value: max }),
|
|
624
|
+
(input) => input.length <= max,
|
|
625
|
+
(input) => (0, import_vinyl_util8.substitute)(locale6.actualLength, { value: input.length })
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
var _FunctionSchema = class _FunctionSchema extends ValueSchema {
|
|
630
|
+
/**
|
|
631
|
+
* The base Function validator validating that the input is a function.
|
|
632
|
+
*/
|
|
633
|
+
static get base() {
|
|
634
|
+
if (this._base == null)
|
|
635
|
+
this._base = new _FunctionSchema(typeOfValidators.func);
|
|
636
|
+
return this._base;
|
|
637
|
+
}
|
|
638
|
+
length(max) {
|
|
639
|
+
return this.chain(functionValidators.length(max));
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Casts the function signature.
|
|
643
|
+
* Function signatures, except for their required number of parameters, cannot be
|
|
644
|
+
* meaningfully validated.
|
|
645
|
+
*/
|
|
646
|
+
cast() {
|
|
647
|
+
return this;
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
__publicField(_FunctionSchema, "_base", null);
|
|
651
|
+
var FunctionSchema = _FunctionSchema;
|
|
652
|
+
|
|
653
|
+
// src/validation/SetSchema.ts
|
|
654
|
+
var import_vinyl_util9 = require("@amazon/vinyl-util");
|
|
655
|
+
var locale7 = {
|
|
656
|
+
set: "Set",
|
|
657
|
+
withElements: "Set<{value}>"
|
|
658
|
+
};
|
|
659
|
+
var setValidators = {
|
|
660
|
+
/**
|
|
661
|
+
* Creates a validator that asserts that the input is a set.
|
|
662
|
+
*/
|
|
663
|
+
isSet() {
|
|
664
|
+
return createValidator(
|
|
665
|
+
locale7.set,
|
|
666
|
+
(input) => input instanceof Set
|
|
667
|
+
);
|
|
668
|
+
},
|
|
669
|
+
/**
|
|
670
|
+
* Creates a validator that asserts that every element passes the given validator.
|
|
671
|
+
*
|
|
672
|
+
* @param elementValidator
|
|
673
|
+
*/
|
|
674
|
+
withElements(elementValidator) {
|
|
675
|
+
return createDeepValidator(
|
|
676
|
+
(0, import_vinyl_util9.substitute)(locale7.withElements, {
|
|
677
|
+
value: elementValidator.description
|
|
678
|
+
}),
|
|
679
|
+
(input, options, path) => {
|
|
680
|
+
const errors = [];
|
|
681
|
+
let i = 0;
|
|
682
|
+
for (const element of input) {
|
|
683
|
+
errors.push(
|
|
684
|
+
...elementValidator.validate(
|
|
685
|
+
element,
|
|
686
|
+
options,
|
|
687
|
+
path.concat(i.toString())
|
|
688
|
+
)
|
|
689
|
+
);
|
|
690
|
+
if (!options.all && errors.length) return errors;
|
|
691
|
+
i++;
|
|
692
|
+
}
|
|
693
|
+
return errors;
|
|
694
|
+
}
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
var _SetSchema = class _SetSchema extends ValueSchema {
|
|
699
|
+
/**
|
|
700
|
+
* The base SetSchema instance validating that the input is a Set.
|
|
701
|
+
*/
|
|
702
|
+
static get base() {
|
|
703
|
+
if (this._base == null)
|
|
704
|
+
this._base = new _SetSchema(setValidators.isSet());
|
|
705
|
+
return this._base;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Creates a validator that asserts that every element passes the given validator.
|
|
709
|
+
*
|
|
710
|
+
* @param elementValidator
|
|
711
|
+
*/
|
|
712
|
+
withElements(elementValidator) {
|
|
713
|
+
return this.chain(setValidators.withElements(elementValidator));
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Casts to a readonly set.
|
|
717
|
+
* This is a shallow cast, elements of the array will not be changed.
|
|
718
|
+
*/
|
|
719
|
+
readonly() {
|
|
720
|
+
return this;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Casts the parameter type.
|
|
724
|
+
*/
|
|
725
|
+
cast() {
|
|
726
|
+
return this;
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
__publicField(_SetSchema, "_base", null);
|
|
730
|
+
var SetSchema = _SetSchema;
|
|
731
|
+
|
|
732
|
+
// src/validation/NumberSchema.ts
|
|
733
|
+
var import_vinyl_util10 = require("@amazon/vinyl-util");
|
|
734
|
+
var locale8 = {
|
|
735
|
+
gte: "at least {value}",
|
|
736
|
+
gt: "greater than {value}",
|
|
737
|
+
lte: "at most {value}",
|
|
738
|
+
lt: "less than {value}",
|
|
739
|
+
within: "within {min} and {max}",
|
|
740
|
+
safeInteger: "safe integer",
|
|
741
|
+
finite: "finite"
|
|
742
|
+
};
|
|
743
|
+
var numberValidators = {
|
|
744
|
+
/**
|
|
745
|
+
* Creates a validator that asserts that the input number is at least the provided minimum
|
|
746
|
+
* value.
|
|
747
|
+
*
|
|
748
|
+
* @param min The minimum (inclusive) the value may be.
|
|
749
|
+
*/
|
|
750
|
+
gte(min) {
|
|
751
|
+
return createValidator(
|
|
752
|
+
(0, import_vinyl_util10.substitute)(locale8.gte, { value: min }),
|
|
753
|
+
(input) => input >= min
|
|
754
|
+
);
|
|
755
|
+
},
|
|
756
|
+
/**
|
|
757
|
+
* Creates a validator that asserts that the input number is greater than the provided minimum
|
|
758
|
+
* value.
|
|
759
|
+
*
|
|
760
|
+
* @param min The minimum (exclusive) the value may be.
|
|
761
|
+
*/
|
|
762
|
+
gt(min) {
|
|
763
|
+
return createValidator(
|
|
764
|
+
(0, import_vinyl_util10.substitute)(locale8.gt, { value: min }),
|
|
765
|
+
(input) => input > min
|
|
766
|
+
);
|
|
767
|
+
},
|
|
768
|
+
/**
|
|
769
|
+
* Creates a validator that asserts that the input number is at most the provided maximum
|
|
770
|
+
* value.
|
|
771
|
+
*
|
|
772
|
+
* @param max The maximum (inclusive) the value may be.
|
|
773
|
+
*/
|
|
774
|
+
lte(max) {
|
|
775
|
+
return createValidator(
|
|
776
|
+
(0, import_vinyl_util10.substitute)(locale8.lte, { value: max }),
|
|
777
|
+
(input) => input <= max
|
|
778
|
+
);
|
|
779
|
+
},
|
|
780
|
+
/**
|
|
781
|
+
* Creates a validator that asserts that the input number is less than the provided maximum
|
|
782
|
+
* value.
|
|
783
|
+
*
|
|
784
|
+
* @param max The maximum (exclusive) the value may be.
|
|
785
|
+
*/
|
|
786
|
+
lt(max) {
|
|
787
|
+
return createValidator(
|
|
788
|
+
(0, import_vinyl_util10.substitute)(locale8.lt, { value: max }),
|
|
789
|
+
(input) => input < max
|
|
790
|
+
);
|
|
791
|
+
},
|
|
792
|
+
/**
|
|
793
|
+
* Creates a validator that asserts that the input number is at least the provided minimum
|
|
794
|
+
* and at most the provided maximum values.
|
|
795
|
+
*
|
|
796
|
+
* @param min The minimum (inclusive) value the input may be.
|
|
797
|
+
* @param max The maximum (inclusive) value the input may be.
|
|
798
|
+
*/
|
|
799
|
+
within(min, max) {
|
|
800
|
+
return createValidator(
|
|
801
|
+
(0, import_vinyl_util10.substitute)(locale8.within, { min, max }),
|
|
802
|
+
(input) => input >= min && input <= max
|
|
803
|
+
);
|
|
804
|
+
},
|
|
805
|
+
/**
|
|
806
|
+
* Creates a validator that asserts that the input number is finite.
|
|
807
|
+
*/
|
|
808
|
+
finite() {
|
|
809
|
+
return createValidator(locale8.finite, (input) => Number.isFinite(input));
|
|
810
|
+
},
|
|
811
|
+
/**
|
|
812
|
+
* Creates a validator that asserts that the input number is a safe integer.
|
|
813
|
+
*/
|
|
814
|
+
safeInteger() {
|
|
815
|
+
return createValidator(
|
|
816
|
+
locale8.safeInteger,
|
|
817
|
+
(input) => Number.isSafeInteger(input)
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
var _NumberSchema = class _NumberSchema extends ValueSchema {
|
|
822
|
+
/**
|
|
823
|
+
* The base Object validator validating that the input is an object.
|
|
824
|
+
*/
|
|
825
|
+
static get base() {
|
|
826
|
+
if (this._base == null)
|
|
827
|
+
this._base = new _NumberSchema(typeOfValidators.number);
|
|
828
|
+
return this._base;
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Creates a validator that asserts that the input number is at least the provided minimum
|
|
832
|
+
* value.
|
|
833
|
+
*
|
|
834
|
+
* @param min The minimum (inclusive) the value may be.
|
|
835
|
+
*/
|
|
836
|
+
gte(min) {
|
|
837
|
+
return this.chain(numberValidators.gte(min));
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Creates a validator that asserts that the input number is greater than the provided minimum
|
|
841
|
+
* value.
|
|
842
|
+
*
|
|
843
|
+
* @param min The minimum (exclusive) the value may be.
|
|
844
|
+
*/
|
|
845
|
+
gt(min) {
|
|
846
|
+
return this.chain(numberValidators.gt(min));
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Creates a validator that asserts that the input number is at most the provided maximum
|
|
850
|
+
* value.
|
|
851
|
+
*
|
|
852
|
+
* @param max The maximum (inclusive) the value may be.
|
|
853
|
+
*/
|
|
854
|
+
lte(max) {
|
|
855
|
+
return this.chain(numberValidators.lte(max));
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Creates a validator that asserts that the input number is less than the provided maximum
|
|
859
|
+
* value.
|
|
860
|
+
*
|
|
861
|
+
* @param max The maximum (exclusive) the value may be.
|
|
862
|
+
*/
|
|
863
|
+
lt(max) {
|
|
864
|
+
return this.chain(numberValidators.lt(max));
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Creates a validator that asserts that the input number is at least the provided minimum
|
|
868
|
+
* and at most the provided maximum values.
|
|
869
|
+
*
|
|
870
|
+
* @param min The minimum (inclusive) value the input may be.
|
|
871
|
+
* @param max The maximum (inclusive) value the input may be.
|
|
872
|
+
*/
|
|
873
|
+
within(min, max) {
|
|
874
|
+
return this.chain(numberValidators.within(min, max));
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Creates a validator that asserts that the input number is finite.
|
|
878
|
+
*/
|
|
879
|
+
finite() {
|
|
880
|
+
return this.chain(numberValidators.finite());
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Creates a validator that asserts that the input number is a safe integer.
|
|
884
|
+
*/
|
|
885
|
+
safeInteger() {
|
|
886
|
+
return this.chain(numberValidators.safeInteger());
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
__publicField(_NumberSchema, "_base", null);
|
|
890
|
+
var NumberSchema = _NumberSchema;
|
|
891
|
+
|
|
892
|
+
// src/validation/ObjectSchema.ts
|
|
893
|
+
var import_vinyl_util11 = require("@amazon/vinyl-util");
|
|
894
|
+
|
|
895
|
+
// src/validation/ValidatorWithPartial.ts
|
|
896
|
+
function isValidatorWithPartial(validator) {
|
|
897
|
+
return "partial" in validator && "partialDeep" in validator;
|
|
898
|
+
}
|
|
899
|
+
function maybeToDeepPartial(validator) {
|
|
900
|
+
return isValidatorWithPartial(validator) ? validator.partialDeep() : validator;
|
|
901
|
+
}
|
|
902
|
+
function maybeToPartial(validator) {
|
|
903
|
+
return isValidatorWithPartial(validator) ? validator.partial() : validator;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// src/validation/ObjectSchema.ts
|
|
907
|
+
var locale9 = {
|
|
908
|
+
extend: "{\n{body}\n}",
|
|
909
|
+
prop: "{key}: {value}",
|
|
910
|
+
propSeparator: ",\n",
|
|
911
|
+
indent: " ",
|
|
912
|
+
required: `property '{key}' is required`
|
|
913
|
+
};
|
|
914
|
+
var objectValidators = {
|
|
915
|
+
/**
|
|
916
|
+
* Creates a validator that validates the input has properties that pass their respective
|
|
917
|
+
* validators.
|
|
918
|
+
*
|
|
919
|
+
* @param propertyValidators
|
|
920
|
+
*/
|
|
921
|
+
properties(propertyValidators) {
|
|
922
|
+
const propertiesDescriptions = [];
|
|
923
|
+
const keys = (0, import_vinyl_util11.ownKeys)(propertyValidators);
|
|
924
|
+
for (const key of keys) {
|
|
925
|
+
const validator2 = propertyValidators[key];
|
|
926
|
+
propertiesDescriptions.push(
|
|
927
|
+
(0, import_vinyl_util11.substitute)(locale9.prop, {
|
|
928
|
+
key: String(key) + (validator2.options.optional ? "?" : ""),
|
|
929
|
+
value: validator2.description
|
|
930
|
+
})
|
|
931
|
+
);
|
|
932
|
+
}
|
|
933
|
+
const description = (0, import_vinyl_util11.substitute)(locale9.extend, {
|
|
934
|
+
body: propertiesDescriptions.join(locale9.propSeparator).split("\n").map((line) => locale9.indent + line).join("\n")
|
|
935
|
+
});
|
|
936
|
+
const validator = createDeepValidator(
|
|
937
|
+
description,
|
|
938
|
+
(input, options, path) => {
|
|
939
|
+
const errors = [];
|
|
940
|
+
for (const key of keys) {
|
|
941
|
+
const validator2 = propertyValidators[key];
|
|
942
|
+
if (key in input) {
|
|
943
|
+
const value = input[key];
|
|
944
|
+
errors.push(
|
|
945
|
+
...validator2.validate(
|
|
946
|
+
value,
|
|
947
|
+
options,
|
|
948
|
+
path.concat(String(key))
|
|
949
|
+
)
|
|
950
|
+
);
|
|
951
|
+
} else {
|
|
952
|
+
if (!validator2.options.optional) {
|
|
953
|
+
errors.push({
|
|
954
|
+
message: (0, import_vinyl_util11.substitute)(locale9.required, { key }),
|
|
955
|
+
path: path.concat(String(key))
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
if (!options.all && errors.length) return errors;
|
|
960
|
+
}
|
|
961
|
+
return errors;
|
|
962
|
+
}
|
|
963
|
+
);
|
|
964
|
+
return (0, import_vinyl_util11.merge)(validator, {
|
|
965
|
+
partial() {
|
|
966
|
+
const optionalPropertyValidators = {};
|
|
967
|
+
for (const key of keys) {
|
|
968
|
+
optionalPropertyValidators[key] = propertyValidators[key].optional();
|
|
969
|
+
}
|
|
970
|
+
return objectValidators.properties(
|
|
971
|
+
optionalPropertyValidators
|
|
972
|
+
);
|
|
973
|
+
},
|
|
974
|
+
partialDeep() {
|
|
975
|
+
const optionalPropertyValidators = {};
|
|
976
|
+
for (const key of keys) {
|
|
977
|
+
optionalPropertyValidators[key] = maybeToDeepPartial(
|
|
978
|
+
propertyValidators[key].optional()
|
|
979
|
+
);
|
|
980
|
+
}
|
|
981
|
+
return objectValidators.properties(
|
|
982
|
+
optionalPropertyValidators
|
|
983
|
+
);
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
var _ObjectSchema = class _ObjectSchema extends ValueSchema {
|
|
989
|
+
/**
|
|
990
|
+
* The base Object validator validating that the input is an object.
|
|
991
|
+
*/
|
|
992
|
+
static get base() {
|
|
993
|
+
if (this._base == null)
|
|
994
|
+
this._base = new _ObjectSchema(typeOfValidators.object);
|
|
995
|
+
return this._base;
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Creates a validator that validates the input has properties that pass their respective
|
|
999
|
+
* validators.
|
|
1000
|
+
*
|
|
1001
|
+
* @param propertyValidators
|
|
1002
|
+
*/
|
|
1003
|
+
extend(propertyValidators) {
|
|
1004
|
+
return this.chain(objectValidators.properties(propertyValidators));
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Allows all properties to be undefined.
|
|
1008
|
+
*/
|
|
1009
|
+
partial() {
|
|
1010
|
+
return this.clone(maybeToPartial);
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Allows all recursive properties to be undefined.
|
|
1014
|
+
*/
|
|
1015
|
+
partialDeep() {
|
|
1016
|
+
return this.clone(maybeToDeepPartial);
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Casts the type parameter.
|
|
1020
|
+
*/
|
|
1021
|
+
cast() {
|
|
1022
|
+
return this;
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
__publicField(_ObjectSchema, "_base", null);
|
|
1026
|
+
var ObjectSchema = _ObjectSchema;
|
|
1027
|
+
|
|
1028
|
+
// src/validation/RecordSchema.ts
|
|
1029
|
+
var import_vinyl_util13 = require("@amazon/vinyl-util");
|
|
1030
|
+
|
|
1031
|
+
// src/validation/StringSchema.ts
|
|
1032
|
+
var import_vinyl_util12 = require("@amazon/vinyl-util");
|
|
1033
|
+
var locale10 = {
|
|
1034
|
+
notEmpty: "not empty",
|
|
1035
|
+
minLength: "at least {value} characters",
|
|
1036
|
+
maxLength: "at most {value} characters",
|
|
1037
|
+
noWhitespace: "no whitespace characters",
|
|
1038
|
+
matches: "matches {value}"
|
|
1039
|
+
};
|
|
1040
|
+
var stringValidators = {
|
|
1041
|
+
/**
|
|
1042
|
+
* Creates a validator that asserts that the input is not empty.
|
|
1043
|
+
*/
|
|
1044
|
+
notEmpty() {
|
|
1045
|
+
return createValidator(locale10.notEmpty, (input) => input !== "");
|
|
1046
|
+
},
|
|
1047
|
+
/**
|
|
1048
|
+
* Creates a validator that asserts that the input string has at least the given minimum
|
|
1049
|
+
* length.
|
|
1050
|
+
*
|
|
1051
|
+
* @param min The string must be at least this length.
|
|
1052
|
+
*/
|
|
1053
|
+
minLength(min) {
|
|
1054
|
+
return createValidator(
|
|
1055
|
+
(0, import_vinyl_util12.substitute)(locale10.minLength, { value: min }),
|
|
1056
|
+
(input) => input.length >= min
|
|
1057
|
+
);
|
|
1058
|
+
},
|
|
1059
|
+
/**
|
|
1060
|
+
* Creates a validator that asserts that the input string has at most the given maximum
|
|
1061
|
+
* length.
|
|
1062
|
+
*
|
|
1063
|
+
* @param max The string must be at most this length.
|
|
1064
|
+
*/
|
|
1065
|
+
maxLength(max) {
|
|
1066
|
+
return createValidator(
|
|
1067
|
+
(0, import_vinyl_util12.substitute)(locale10.maxLength, { value: max }),
|
|
1068
|
+
(input) => input.length <= max
|
|
1069
|
+
);
|
|
1070
|
+
},
|
|
1071
|
+
/**
|
|
1072
|
+
* Creates a validator that asserts that the input string has no whitespace characters.
|
|
1073
|
+
* Whitespace characters include space, new line, carriage return, and tab.
|
|
1074
|
+
*/
|
|
1075
|
+
noWhitespace() {
|
|
1076
|
+
return createValidator(
|
|
1077
|
+
locale10.noWhitespace,
|
|
1078
|
+
(input) => input.search(/\s/g) === -1
|
|
1079
|
+
);
|
|
1080
|
+
},
|
|
1081
|
+
/**
|
|
1082
|
+
* Creates a validator that asserts that the input string matches the given regex.
|
|
1083
|
+
* @param regex
|
|
1084
|
+
*/
|
|
1085
|
+
matches(regex) {
|
|
1086
|
+
return createValidator(
|
|
1087
|
+
(0, import_vinyl_util12.substitute)(locale10.matches, { value: regex.toString() }),
|
|
1088
|
+
(input) => {
|
|
1089
|
+
return regex.test(input);
|
|
1090
|
+
}
|
|
1091
|
+
);
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
var _StringSchema = class _StringSchema extends ValueSchema {
|
|
1095
|
+
/**
|
|
1096
|
+
* The base SetSchema instance validating that the input is a Set.
|
|
1097
|
+
*/
|
|
1098
|
+
static get base() {
|
|
1099
|
+
if (this._base == null)
|
|
1100
|
+
this._base = new _StringSchema(typeOfValidators.string);
|
|
1101
|
+
return this._base;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Creates a validator that asserts that the input is not empty.
|
|
1105
|
+
*/
|
|
1106
|
+
notEmpty() {
|
|
1107
|
+
return this.chain(stringValidators.notEmpty());
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Creates a validator that asserts that the input string has at least the given minimum
|
|
1111
|
+
* length.
|
|
1112
|
+
*
|
|
1113
|
+
* @param min The string must be at least this length.
|
|
1114
|
+
*/
|
|
1115
|
+
minLength(min) {
|
|
1116
|
+
return this.chain(stringValidators.minLength(min));
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Creates a validator that asserts that the input string has at most the given maximum
|
|
1120
|
+
* length.
|
|
1121
|
+
*
|
|
1122
|
+
* @param max The string must be at most this length.
|
|
1123
|
+
*/
|
|
1124
|
+
maxLength(max) {
|
|
1125
|
+
return this.chain(stringValidators.maxLength(max));
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Creates a validator that asserts that the input string has no whitespace characters.
|
|
1129
|
+
* Whitespace characters include space, new line, carriage return, and tab.
|
|
1130
|
+
*/
|
|
1131
|
+
noWhitespace() {
|
|
1132
|
+
return this.chain(stringValidators.noWhitespace());
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Creates a validator that asserts that the input string matches the given regex.
|
|
1136
|
+
* @param regex
|
|
1137
|
+
*/
|
|
1138
|
+
matches(regex) {
|
|
1139
|
+
return this.chain(stringValidators.matches(regex));
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
__publicField(_StringSchema, "_base", null);
|
|
1143
|
+
var StringSchema = _StringSchema;
|
|
1144
|
+
|
|
1145
|
+
// src/validation/RecordSchema.ts
|
|
1146
|
+
var locale11 = {
|
|
1147
|
+
record: "{ [key: {key}]: {value} }"
|
|
1148
|
+
};
|
|
1149
|
+
var recordValidators = {
|
|
1150
|
+
/**
|
|
1151
|
+
* Returns a validator that asserts that the object's own enumerable properties has keys and
|
|
1152
|
+
* values that match their respective validators.
|
|
1153
|
+
*
|
|
1154
|
+
* Prototype members are not included.
|
|
1155
|
+
* Numeric keys are validated as strings. For example the object `{ [0]: 1 }` will be passed
|
|
1156
|
+
* to the key validator as '0'.
|
|
1157
|
+
*
|
|
1158
|
+
* @param keyValidator Validates each key.
|
|
1159
|
+
* @param valueValidator Validates each value.
|
|
1160
|
+
*/
|
|
1161
|
+
record(keyValidator, valueValidator) {
|
|
1162
|
+
return createDeepValidator(
|
|
1163
|
+
(0, import_vinyl_util13.substitute)(locale11.record, {
|
|
1164
|
+
key: keyValidator.description,
|
|
1165
|
+
value: valueValidator.description
|
|
1166
|
+
}),
|
|
1167
|
+
(input, options, path) => {
|
|
1168
|
+
const errors = [];
|
|
1169
|
+
for (const key of (0, import_vinyl_util13.ownKeys)(input)) {
|
|
1170
|
+
const keyStr = String(key);
|
|
1171
|
+
errors.push(
|
|
1172
|
+
...keyValidator.validate(
|
|
1173
|
+
key,
|
|
1174
|
+
options,
|
|
1175
|
+
path.concat(`[${keyStr}]`)
|
|
1176
|
+
)
|
|
1177
|
+
);
|
|
1178
|
+
if (!options.all && errors.length) return errors;
|
|
1179
|
+
const value = input[key];
|
|
1180
|
+
errors.push(
|
|
1181
|
+
...valueValidator.validate(
|
|
1182
|
+
value,
|
|
1183
|
+
options,
|
|
1184
|
+
path.concat(keyStr)
|
|
1185
|
+
)
|
|
1186
|
+
);
|
|
1187
|
+
if (!options.all && errors.length) return errors;
|
|
1188
|
+
}
|
|
1189
|
+
return errors;
|
|
1190
|
+
}
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1193
|
+
};
|
|
1194
|
+
var _RecordSchema = class _RecordSchema extends ValueSchema {
|
|
1195
|
+
/**
|
|
1196
|
+
* The base Object validator validating that the input is an object.
|
|
1197
|
+
*/
|
|
1198
|
+
static get base() {
|
|
1199
|
+
if (this._base == null)
|
|
1200
|
+
this._base = new _RecordSchema(typeOfValidators.object);
|
|
1201
|
+
return this._base;
|
|
1202
|
+
}
|
|
1203
|
+
static get defaultKeyValidator() {
|
|
1204
|
+
return StringSchema.base;
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Returns a validator that asserts that the object's own enumerable properties has keys and
|
|
1208
|
+
* values that match their respective validators.
|
|
1209
|
+
*
|
|
1210
|
+
* Prototype members are not included.
|
|
1211
|
+
* Numeric keys are validated as strings. For example the object `{ [0]: 1 }` will be passed
|
|
1212
|
+
* to the key validator as '0'.
|
|
1213
|
+
*
|
|
1214
|
+
* @param keyValidator Validates each key.
|
|
1215
|
+
* @param valueValidator Validates each value.
|
|
1216
|
+
*/
|
|
1217
|
+
record(keyValidator, valueValidator) {
|
|
1218
|
+
return this.chain(recordValidators.record(keyValidator, valueValidator));
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Returns a validator that asserts that the object's own enumerable properties has
|
|
1222
|
+
* string keys and values that match the given validator.
|
|
1223
|
+
*
|
|
1224
|
+
* Prototype members are not included.
|
|
1225
|
+
*
|
|
1226
|
+
* @param valueValidator Validates each value.
|
|
1227
|
+
*/
|
|
1228
|
+
recordValues(valueValidator) {
|
|
1229
|
+
return this.record(_RecordSchema.defaultKeyValidator, valueValidator);
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* Casts to a ReadonlyRecord
|
|
1233
|
+
*/
|
|
1234
|
+
readonly() {
|
|
1235
|
+
return this;
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Casts the type parameter.
|
|
1239
|
+
*/
|
|
1240
|
+
cast() {
|
|
1241
|
+
return this;
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
__publicField(_RecordSchema, "_base", null);
|
|
1245
|
+
var RecordSchema = _RecordSchema;
|
|
1246
|
+
|
|
1247
|
+
// src/validation/validators.ts
|
|
1248
|
+
var locale12 = {
|
|
1249
|
+
isOneOf: "one of: {value}",
|
|
1250
|
+
instanceOf: "instance of {value}",
|
|
1251
|
+
oneOfSeparator: " | "
|
|
1252
|
+
};
|
|
1253
|
+
function any() {
|
|
1254
|
+
return new ValueSchema(valueValidators.any());
|
|
1255
|
+
}
|
|
1256
|
+
function array(elementValidator) {
|
|
1257
|
+
if (!elementValidator) return ArraySchema.base;
|
|
1258
|
+
else return ArraySchema.base.withElements(elementValidator);
|
|
1259
|
+
}
|
|
1260
|
+
function boolean() {
|
|
1261
|
+
return new ValueSchema(typeOfValidators.boolean);
|
|
1262
|
+
}
|
|
1263
|
+
function func() {
|
|
1264
|
+
return FunctionSchema.base;
|
|
1265
|
+
}
|
|
1266
|
+
function instanceOf(clazz) {
|
|
1267
|
+
return new ValueSchema(
|
|
1268
|
+
createValidator(
|
|
1269
|
+
(0, import_vinyl_util14.substitute)(locale12.instanceOf, { value: clazz.name }),
|
|
1270
|
+
(input) => input instanceof clazz
|
|
1271
|
+
)
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1274
|
+
function isOneOf(...possibleValues) {
|
|
1275
|
+
return new ValueSchema(
|
|
1276
|
+
createValidator(
|
|
1277
|
+
(0, import_vinyl_util14.substitute)(locale12.isOneOf, {
|
|
1278
|
+
value: possibleValues.join(locale12.oneOfSeparator)
|
|
1279
|
+
}),
|
|
1280
|
+
(input) => possibleValues.includes(input)
|
|
1281
|
+
)
|
|
1282
|
+
);
|
|
1283
|
+
}
|
|
1284
|
+
function enumOf(enumObject) {
|
|
1285
|
+
return isOneOf(...Object.values(enumObject));
|
|
1286
|
+
}
|
|
1287
|
+
function exactlyNull() {
|
|
1288
|
+
return valueValidators.null();
|
|
1289
|
+
}
|
|
1290
|
+
function nullish() {
|
|
1291
|
+
return valueValidators.nullish();
|
|
1292
|
+
}
|
|
1293
|
+
function number() {
|
|
1294
|
+
return NumberSchema.base;
|
|
1295
|
+
}
|
|
1296
|
+
function object(propertyValidators) {
|
|
1297
|
+
return ObjectSchema.base.extend(propertyValidators);
|
|
1298
|
+
}
|
|
1299
|
+
function record(keyValidator, valueValidator) {
|
|
1300
|
+
return RecordSchema.base.record(keyValidator, valueValidator);
|
|
1301
|
+
}
|
|
1302
|
+
function recordValues(valueValidator) {
|
|
1303
|
+
return RecordSchema.base.recordValues(valueValidator);
|
|
1304
|
+
}
|
|
1305
|
+
function set(elementValidator) {
|
|
1306
|
+
return SetSchema.base.withElements(elementValidator);
|
|
1307
|
+
}
|
|
1308
|
+
function string() {
|
|
1309
|
+
return StringSchema.base;
|
|
1310
|
+
}
|
|
1311
|
+
function tuple(...validators) {
|
|
1312
|
+
return ArraySchema.base.tuple(...validators);
|
|
1313
|
+
}
|
|
1314
|
+
function symbol() {
|
|
1315
|
+
return new ValueSchema(typeOfValidators.symbol);
|
|
1316
|
+
}
|
|
1317
|
+
function exactlyUndefined() {
|
|
1318
|
+
return new ValueSchema(valueValidators.undefined());
|
|
1319
|
+
}
|
|
1320
|
+
function custom(expectationMessage, isValid, inputStringify = (input) => (0, import_vinyl_util14.stringifyForPrint)(input, 500)) {
|
|
1321
|
+
return new ValueSchema(
|
|
1322
|
+
createValidator(expectationMessage, isValid, inputStringify)
|
|
1323
|
+
);
|
|
1324
|
+
}
|
|
1325
|
+
//# sourceMappingURL=index.cjs.map
|