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