@modulify/validator 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -1
- package/README.md +12 -2
- package/dist/assert-BDOtHdLx.cjs +289 -0
- package/dist/assert-CzMg5aO7.mjs +206 -0
- package/dist/assert.cjs +7 -65
- package/dist/assert.d.cts +37 -0
- package/dist/assert.d.mts +37 -0
- package/dist/assert.d.ts +24 -3
- package/dist/assert.mjs +2 -66
- package/dist/assertions-DPYCHREw.mjs +297 -0
- package/dist/assertions-nfOKqcjs.cjs +476 -0
- package/dist/assertions.cjs +34 -206
- package/dist/assertions.d.cts +56 -0
- package/dist/assertions.d.mts +56 -0
- package/dist/assertions.d.ts +43 -45
- package/dist/assertions.mjs +3 -207
- package/dist/checkers.d.cts +8 -0
- package/dist/checkers.d.mts +8 -0
- package/dist/checkers.d.ts +1 -1
- package/dist/combinators.cjs +303 -304
- package/dist/combinators.d.cts +16 -0
- package/dist/combinators.d.mts +16 -0
- package/dist/combinators.d.ts +15 -16
- package/dist/combinators.mjs +304 -315
- package/dist/constraints.d.cts +4 -0
- package/dist/constraints.d.mts +4 -0
- package/dist/constraints.d.ts +2 -2
- package/dist/extractors.d.cts +2 -0
- package/dist/extractors.d.mts +2 -0
- package/dist/index.cjs +210 -213
- package/dist/index.d.cts +12 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.mjs +165 -218
- package/dist/json-schema.cjs +364 -489
- package/dist/json-schema.d.cts +14 -0
- package/dist/json-schema.d.mts +14 -0
- package/dist/json-schema.d.ts +3 -3
- package/dist/json-schema.mjs +365 -492
- package/dist/metadata.cjs +6 -7
- package/dist/metadata.d.cts +8 -0
- package/dist/metadata.d.mts +8 -0
- package/dist/metadata.d.ts +2 -2
- package/dist/metadata.mjs +2 -8
- package/dist/predicates.cjs +98 -41
- package/dist/predicates.d.cts +77 -0
- package/dist/predicates.d.mts +77 -0
- package/dist/predicates.d.ts +25 -4
- package/dist/predicates.mjs +92 -66
- package/dist/types/index.d.cts +984 -0
- package/dist/types/index.d.mts +984 -0
- package/dist/types/index.d.ts +984 -0
- package/dist/types/json-schema.d.cts +75 -0
- package/dist/types/json-schema.d.mts +75 -0
- package/dist/types/json-schema.d.ts +75 -0
- package/dist/violations.d.cts +29 -0
- package/dist/violations.d.mts +29 -0
- package/dist/violations.d.ts +1 -1
- package/docs/RELEASING.md +66 -0
- package/docs/en/00-index.md +2 -0
- package/docs/en/01-shape-api.md +35 -10
- package/docs/en/02-metadata-and-introspection.md +2 -1
- package/docs/en/03-violations.md +1 -1
- package/docs/en/04-json-schema-export.md +5 -0
- package/docs/en/05-public-api.md +35 -3
- package/docs/en/06-common-recipes.md +2 -1
- package/docs/en/07-ai-reference.md +5 -2
- package/docs/en/08-violation-code-types.md +28 -2
- package/docs/en/09-migration.md +75 -0
- package/docs/ru/00-index.md +2 -0
- package/docs/ru/01-shape-api.md +35 -10
- package/docs/ru/02-metadata-and-introspection.md +2 -1
- package/docs/ru/03-violations.md +1 -1
- package/docs/ru/04-json-schema-export.md +5 -0
- package/docs/ru/05-public-api.md +35 -3
- package/docs/ru/06-common-recipes.md +2 -1
- package/docs/ru/07-ai-reference.md +5 -2
- package/docs/ru/08-violation-code-types.md +28 -2
- package/docs/ru/09-migration.md +76 -0
- package/docs/ru/README.md +10 -2
- package/package.json +63 -37
- package/types/index.d.ts +275 -115
- package/dist/metadata.cjs.js +0 -130
- package/dist/metadata.es.js +0 -131
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
const require_assert = require("./assert-BDOtHdLx.cjs");
|
|
2
|
+
const require_predicates = require("./predicates.cjs");
|
|
3
|
+
//#region src/checkers.ts
|
|
4
|
+
var isEqual = (value, exact) => value === exact;
|
|
5
|
+
var isGte = (value, min) => value >= min;
|
|
6
|
+
var isLte = (value, max) => value <= max;
|
|
7
|
+
var inRange = (value, [min, max]) => value >= min && value <= max;
|
|
8
|
+
var startsWith$1 = (value, prefix) => value.startsWith(prefix);
|
|
9
|
+
var endsWith$1 = (value, suffix) => value.endsWith(suffix);
|
|
10
|
+
var matchesPattern = (value, pattern) => new RegExp(pattern.source, pattern.flags).test(value);
|
|
11
|
+
var isMultipleOf = (value, step) => {
|
|
12
|
+
if (step === 0) return false;
|
|
13
|
+
const quotient = value / step;
|
|
14
|
+
const delta = Math.abs(quotient - Math.round(quotient));
|
|
15
|
+
return Number.isFinite(quotient) && delta <= Number.EPSILON * Math.max(1, Math.abs(quotient)) * 16;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/extractors.ts
|
|
19
|
+
var length = (value) => value.length;
|
|
20
|
+
var size = (value) => value.size;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/assertions.ts
|
|
23
|
+
var buildLengthConstraints = (options) => {
|
|
24
|
+
const { exact = null, max = null, min = null, range = null } = options;
|
|
25
|
+
const constraints = [];
|
|
26
|
+
if (exact !== null) constraints.push([
|
|
27
|
+
length,
|
|
28
|
+
isEqual,
|
|
29
|
+
"length.exact",
|
|
30
|
+
exact
|
|
31
|
+
]);
|
|
32
|
+
if (max !== null) constraints.push([
|
|
33
|
+
length,
|
|
34
|
+
isLte,
|
|
35
|
+
"length.max",
|
|
36
|
+
max
|
|
37
|
+
]);
|
|
38
|
+
if (min !== null) constraints.push([
|
|
39
|
+
length,
|
|
40
|
+
isGte,
|
|
41
|
+
"length.min",
|
|
42
|
+
min
|
|
43
|
+
]);
|
|
44
|
+
if (range !== null) constraints.push([
|
|
45
|
+
length,
|
|
46
|
+
inRange,
|
|
47
|
+
"length.range",
|
|
48
|
+
range
|
|
49
|
+
]);
|
|
50
|
+
return constraints;
|
|
51
|
+
};
|
|
52
|
+
var buildSizeConstraints = (options) => {
|
|
53
|
+
const { exact = null, max = null, min = null, range = null } = options;
|
|
54
|
+
const constraints = [];
|
|
55
|
+
if (exact !== null) constraints.push([
|
|
56
|
+
size,
|
|
57
|
+
isEqual,
|
|
58
|
+
"size.exact",
|
|
59
|
+
exact
|
|
60
|
+
]);
|
|
61
|
+
if (max !== null) constraints.push([
|
|
62
|
+
size,
|
|
63
|
+
isLte,
|
|
64
|
+
"size.max",
|
|
65
|
+
max
|
|
66
|
+
]);
|
|
67
|
+
if (min !== null) constraints.push([
|
|
68
|
+
size,
|
|
69
|
+
isGte,
|
|
70
|
+
"size.min",
|
|
71
|
+
min
|
|
72
|
+
]);
|
|
73
|
+
if (range !== null) constraints.push([
|
|
74
|
+
size,
|
|
75
|
+
inRange,
|
|
76
|
+
"size.range",
|
|
77
|
+
range
|
|
78
|
+
]);
|
|
79
|
+
return constraints;
|
|
80
|
+
};
|
|
81
|
+
var buildValueConstraints = (options) => {
|
|
82
|
+
const { exact = null, max = null, min = null, range = null } = options;
|
|
83
|
+
const constraints = [];
|
|
84
|
+
if (exact !== null) constraints.push([
|
|
85
|
+
(value) => value,
|
|
86
|
+
isEqual,
|
|
87
|
+
"number.exact",
|
|
88
|
+
exact
|
|
89
|
+
]);
|
|
90
|
+
if (max !== null) constraints.push([
|
|
91
|
+
(value) => value,
|
|
92
|
+
isLte,
|
|
93
|
+
"number.max",
|
|
94
|
+
max
|
|
95
|
+
]);
|
|
96
|
+
if (min !== null) constraints.push([
|
|
97
|
+
(value) => value,
|
|
98
|
+
isGte,
|
|
99
|
+
"number.min",
|
|
100
|
+
min
|
|
101
|
+
]);
|
|
102
|
+
if (range !== null) constraints.push([
|
|
103
|
+
(value) => value,
|
|
104
|
+
inRange,
|
|
105
|
+
"number.range",
|
|
106
|
+
range
|
|
107
|
+
]);
|
|
108
|
+
return constraints;
|
|
109
|
+
};
|
|
110
|
+
var isBoolean = /* @__PURE__ */ require_assert.assert(require_predicates.isBoolean, {
|
|
111
|
+
name: "isBoolean",
|
|
112
|
+
bail: true,
|
|
113
|
+
code: "type.boolean"
|
|
114
|
+
});
|
|
115
|
+
var isBigInt = /* @__PURE__ */ require_assert.assert(require_predicates.isBigInt, {
|
|
116
|
+
name: "isBigInt",
|
|
117
|
+
bail: true,
|
|
118
|
+
code: "type.bigint"
|
|
119
|
+
});
|
|
120
|
+
var isBlob = /* @__PURE__ */ require_assert.assert(require_predicates.isBlob, {
|
|
121
|
+
name: "isBlob",
|
|
122
|
+
bail: true,
|
|
123
|
+
code: "type.blob"
|
|
124
|
+
});
|
|
125
|
+
var isDate = /* @__PURE__ */ require_assert.assert(require_predicates.isDate, {
|
|
126
|
+
name: "isDate",
|
|
127
|
+
bail: true,
|
|
128
|
+
code: "type.date"
|
|
129
|
+
});
|
|
130
|
+
var isDefined = /* @__PURE__ */ require_assert.assert((value) => value !== void 0, {
|
|
131
|
+
name: "isDefined",
|
|
132
|
+
bail: true,
|
|
133
|
+
code: "value.defined"
|
|
134
|
+
});
|
|
135
|
+
var isEmail = /* @__PURE__ */ require_assert.assert(require_predicates.isEmail, {
|
|
136
|
+
name: "isEmail",
|
|
137
|
+
bail: true,
|
|
138
|
+
code: "string.email"
|
|
139
|
+
});
|
|
140
|
+
var isError = /* @__PURE__ */ require_assert.assert(require_predicates.isError, {
|
|
141
|
+
name: "isError",
|
|
142
|
+
bail: true,
|
|
143
|
+
code: "type.error"
|
|
144
|
+
});
|
|
145
|
+
var isFiniteNumber = /* @__PURE__ */ require_assert.assert(require_predicates.isFiniteNumber, {
|
|
146
|
+
name: "isFiniteNumber",
|
|
147
|
+
bail: true,
|
|
148
|
+
code: "number.finite"
|
|
149
|
+
});
|
|
150
|
+
var isFile = /* @__PURE__ */ require_assert.assert(require_predicates.isFile, {
|
|
151
|
+
name: "isFile",
|
|
152
|
+
bail: true,
|
|
153
|
+
code: "type.file"
|
|
154
|
+
});
|
|
155
|
+
var isFunction = /* @__PURE__ */ require_assert.assert(require_predicates.isFunction, {
|
|
156
|
+
name: "isFunction",
|
|
157
|
+
bail: true,
|
|
158
|
+
code: "type.function"
|
|
159
|
+
});
|
|
160
|
+
var isInteger = /* @__PURE__ */ require_assert.assert(require_predicates.isInteger, {
|
|
161
|
+
name: "isInteger",
|
|
162
|
+
bail: true,
|
|
163
|
+
code: "number.integer"
|
|
164
|
+
});
|
|
165
|
+
var isMap = /* @__PURE__ */ require_assert.assert(require_predicates.isMap, {
|
|
166
|
+
name: "isMap",
|
|
167
|
+
bail: true,
|
|
168
|
+
code: "type.map"
|
|
169
|
+
});
|
|
170
|
+
var isNaN = /* @__PURE__ */ require_assert.assert(require_predicates.isNaN, {
|
|
171
|
+
name: "isNaN",
|
|
172
|
+
bail: true,
|
|
173
|
+
code: "number.nan"
|
|
174
|
+
});
|
|
175
|
+
var isNull = /* @__PURE__ */ require_assert.assert(require_predicates.isNull, {
|
|
176
|
+
name: "isNull",
|
|
177
|
+
bail: true,
|
|
178
|
+
code: "type.null"
|
|
179
|
+
});
|
|
180
|
+
var isNumber = /* @__PURE__ */ require_assert.assert(require_predicates.isNumber, {
|
|
181
|
+
name: "isNumber",
|
|
182
|
+
bail: true,
|
|
183
|
+
code: "type.number"
|
|
184
|
+
});
|
|
185
|
+
var isPromiseLike = /* @__PURE__ */ require_assert.assert(require_predicates.isPromiseLike, {
|
|
186
|
+
name: "isPromiseLike",
|
|
187
|
+
bail: true,
|
|
188
|
+
code: "type.promise-like"
|
|
189
|
+
});
|
|
190
|
+
var isRegExp = /* @__PURE__ */ require_assert.assert(require_predicates.isRegExp, {
|
|
191
|
+
name: "isRegExp",
|
|
192
|
+
bail: true,
|
|
193
|
+
code: "type.regexp"
|
|
194
|
+
});
|
|
195
|
+
var isSafeInteger = /* @__PURE__ */ require_assert.assert(require_predicates.isSafeInteger, {
|
|
196
|
+
name: "isSafeInteger",
|
|
197
|
+
bail: true,
|
|
198
|
+
code: "number.safe-integer"
|
|
199
|
+
});
|
|
200
|
+
var isSet = /* @__PURE__ */ require_assert.assert(require_predicates.isSet, {
|
|
201
|
+
name: "isSet",
|
|
202
|
+
bail: true,
|
|
203
|
+
code: "type.set"
|
|
204
|
+
});
|
|
205
|
+
var isString = /* @__PURE__ */ require_assert.assert(require_predicates.isString, {
|
|
206
|
+
name: "isString",
|
|
207
|
+
bail: true,
|
|
208
|
+
code: "type.string"
|
|
209
|
+
});
|
|
210
|
+
var isSymbol = /* @__PURE__ */ require_assert.assert(require_predicates.isSymbol, {
|
|
211
|
+
name: "isSymbol",
|
|
212
|
+
bail: true,
|
|
213
|
+
code: "type.symbol"
|
|
214
|
+
});
|
|
215
|
+
var isValidDate = /* @__PURE__ */ require_assert.assert(require_predicates.isValidDate, {
|
|
216
|
+
name: "isValidDate",
|
|
217
|
+
bail: true,
|
|
218
|
+
code: "date.valid"
|
|
219
|
+
});
|
|
220
|
+
var hasLength = (options = {}) => {
|
|
221
|
+
const { bail = false } = options;
|
|
222
|
+
const constraints = buildLengthConstraints(options);
|
|
223
|
+
return /* @__PURE__ */ require_assert.createRefinement({
|
|
224
|
+
name: "hasLength",
|
|
225
|
+
bail,
|
|
226
|
+
code: "length.unsupported-type"
|
|
227
|
+
}, constraints);
|
|
228
|
+
};
|
|
229
|
+
var hasSize = (options = {}) => {
|
|
230
|
+
const { bail = false } = options;
|
|
231
|
+
const constraints = buildSizeConstraints(options);
|
|
232
|
+
return /* @__PURE__ */ require_assert.createRefinement({
|
|
233
|
+
name: "hasSize",
|
|
234
|
+
bail,
|
|
235
|
+
code: "size.unsupported-type"
|
|
236
|
+
}, constraints);
|
|
237
|
+
};
|
|
238
|
+
var hasPattern = (pattern, { bail = false } = {}) => /* @__PURE__ */ require_assert.createRefinement({
|
|
239
|
+
name: "hasPattern",
|
|
240
|
+
bail,
|
|
241
|
+
code: "string.unsupported-type"
|
|
242
|
+
}, [[
|
|
243
|
+
(value) => value,
|
|
244
|
+
matchesPattern,
|
|
245
|
+
"string.pattern",
|
|
246
|
+
pattern
|
|
247
|
+
]]);
|
|
248
|
+
var startsWith = (prefix, { bail = false } = {}) => /* @__PURE__ */ require_assert.createRefinement({
|
|
249
|
+
name: "startsWith",
|
|
250
|
+
bail,
|
|
251
|
+
code: "string.unsupported-type"
|
|
252
|
+
}, [[
|
|
253
|
+
(value) => value,
|
|
254
|
+
startsWith$1,
|
|
255
|
+
"string.starts-with",
|
|
256
|
+
prefix
|
|
257
|
+
]]);
|
|
258
|
+
var endsWith = (suffix, { bail = false } = {}) => /* @__PURE__ */ require_assert.createRefinement({
|
|
259
|
+
name: "endsWith",
|
|
260
|
+
bail,
|
|
261
|
+
code: "string.unsupported-type"
|
|
262
|
+
}, [[
|
|
263
|
+
(value) => value,
|
|
264
|
+
endsWith$1,
|
|
265
|
+
"string.ends-with",
|
|
266
|
+
suffix
|
|
267
|
+
]]);
|
|
268
|
+
var hasValue = (options = {}) => {
|
|
269
|
+
const { bail = false } = options;
|
|
270
|
+
const constraints = buildValueConstraints(options);
|
|
271
|
+
return /* @__PURE__ */ require_assert.createRefinement({
|
|
272
|
+
name: "hasValue",
|
|
273
|
+
bail,
|
|
274
|
+
code: "number.unsupported-type"
|
|
275
|
+
}, constraints);
|
|
276
|
+
};
|
|
277
|
+
var multipleOf = (step, { bail = false } = {}) => /* @__PURE__ */ require_assert.createRefinement({
|
|
278
|
+
name: "multipleOf",
|
|
279
|
+
bail,
|
|
280
|
+
code: "number.unsupported-type"
|
|
281
|
+
}, [[
|
|
282
|
+
(value) => value,
|
|
283
|
+
isMultipleOf,
|
|
284
|
+
"number.multiple-of",
|
|
285
|
+
step
|
|
286
|
+
]]);
|
|
287
|
+
var oneOf = (values, { equalTo = (a, b) => a === b, bail = false } = {}) => {
|
|
288
|
+
const haystack = require_predicates.isArray(values) ? values : Object.values(values);
|
|
289
|
+
return /* @__PURE__ */ require_assert.assert((value) => haystack.some((item) => equalTo(item, value)), {
|
|
290
|
+
name: "oneOf",
|
|
291
|
+
bail,
|
|
292
|
+
code: "value.one-of",
|
|
293
|
+
args: [haystack]
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
//#endregion
|
|
297
|
+
Object.defineProperty(exports, "endsWith", {
|
|
298
|
+
enumerable: true,
|
|
299
|
+
get: function() {
|
|
300
|
+
return endsWith;
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
Object.defineProperty(exports, "hasLength", {
|
|
304
|
+
enumerable: true,
|
|
305
|
+
get: function() {
|
|
306
|
+
return hasLength;
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
Object.defineProperty(exports, "hasPattern", {
|
|
310
|
+
enumerable: true,
|
|
311
|
+
get: function() {
|
|
312
|
+
return hasPattern;
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
Object.defineProperty(exports, "hasSize", {
|
|
316
|
+
enumerable: true,
|
|
317
|
+
get: function() {
|
|
318
|
+
return hasSize;
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
Object.defineProperty(exports, "hasValue", {
|
|
322
|
+
enumerable: true,
|
|
323
|
+
get: function() {
|
|
324
|
+
return hasValue;
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
Object.defineProperty(exports, "isBigInt", {
|
|
328
|
+
enumerable: true,
|
|
329
|
+
get: function() {
|
|
330
|
+
return isBigInt;
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
Object.defineProperty(exports, "isBlob", {
|
|
334
|
+
enumerable: true,
|
|
335
|
+
get: function() {
|
|
336
|
+
return isBlob;
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
Object.defineProperty(exports, "isBoolean", {
|
|
340
|
+
enumerable: true,
|
|
341
|
+
get: function() {
|
|
342
|
+
return isBoolean;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
Object.defineProperty(exports, "isDate", {
|
|
346
|
+
enumerable: true,
|
|
347
|
+
get: function() {
|
|
348
|
+
return isDate;
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
Object.defineProperty(exports, "isDefined", {
|
|
352
|
+
enumerable: true,
|
|
353
|
+
get: function() {
|
|
354
|
+
return isDefined;
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
Object.defineProperty(exports, "isEmail", {
|
|
358
|
+
enumerable: true,
|
|
359
|
+
get: function() {
|
|
360
|
+
return isEmail;
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
Object.defineProperty(exports, "isError", {
|
|
364
|
+
enumerable: true,
|
|
365
|
+
get: function() {
|
|
366
|
+
return isError;
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
Object.defineProperty(exports, "isFile", {
|
|
370
|
+
enumerable: true,
|
|
371
|
+
get: function() {
|
|
372
|
+
return isFile;
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
Object.defineProperty(exports, "isFiniteNumber", {
|
|
376
|
+
enumerable: true,
|
|
377
|
+
get: function() {
|
|
378
|
+
return isFiniteNumber;
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
Object.defineProperty(exports, "isFunction", {
|
|
382
|
+
enumerable: true,
|
|
383
|
+
get: function() {
|
|
384
|
+
return isFunction;
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
Object.defineProperty(exports, "isInteger", {
|
|
388
|
+
enumerable: true,
|
|
389
|
+
get: function() {
|
|
390
|
+
return isInteger;
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
Object.defineProperty(exports, "isMap", {
|
|
394
|
+
enumerable: true,
|
|
395
|
+
get: function() {
|
|
396
|
+
return isMap;
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
Object.defineProperty(exports, "isNaN", {
|
|
400
|
+
enumerable: true,
|
|
401
|
+
get: function() {
|
|
402
|
+
return isNaN;
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
Object.defineProperty(exports, "isNull", {
|
|
406
|
+
enumerable: true,
|
|
407
|
+
get: function() {
|
|
408
|
+
return isNull;
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
Object.defineProperty(exports, "isNumber", {
|
|
412
|
+
enumerable: true,
|
|
413
|
+
get: function() {
|
|
414
|
+
return isNumber;
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
Object.defineProperty(exports, "isPromiseLike", {
|
|
418
|
+
enumerable: true,
|
|
419
|
+
get: function() {
|
|
420
|
+
return isPromiseLike;
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
Object.defineProperty(exports, "isRegExp", {
|
|
424
|
+
enumerable: true,
|
|
425
|
+
get: function() {
|
|
426
|
+
return isRegExp;
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
Object.defineProperty(exports, "isSafeInteger", {
|
|
430
|
+
enumerable: true,
|
|
431
|
+
get: function() {
|
|
432
|
+
return isSafeInteger;
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
Object.defineProperty(exports, "isSet", {
|
|
436
|
+
enumerable: true,
|
|
437
|
+
get: function() {
|
|
438
|
+
return isSet;
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
Object.defineProperty(exports, "isString", {
|
|
442
|
+
enumerable: true,
|
|
443
|
+
get: function() {
|
|
444
|
+
return isString;
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
Object.defineProperty(exports, "isSymbol", {
|
|
448
|
+
enumerable: true,
|
|
449
|
+
get: function() {
|
|
450
|
+
return isSymbol;
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
Object.defineProperty(exports, "isValidDate", {
|
|
454
|
+
enumerable: true,
|
|
455
|
+
get: function() {
|
|
456
|
+
return isValidDate;
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
Object.defineProperty(exports, "multipleOf", {
|
|
460
|
+
enumerable: true,
|
|
461
|
+
get: function() {
|
|
462
|
+
return multipleOf;
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
Object.defineProperty(exports, "oneOf", {
|
|
466
|
+
enumerable: true,
|
|
467
|
+
get: function() {
|
|
468
|
+
return oneOf;
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
Object.defineProperty(exports, "startsWith", {
|
|
472
|
+
enumerable: true,
|
|
473
|
+
get: function() {
|
|
474
|
+
return startsWith;
|
|
475
|
+
}
|
|
476
|
+
});
|
package/dist/assertions.cjs
CHANGED
|
@@ -1,207 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const isNull = assert.assert(predicates.isNull, { name: "isNull", bail: true, code: "type.null" });
|
|
38
|
-
const isNumber = assert.assert(predicates.isNumber, { name: "isNumber", bail: true, code: "type.number" });
|
|
39
|
-
const isSet = assert.assert(predicates.isSet, { name: "isSet", bail: true, code: "type.set" });
|
|
40
|
-
const isString = assert.assert(predicates.isString, { name: "isString", bail: true, code: "type.string" });
|
|
41
|
-
const isSymbol = assert.assert(predicates.isSymbol, { name: "isSymbol", bail: true, code: "type.symbol" });
|
|
42
|
-
const hasLength = ({
|
|
43
|
-
exact = null,
|
|
44
|
-
max = null,
|
|
45
|
-
min = null,
|
|
46
|
-
range = null,
|
|
47
|
-
bail = false
|
|
48
|
-
} = {}) => {
|
|
49
|
-
const constraints = [];
|
|
50
|
-
if (exact !== null) constraints.push([length, isEqual, "length.exact", exact]);
|
|
51
|
-
if (max !== null) constraints.push([length, isLte, "length.max", max]);
|
|
52
|
-
if (min !== null) constraints.push([length, isGte, "length.min", min]);
|
|
53
|
-
if (range !== null) constraints.push([length, inRange, "length.range", range]);
|
|
54
|
-
return assert.assert(
|
|
55
|
-
(value) => predicates.isArray(value) || predicates.isString(value),
|
|
56
|
-
{
|
|
57
|
-
name: "hasLength",
|
|
58
|
-
bail,
|
|
59
|
-
code: "length.unsupported-type"
|
|
60
|
-
},
|
|
61
|
-
constraints
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
const hasSize = ({
|
|
65
|
-
exact = null,
|
|
66
|
-
max = null,
|
|
67
|
-
min = null,
|
|
68
|
-
range = null,
|
|
69
|
-
bail = false
|
|
70
|
-
} = {}) => {
|
|
71
|
-
const constraints = [];
|
|
72
|
-
if (exact !== null) constraints.push([size, isEqual, "size.exact", exact]);
|
|
73
|
-
if (max !== null) constraints.push([size, isLte, "size.max", max]);
|
|
74
|
-
if (min !== null) constraints.push([size, isGte, "size.min", min]);
|
|
75
|
-
if (range !== null) constraints.push([size, inRange, "size.range", range]);
|
|
76
|
-
return assert.assert(
|
|
77
|
-
(value) => predicates.isMap(value) || predicates.isSet(value),
|
|
78
|
-
{
|
|
79
|
-
name: "hasSize",
|
|
80
|
-
bail,
|
|
81
|
-
code: "size.unsupported-type"
|
|
82
|
-
},
|
|
83
|
-
constraints
|
|
84
|
-
);
|
|
85
|
-
};
|
|
86
|
-
const hasPattern = (pattern, {
|
|
87
|
-
bail = false
|
|
88
|
-
} = {}) => assert.assert(
|
|
89
|
-
predicates.isString,
|
|
90
|
-
{
|
|
91
|
-
name: "hasPattern",
|
|
92
|
-
bail,
|
|
93
|
-
code: "string.unsupported-type"
|
|
94
|
-
},
|
|
95
|
-
[[
|
|
96
|
-
(value) => value,
|
|
97
|
-
matchesPattern,
|
|
98
|
-
"string.pattern",
|
|
99
|
-
pattern
|
|
100
|
-
]]
|
|
101
|
-
);
|
|
102
|
-
const startsWith = (prefix, {
|
|
103
|
-
bail = false
|
|
104
|
-
} = {}) => assert.assert(
|
|
105
|
-
predicates.isString,
|
|
106
|
-
{
|
|
107
|
-
name: "startsWith",
|
|
108
|
-
bail,
|
|
109
|
-
code: "string.unsupported-type"
|
|
110
|
-
},
|
|
111
|
-
[[
|
|
112
|
-
(value) => value,
|
|
113
|
-
startsWith$1,
|
|
114
|
-
"string.starts-with",
|
|
115
|
-
prefix
|
|
116
|
-
]]
|
|
117
|
-
);
|
|
118
|
-
const endsWith = (suffix, {
|
|
119
|
-
bail = false
|
|
120
|
-
} = {}) => assert.assert(
|
|
121
|
-
predicates.isString,
|
|
122
|
-
{
|
|
123
|
-
name: "endsWith",
|
|
124
|
-
bail,
|
|
125
|
-
code: "string.unsupported-type"
|
|
126
|
-
},
|
|
127
|
-
[[
|
|
128
|
-
(value) => value,
|
|
129
|
-
endsWith$1,
|
|
130
|
-
"string.ends-with",
|
|
131
|
-
suffix
|
|
132
|
-
]]
|
|
133
|
-
);
|
|
134
|
-
const hasValue = ({
|
|
135
|
-
exact = null,
|
|
136
|
-
max = null,
|
|
137
|
-
min = null,
|
|
138
|
-
range = null,
|
|
139
|
-
bail = false
|
|
140
|
-
} = {}) => {
|
|
141
|
-
const constraints = [];
|
|
142
|
-
if (exact !== null) constraints.push([(value) => value, isEqual, "number.exact", exact]);
|
|
143
|
-
if (max !== null) constraints.push([(value) => value, isLte, "number.max", max]);
|
|
144
|
-
if (min !== null) constraints.push([(value) => value, isGte, "number.min", min]);
|
|
145
|
-
if (range !== null) constraints.push([(value) => value, inRange, "number.range", range]);
|
|
146
|
-
return assert.assert(
|
|
147
|
-
predicates.isNumber,
|
|
148
|
-
{
|
|
149
|
-
name: "hasValue",
|
|
150
|
-
bail,
|
|
151
|
-
code: "number.unsupported-type"
|
|
152
|
-
},
|
|
153
|
-
constraints
|
|
154
|
-
);
|
|
155
|
-
};
|
|
156
|
-
const multipleOf = (step, {
|
|
157
|
-
bail = false
|
|
158
|
-
} = {}) => assert.assert(
|
|
159
|
-
predicates.isNumber,
|
|
160
|
-
{
|
|
161
|
-
name: "multipleOf",
|
|
162
|
-
bail,
|
|
163
|
-
code: "number.unsupported-type"
|
|
164
|
-
},
|
|
165
|
-
[[
|
|
166
|
-
(value) => value,
|
|
167
|
-
isMultipleOf,
|
|
168
|
-
"number.multiple-of",
|
|
169
|
-
step
|
|
170
|
-
]]
|
|
171
|
-
);
|
|
172
|
-
const oneOf = (values, {
|
|
173
|
-
equalTo = (a, b) => a === b,
|
|
174
|
-
bail = false
|
|
175
|
-
} = {}) => {
|
|
176
|
-
const haystack = predicates.isArray(values) ? values : Object.values(values);
|
|
177
|
-
return assert.assert((value) => haystack.some((item) => equalTo(item, value)), {
|
|
178
|
-
name: "oneOf",
|
|
179
|
-
bail,
|
|
180
|
-
code: "value.one-of",
|
|
181
|
-
args: [haystack]
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
exports.assert = assert.assert;
|
|
185
|
-
exports.endsWith = endsWith;
|
|
186
|
-
exports.hasLength = hasLength;
|
|
187
|
-
exports.hasPattern = hasPattern;
|
|
188
|
-
exports.hasSize = hasSize;
|
|
189
|
-
exports.hasValue = hasValue;
|
|
190
|
-
exports.isBigInt = isBigInt;
|
|
191
|
-
exports.isBlob = isBlob;
|
|
192
|
-
exports.isBoolean = isBoolean;
|
|
193
|
-
exports.isDate = isDate;
|
|
194
|
-
exports.isDefined = isDefined;
|
|
195
|
-
exports.isEmail = isEmail;
|
|
196
|
-
exports.isFile = isFile;
|
|
197
|
-
exports.isFunction = isFunction;
|
|
198
|
-
exports.isMap = isMap;
|
|
199
|
-
exports.isNaN = isNaN;
|
|
200
|
-
exports.isNull = isNull;
|
|
201
|
-
exports.isNumber = isNumber;
|
|
202
|
-
exports.isSet = isSet;
|
|
203
|
-
exports.isString = isString;
|
|
204
|
-
exports.isSymbol = isSymbol;
|
|
205
|
-
exports.multipleOf = multipleOf;
|
|
206
|
-
exports.oneOf = oneOf;
|
|
207
|
-
exports.startsWith = startsWith;
|
|
2
|
+
const require_assert = require("./assert-BDOtHdLx.cjs");
|
|
3
|
+
const require_assertions = require("./assertions-nfOKqcjs.cjs");
|
|
4
|
+
exports.assert = require_assert.assert;
|
|
5
|
+
exports.endsWith = require_assertions.endsWith;
|
|
6
|
+
exports.hasLength = require_assertions.hasLength;
|
|
7
|
+
exports.hasPattern = require_assertions.hasPattern;
|
|
8
|
+
exports.hasSize = require_assertions.hasSize;
|
|
9
|
+
exports.hasValue = require_assertions.hasValue;
|
|
10
|
+
exports.isBigInt = require_assertions.isBigInt;
|
|
11
|
+
exports.isBlob = require_assertions.isBlob;
|
|
12
|
+
exports.isBoolean = require_assertions.isBoolean;
|
|
13
|
+
exports.isDate = require_assertions.isDate;
|
|
14
|
+
exports.isDefined = require_assertions.isDefined;
|
|
15
|
+
exports.isEmail = require_assertions.isEmail;
|
|
16
|
+
exports.isError = require_assertions.isError;
|
|
17
|
+
exports.isFile = require_assertions.isFile;
|
|
18
|
+
exports.isFiniteNumber = require_assertions.isFiniteNumber;
|
|
19
|
+
exports.isFunction = require_assertions.isFunction;
|
|
20
|
+
exports.isInteger = require_assertions.isInteger;
|
|
21
|
+
exports.isMap = require_assertions.isMap;
|
|
22
|
+
exports.isNaN = require_assertions.isNaN;
|
|
23
|
+
exports.isNull = require_assertions.isNull;
|
|
24
|
+
exports.isNumber = require_assertions.isNumber;
|
|
25
|
+
exports.isPromiseLike = require_assertions.isPromiseLike;
|
|
26
|
+
exports.isRegExp = require_assertions.isRegExp;
|
|
27
|
+
exports.isSafeInteger = require_assertions.isSafeInteger;
|
|
28
|
+
exports.isSet = require_assertions.isSet;
|
|
29
|
+
exports.isString = require_assertions.isString;
|
|
30
|
+
exports.isSymbol = require_assertions.isSymbol;
|
|
31
|
+
exports.isValidDate = require_assertions.isValidDate;
|
|
32
|
+
exports.multipleOf = require_assertions.multipleOf;
|
|
33
|
+
exports.oneOf = require_assertions.oneOf;
|
|
34
|
+
exports.refine = require_assert.refine;
|
|
35
|
+
exports.startsWith = require_assertions.startsWith;
|