@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,37 @@
|
|
|
1
|
+
import { Assertion, Constraint, AssertionConstraint, Guard, Predicate, Refinement } from './types/index.mjs';
|
|
2
|
+
type AssertMeta = {
|
|
3
|
+
name: string;
|
|
4
|
+
bail: boolean;
|
|
5
|
+
code?: string;
|
|
6
|
+
args?: readonly unknown[];
|
|
7
|
+
};
|
|
8
|
+
type ResolveAssertionCode<Name extends string, Code extends string | undefined> = Code extends string ? Code : Name;
|
|
9
|
+
type ResolveAssertionArgs<Args extends readonly unknown[] | undefined> = Args extends readonly unknown[] ? Args : [];
|
|
10
|
+
type ConstraintInputFunction<C extends AssertionConstraint> = C extends unknown ? (value: Parameters<C[0]>[0]) => void : never;
|
|
11
|
+
type ConstraintInput<C extends readonly AssertionConstraint[]> = C extends readonly [] ? unknown : ConstraintInputFunction<C[number]> extends (value: infer Input) => void ? Input : never;
|
|
12
|
+
type ConstraintArgs<C extends AssertionConstraint> = C extends readonly [unknown, unknown, string, ...infer Args] ? Args : never;
|
|
13
|
+
type CompatibleAssertionConstraints<Input, C extends readonly AssertionConstraint[]> = {
|
|
14
|
+
[K in keyof C]: AssertionConstraint<Input, ReturnType<C[K][0]>, ConstraintArgs<C[K]>, C[K][2]>;
|
|
15
|
+
};
|
|
16
|
+
export declare const assert: <T, const Name extends string, const Bail extends boolean, const Code extends string | undefined = undefined, const Args extends readonly unknown[] | undefined = undefined, const C extends readonly AssertionConstraint<T, any, any[], string>[] = []>(predicate: Predicate<T>, meta: AssertMeta & {
|
|
17
|
+
name: Name;
|
|
18
|
+
bail: Bail;
|
|
19
|
+
code?: Code;
|
|
20
|
+
args?: Args;
|
|
21
|
+
}, constraints?: C & CompatibleAssertionConstraints<T, C>) => Guard<T, C, ResolveAssertionCode<Name, Code>, ResolveAssertionArgs<Args>, Name>;
|
|
22
|
+
export declare const isRefinementAssertion: (constraint: Constraint) => constraint is Assertion;
|
|
23
|
+
export declare const runRefinementAssertion: (constraint: Assertion, value: unknown) => ReturnType<Assertion>;
|
|
24
|
+
export declare const checkRefinementAssertion: (constraint: Assertion, value: unknown) => boolean;
|
|
25
|
+
export declare const createRefinement: <const Name extends string, const Bail extends boolean, const Code extends string | undefined = undefined, const Args extends readonly unknown[] | undefined = undefined, const C extends readonly AssertionConstraint[] = []>(meta: AssertMeta & {
|
|
26
|
+
name: Name;
|
|
27
|
+
bail: Bail;
|
|
28
|
+
code?: Code;
|
|
29
|
+
args?: Args;
|
|
30
|
+
}, constraints?: C) => Refinement<ConstraintInput<C>, C, ResolveAssertionCode<Name, Code>, ResolveAssertionArgs<Args>, Name>;
|
|
31
|
+
export declare const refine: <const Name extends string, const Bail extends boolean, const Code extends string | undefined = undefined, const Args extends readonly unknown[] | undefined = undefined, const C extends readonly AssertionConstraint[] = []>(meta: AssertMeta & {
|
|
32
|
+
name: Name;
|
|
33
|
+
bail: Bail;
|
|
34
|
+
code?: Code;
|
|
35
|
+
args?: Args;
|
|
36
|
+
}, constraints?: C & CompatibleAssertionConstraints<ConstraintInput<C>, C>) => Refinement<ConstraintInput<C>, C, ResolveAssertionCode<Name, Code>, ResolveAssertionArgs<Args>, Name>;
|
|
37
|
+
export {};
|
package/dist/assert.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Assertion, AssertionConstraint, Predicate } from '
|
|
1
|
+
import { Assertion, Constraint, AssertionConstraint, Guard, Predicate, Refinement } from './types/index.js';
|
|
2
2
|
type AssertMeta = {
|
|
3
3
|
name: string;
|
|
4
4
|
bail: boolean;
|
|
@@ -7,10 +7,31 @@ type AssertMeta = {
|
|
|
7
7
|
};
|
|
8
8
|
type ResolveAssertionCode<Name extends string, Code extends string | undefined> = Code extends string ? Code : Name;
|
|
9
9
|
type ResolveAssertionArgs<Args extends readonly unknown[] | undefined> = Args extends readonly unknown[] ? Args : [];
|
|
10
|
-
|
|
10
|
+
type ConstraintInputFunction<C extends AssertionConstraint> = C extends unknown ? (value: Parameters<C[0]>[0]) => void : never;
|
|
11
|
+
type ConstraintInput<C extends readonly AssertionConstraint[]> = C extends readonly [] ? unknown : ConstraintInputFunction<C[number]> extends (value: infer Input) => void ? Input : never;
|
|
12
|
+
type ConstraintArgs<C extends AssertionConstraint> = C extends readonly [unknown, unknown, string, ...infer Args] ? Args : never;
|
|
13
|
+
type CompatibleAssertionConstraints<Input, C extends readonly AssertionConstraint[]> = {
|
|
14
|
+
[K in keyof C]: AssertionConstraint<Input, ReturnType<C[K][0]>, ConstraintArgs<C[K]>, C[K][2]>;
|
|
15
|
+
};
|
|
16
|
+
export declare const assert: <T, const Name extends string, const Bail extends boolean, const Code extends string | undefined = undefined, const Args extends readonly unknown[] | undefined = undefined, const C extends readonly AssertionConstraint<T, any, any[], string>[] = []>(predicate: Predicate<T>, meta: AssertMeta & {
|
|
17
|
+
name: Name;
|
|
18
|
+
bail: Bail;
|
|
19
|
+
code?: Code;
|
|
20
|
+
args?: Args;
|
|
21
|
+
}, constraints?: C & CompatibleAssertionConstraints<T, C>) => Guard<T, C, ResolveAssertionCode<Name, Code>, ResolveAssertionArgs<Args>, Name>;
|
|
22
|
+
export declare const isRefinementAssertion: (constraint: Constraint) => constraint is Assertion;
|
|
23
|
+
export declare const runRefinementAssertion: (constraint: Assertion, value: unknown) => ReturnType<Assertion>;
|
|
24
|
+
export declare const checkRefinementAssertion: (constraint: Assertion, value: unknown) => boolean;
|
|
25
|
+
export declare const createRefinement: <const Name extends string, const Bail extends boolean, const Code extends string | undefined = undefined, const Args extends readonly unknown[] | undefined = undefined, const C extends readonly AssertionConstraint[] = []>(meta: AssertMeta & {
|
|
26
|
+
name: Name;
|
|
27
|
+
bail: Bail;
|
|
28
|
+
code?: Code;
|
|
29
|
+
args?: Args;
|
|
30
|
+
}, constraints?: C) => Refinement<ConstraintInput<C>, C, ResolveAssertionCode<Name, Code>, ResolveAssertionArgs<Args>, Name>;
|
|
31
|
+
export declare const refine: <const Name extends string, const Bail extends boolean, const Code extends string | undefined = undefined, const Args extends readonly unknown[] | undefined = undefined, const C extends readonly AssertionConstraint[] = []>(meta: AssertMeta & {
|
|
11
32
|
name: Name;
|
|
12
33
|
bail: Bail;
|
|
13
34
|
code?: Code;
|
|
14
35
|
args?: Args;
|
|
15
|
-
}, constraints?: C) =>
|
|
36
|
+
}, constraints?: C & CompatibleAssertionConstraints<ConstraintInput<C>, C>) => Refinement<ConstraintInput<C>, C, ResolveAssertionCode<Name, Code>, ResolveAssertionArgs<Args>, Name>;
|
|
16
37
|
export {};
|
package/dist/assert.mjs
CHANGED
|
@@ -1,66 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const assertionCode = meta.code ?? meta.name;
|
|
4
|
-
const assertionArgs = meta.args ?? [];
|
|
5
|
-
const violationSubject = {
|
|
6
|
-
kind: "assertion",
|
|
7
|
-
name: meta.name,
|
|
8
|
-
code: assertionCode,
|
|
9
|
-
args: assertionArgs
|
|
10
|
-
};
|
|
11
|
-
const assertion = ((value) => {
|
|
12
|
-
if (!predicate(value)) {
|
|
13
|
-
return {
|
|
14
|
-
value,
|
|
15
|
-
violates: violationSubject
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
for (const [extract, check, code, ...args] of constraints) {
|
|
19
|
-
if (!check(extract(value), ...args)) {
|
|
20
|
-
const constraintSubject = {
|
|
21
|
-
kind: "assertion",
|
|
22
|
-
name: meta.name,
|
|
23
|
-
code,
|
|
24
|
-
args
|
|
25
|
-
};
|
|
26
|
-
return {
|
|
27
|
-
value,
|
|
28
|
-
violates: constraintSubject
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperties(assertion, {
|
|
35
|
-
name: {
|
|
36
|
-
configurable: true,
|
|
37
|
-
value: meta.name
|
|
38
|
-
},
|
|
39
|
-
bail: {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
value: meta.bail
|
|
42
|
-
},
|
|
43
|
-
constraints: {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
value: constraints
|
|
46
|
-
},
|
|
47
|
-
check: {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
value: (value) => predicate(value) && (!constraints.length || constraints.every(([extract, check, , ...args]) => check(extract(value), ...args)))
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return attachConstraintDescriptor(assertion, () => ({
|
|
53
|
-
kind: "assertion",
|
|
54
|
-
name: meta.name,
|
|
55
|
-
bail: meta.bail,
|
|
56
|
-
code: assertionCode,
|
|
57
|
-
args: assertionArgs,
|
|
58
|
-
constraints: constraints.map(([, , code, ...args]) => ({
|
|
59
|
-
code,
|
|
60
|
-
args
|
|
61
|
-
}))
|
|
62
|
-
}));
|
|
63
|
-
};
|
|
64
|
-
export {
|
|
65
|
-
assert
|
|
66
|
-
};
|
|
1
|
+
import { a as refine, i as isRefinementAssertion, n as checkRefinementAssertion, o as runRefinementAssertion, r as createRefinement, t as assert } from "./assert-CzMg5aO7.mjs";
|
|
2
|
+
export { assert, checkRefinementAssertion, createRefinement, isRefinementAssertion, refine, runRefinementAssertion };
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { r as createRefinement, t as assert } from "./assert-CzMg5aO7.mjs";
|
|
2
|
+
import { isArray, isBigInt as isBigInt$1, isBlob as isBlob$1, isBoolean as isBoolean$1, isDate as isDate$1, isEmail as isEmail$1, isError as isError$1, isFile as isFile$1, isFiniteNumber as isFiniteNumber$1, isFunction as isFunction$1, isInteger as isInteger$1, isMap as isMap$1, isNaN as isNaN$1, isNull as isNull$1, isNumber as isNumber$1, isPromiseLike as isPromiseLike$1, isRegExp as isRegExp$1, isSafeInteger as isSafeInteger$1, isSet as isSet$1, isString as isString$1, isSymbol as isSymbol$1, isValidDate as isValidDate$1 } from "./predicates.mjs";
|
|
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__ */ assert(isBoolean$1, {
|
|
111
|
+
name: "isBoolean",
|
|
112
|
+
bail: true,
|
|
113
|
+
code: "type.boolean"
|
|
114
|
+
});
|
|
115
|
+
var isBigInt = /* @__PURE__ */ assert(isBigInt$1, {
|
|
116
|
+
name: "isBigInt",
|
|
117
|
+
bail: true,
|
|
118
|
+
code: "type.bigint"
|
|
119
|
+
});
|
|
120
|
+
var isBlob = /* @__PURE__ */ assert(isBlob$1, {
|
|
121
|
+
name: "isBlob",
|
|
122
|
+
bail: true,
|
|
123
|
+
code: "type.blob"
|
|
124
|
+
});
|
|
125
|
+
var isDate = /* @__PURE__ */ assert(isDate$1, {
|
|
126
|
+
name: "isDate",
|
|
127
|
+
bail: true,
|
|
128
|
+
code: "type.date"
|
|
129
|
+
});
|
|
130
|
+
var isDefined = /* @__PURE__ */ assert((value) => value !== void 0, {
|
|
131
|
+
name: "isDefined",
|
|
132
|
+
bail: true,
|
|
133
|
+
code: "value.defined"
|
|
134
|
+
});
|
|
135
|
+
var isEmail = /* @__PURE__ */ assert(isEmail$1, {
|
|
136
|
+
name: "isEmail",
|
|
137
|
+
bail: true,
|
|
138
|
+
code: "string.email"
|
|
139
|
+
});
|
|
140
|
+
var isError = /* @__PURE__ */ assert(isError$1, {
|
|
141
|
+
name: "isError",
|
|
142
|
+
bail: true,
|
|
143
|
+
code: "type.error"
|
|
144
|
+
});
|
|
145
|
+
var isFiniteNumber = /* @__PURE__ */ assert(isFiniteNumber$1, {
|
|
146
|
+
name: "isFiniteNumber",
|
|
147
|
+
bail: true,
|
|
148
|
+
code: "number.finite"
|
|
149
|
+
});
|
|
150
|
+
var isFile = /* @__PURE__ */ assert(isFile$1, {
|
|
151
|
+
name: "isFile",
|
|
152
|
+
bail: true,
|
|
153
|
+
code: "type.file"
|
|
154
|
+
});
|
|
155
|
+
var isFunction = /* @__PURE__ */ assert(isFunction$1, {
|
|
156
|
+
name: "isFunction",
|
|
157
|
+
bail: true,
|
|
158
|
+
code: "type.function"
|
|
159
|
+
});
|
|
160
|
+
var isInteger = /* @__PURE__ */ assert(isInteger$1, {
|
|
161
|
+
name: "isInteger",
|
|
162
|
+
bail: true,
|
|
163
|
+
code: "number.integer"
|
|
164
|
+
});
|
|
165
|
+
var isMap = /* @__PURE__ */ assert(isMap$1, {
|
|
166
|
+
name: "isMap",
|
|
167
|
+
bail: true,
|
|
168
|
+
code: "type.map"
|
|
169
|
+
});
|
|
170
|
+
var isNaN = /* @__PURE__ */ assert(isNaN$1, {
|
|
171
|
+
name: "isNaN",
|
|
172
|
+
bail: true,
|
|
173
|
+
code: "number.nan"
|
|
174
|
+
});
|
|
175
|
+
var isNull = /* @__PURE__ */ assert(isNull$1, {
|
|
176
|
+
name: "isNull",
|
|
177
|
+
bail: true,
|
|
178
|
+
code: "type.null"
|
|
179
|
+
});
|
|
180
|
+
var isNumber = /* @__PURE__ */ assert(isNumber$1, {
|
|
181
|
+
name: "isNumber",
|
|
182
|
+
bail: true,
|
|
183
|
+
code: "type.number"
|
|
184
|
+
});
|
|
185
|
+
var isPromiseLike = /* @__PURE__ */ assert(isPromiseLike$1, {
|
|
186
|
+
name: "isPromiseLike",
|
|
187
|
+
bail: true,
|
|
188
|
+
code: "type.promise-like"
|
|
189
|
+
});
|
|
190
|
+
var isRegExp = /* @__PURE__ */ assert(isRegExp$1, {
|
|
191
|
+
name: "isRegExp",
|
|
192
|
+
bail: true,
|
|
193
|
+
code: "type.regexp"
|
|
194
|
+
});
|
|
195
|
+
var isSafeInteger = /* @__PURE__ */ assert(isSafeInteger$1, {
|
|
196
|
+
name: "isSafeInteger",
|
|
197
|
+
bail: true,
|
|
198
|
+
code: "number.safe-integer"
|
|
199
|
+
});
|
|
200
|
+
var isSet = /* @__PURE__ */ assert(isSet$1, {
|
|
201
|
+
name: "isSet",
|
|
202
|
+
bail: true,
|
|
203
|
+
code: "type.set"
|
|
204
|
+
});
|
|
205
|
+
var isString = /* @__PURE__ */ assert(isString$1, {
|
|
206
|
+
name: "isString",
|
|
207
|
+
bail: true,
|
|
208
|
+
code: "type.string"
|
|
209
|
+
});
|
|
210
|
+
var isSymbol = /* @__PURE__ */ assert(isSymbol$1, {
|
|
211
|
+
name: "isSymbol",
|
|
212
|
+
bail: true,
|
|
213
|
+
code: "type.symbol"
|
|
214
|
+
});
|
|
215
|
+
var isValidDate = /* @__PURE__ */ assert(isValidDate$1, {
|
|
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__ */ 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__ */ createRefinement({
|
|
233
|
+
name: "hasSize",
|
|
234
|
+
bail,
|
|
235
|
+
code: "size.unsupported-type"
|
|
236
|
+
}, constraints);
|
|
237
|
+
};
|
|
238
|
+
var hasPattern = (pattern, { bail = false } = {}) => /* @__PURE__ */ 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__ */ 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__ */ 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__ */ createRefinement({
|
|
272
|
+
name: "hasValue",
|
|
273
|
+
bail,
|
|
274
|
+
code: "number.unsupported-type"
|
|
275
|
+
}, constraints);
|
|
276
|
+
};
|
|
277
|
+
var multipleOf = (step, { bail = false } = {}) => /* @__PURE__ */ 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 = isArray(values) ? values : Object.values(values);
|
|
289
|
+
return /* @__PURE__ */ 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
|
+
export { startsWith as A, isSafeInteger as C, isValidDate as D, isSymbol as E, multipleOf as O, isRegExp as S, isString as T, isMap as _, hasValue as a, isNumber as b, isBoolean as c, isEmail as d, isError as f, isInteger as g, isFunction as h, hasSize as i, oneOf as k, isDate as l, isFiniteNumber as m, hasLength as n, isBigInt as o, isFile as p, hasPattern as r, isBlob as s, endsWith as t, isDefined as u, isNaN as v, isSet as w, isPromiseLike as x, isNull as y };
|