@ray-js/robot-data-stream 0.0.14 → 0.0.15-beta.1
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/lib/mqtt/createCommonOptions.d.ts +4 -2
- package/lib/mqtt/createCommonOptions.js +10 -5
- package/lib/mqtt/hooks/useStructuredMessage.d.ts +14 -0
- package/lib/mqtt/hooks/useStructuredMessage.js +131 -0
- package/lib/mqtt/mqttProvider.d.ts +19 -1
- package/lib/mqtt/mqttProvider.js +69 -8
- package/lib/mqtt/promise.d.ts +57 -4
- package/lib/mqtt/promise.js +115 -36
- package/lib/mqtt/type/fun.d.ts +49 -0
- package/lib/mqtt/type/fun.js +145 -0
- package/lib/mqtt/type/index.d.ts +0 -7
- package/lib/mqtt/type/index.js +0 -1
- package/lib/mqtt/type/protocols/base.d.ts +5 -0
- package/lib/mqtt/type/protocols/base.js +32 -0
- package/lib/mqtt/type/protocols/carpetCleanProtocol.d.ts +8 -0
- package/lib/mqtt/type/protocols/carpetCleanProtocol.js +16 -0
- package/lib/mqtt/type/protocols/carpetProtocol.d.ts +41 -0
- package/lib/mqtt/type/protocols/carpetProtocol.js +202 -0
- package/lib/mqtt/type/protocols/devInfoProtocol.d.ts +5 -0
- package/lib/mqtt/type/protocols/devInfoProtocol.js +12 -0
- package/lib/mqtt/type/protocols/deviceModelProtocol.d.ts +8 -0
- package/lib/mqtt/type/protocols/deviceModelProtocol.js +34 -0
- package/lib/mqtt/type/protocols/furnitureModelProtocol.d.ts +10 -0
- package/lib/mqtt/type/protocols/furnitureModelProtocol.js +35 -0
- package/lib/mqtt/type/protocols/historyMapProtocol.d.ts +17 -0
- package/lib/mqtt/type/protocols/historyMapProtocol.js +37 -0
- package/lib/mqtt/type/protocols/index.d.ts +20 -0
- package/lib/mqtt/type/protocols/index.js +20 -0
- package/lib/mqtt/type/protocols/partDivisionProtocol.d.ts +8 -0
- package/lib/mqtt/type/protocols/partDivisionProtocol.js +12 -0
- package/lib/mqtt/type/protocols/partMergeProtocol.d.ts +7 -0
- package/lib/mqtt/type/protocols/partMergeProtocol.js +12 -0
- package/lib/mqtt/type/protocols/passwordProtocol.d.ts +11 -0
- package/lib/mqtt/type/protocols/passwordProtocol.js +25 -0
- package/lib/mqtt/type/protocols/quietHoursProtocol.d.ts +8 -0
- package/lib/mqtt/type/protocols/quietHoursProtocol.js +35 -0
- package/lib/mqtt/type/protocols/resetMapProtocol.d.ts +4 -0
- package/lib/mqtt/type/protocols/resetMapProtocol.js +1 -0
- package/lib/mqtt/type/protocols/roomPropertyProtocol.d.ts +14 -0
- package/lib/mqtt/type/protocols/roomPropertyProtocol.js +113 -0
- package/lib/mqtt/type/protocols/scheduleProtocol.d.ts +18 -0
- package/lib/mqtt/type/protocols/scheduleProtocol.js +100 -0
- package/lib/mqtt/type/protocols/selectRoomCleanProtocol.d.ts +8 -0
- package/lib/mqtt/type/protocols/selectRoomCleanProtocol.js +40 -0
- package/lib/mqtt/type/protocols/spotCleanProtocol.d.ts +9 -0
- package/lib/mqtt/type/protocols/spotCleanProtocol.js +72 -0
- package/lib/mqtt/type/protocols/virtualAreaProtocol.d.ts +8 -0
- package/lib/mqtt/type/protocols/virtualAreaProtocol.js +36 -0
- package/lib/mqtt/type/protocols/virtualWallProtocol.d.ts +8 -0
- package/lib/mqtt/type/protocols/virtualWallProtocol.js +25 -0
- package/lib/mqtt/type/protocols/voiceProtocol.d.ts +8 -0
- package/lib/mqtt/type/protocols/voiceProtocol.js +23 -0
- package/lib/mqtt/type/protocols/wifiMapProtocol.d.ts +8 -0
- package/lib/mqtt/type/protocols/wifiMapProtocol.js +14 -0
- package/lib/mqtt/type/protocols/zoneCleanProtocol.d.ts +8 -0
- package/lib/mqtt/type/protocols/zoneCleanProtocol.js +49 -0
- package/lib/mqtt/useCarpet.d.ts +7 -67
- package/lib/mqtt/useCarpet.js +101 -181
- package/lib/mqtt/useCarpetClean.d.ts +2 -11
- package/lib/mqtt/useCarpetClean.js +24 -51
- package/lib/mqtt/useDevInfo.d.ts +8 -6
- package/lib/mqtt/useDevInfo.js +44 -36
- package/lib/mqtt/useDeviceModel.d.ts +6 -19
- package/lib/mqtt/useDeviceModel.js +29 -42
- package/lib/mqtt/useFurnitureModel.d.ts +6 -18
- package/lib/mqtt/useFurnitureModel.js +29 -43
- package/lib/mqtt/useHistoryMap.d.ts +2 -18
- package/lib/mqtt/useHistoryMap.js +102 -119
- package/lib/mqtt/usePartDivision.d.ts +2 -9
- package/lib/mqtt/usePartDivision.js +48 -57
- package/lib/mqtt/usePartMerge.d.ts +2 -8
- package/lib/mqtt/usePartMerge.js +34 -49
- package/lib/mqtt/usePassword.d.ts +6 -13
- package/lib/mqtt/usePassword.js +84 -74
- package/lib/mqtt/useQuiteHours.d.ts +4 -37
- package/lib/mqtt/useQuiteHours.js +66 -100
- package/lib/mqtt/useResetMap.d.ts +2 -8
- package/lib/mqtt/useResetMap.js +27 -34
- package/lib/mqtt/useRoomProperty.d.ts +8 -9
- package/lib/mqtt/useRoomProperty.js +67 -65
- package/lib/mqtt/useSchedule.d.ts +3 -23
- package/lib/mqtt/useSchedule.js +72 -101
- package/lib/mqtt/useSelectRoomClean.d.ts +3 -24
- package/lib/mqtt/useSelectRoomClean.js +107 -133
- package/lib/mqtt/useSpotClean.d.ts +5 -15
- package/lib/mqtt/useSpotClean.js +68 -121
- package/lib/mqtt/useVirtualArea.d.ts +6 -17
- package/lib/mqtt/useVirtualArea.js +109 -119
- package/lib/mqtt/useVirtualWall.d.ts +2 -18
- package/lib/mqtt/useVirtualWall.js +69 -90
- package/lib/mqtt/useVoice.d.ts +2 -16
- package/lib/mqtt/useVoice.js +48 -68
- package/lib/mqtt/useWifiMap.d.ts +6 -5
- package/lib/mqtt/useWifiMap.js +43 -42
- package/lib/mqtt/useZoneClean.d.ts +2 -21
- package/lib/mqtt/useZoneClean.js +125 -137
- package/lib/myLib/zod/mini/index.d.cts +1 -0
- package/lib/myLib/zod/mini/index.d.ts +1 -0
- package/lib/myLib/zod/mini/index.js +1 -0
- package/lib/myLib/zod/mini/package.json +6 -0
- package/lib/myLib/zod/src/mini/index.d.ts +1 -0
- package/lib/myLib/zod/src/mini/index.js +1 -0
- package/lib/myLib/zod/src/v4/core/api.d.ts +306 -0
- package/lib/myLib/zod/src/v4/core/api.js +1256 -0
- package/lib/myLib/zod/src/v4/core/checks.d.ts +278 -0
- package/lib/myLib/zod/src/v4/core/checks.js +816 -0
- package/lib/myLib/zod/src/v4/core/config.d.ts +9 -0
- package/lib/myLib/zod/src/v4/core/config.js +5 -0
- package/lib/myLib/zod/src/v4/core/core.d.ts +70 -0
- package/lib/myLib/zod/src/v4/core/core.js +95 -0
- package/lib/myLib/zod/src/v4/core/doc.d.ts +14 -0
- package/lib/myLib/zod/src/v4/core/doc.js +42 -0
- package/lib/myLib/zod/src/v4/core/errors.d.ts +220 -0
- package/lib/myLib/zod/src/v4/core/errors.js +232 -0
- package/lib/myLib/zod/src/v4/core/index.d.ts +15 -0
- package/lib/myLib/zod/src/v4/core/index.js +15 -0
- package/lib/myLib/zod/src/v4/core/json-schema-generator.d.ts +65 -0
- package/lib/myLib/zod/src/v4/core/json-schema-generator.js +120 -0
- package/lib/myLib/zod/src/v4/core/json-schema-processors.d.ts +49 -0
- package/lib/myLib/zod/src/v4/core/json-schema-processors.js +593 -0
- package/lib/myLib/zod/src/v4/core/json-schema.d.ts +88 -0
- package/lib/myLib/zod/src/v4/core/json-schema.js +1 -0
- package/lib/myLib/zod/src/v4/core/parse.d.ts +49 -0
- package/lib/myLib/zod/src/v4/core/parse.js +147 -0
- package/lib/myLib/zod/src/v4/core/regexes.d.ts +78 -0
- package/lib/myLib/zod/src/v4/core/regexes.js +146 -0
- package/lib/myLib/zod/src/v4/core/registries.d.ts +35 -0
- package/lib/myLib/zod/src/v4/core/registries.js +51 -0
- package/lib/myLib/zod/src/v4/core/schemas.d.ts +1136 -0
- package/lib/myLib/zod/src/v4/core/schemas.js +2745 -0
- package/lib/myLib/zod/src/v4/core/standard-schema.d.ts +126 -0
- package/lib/myLib/zod/src/v4/core/standard-schema.js +1 -0
- package/lib/myLib/zod/src/v4/core/to-json-schema.d.ts +114 -0
- package/lib/myLib/zod/src/v4/core/to-json-schema.js +488 -0
- package/lib/myLib/zod/src/v4/core/util.d.ts +199 -0
- package/lib/myLib/zod/src/v4/core/util.js +656 -0
- package/lib/myLib/zod/src/v4/core/versions.d.ts +5 -0
- package/lib/myLib/zod/src/v4/core/versions.js +5 -0
- package/lib/myLib/zod/src/v4/core/zsf.d.ts +91 -0
- package/lib/myLib/zod/src/v4/core/zsf.js +1 -0
- package/lib/myLib/zod/src/v4/mini/checks.d.ts +1 -0
- package/lib/myLib/zod/src/v4/mini/checks.js +1 -0
- package/lib/myLib/zod/src/v4/mini/coerce.d.ts +7 -0
- package/lib/myLib/zod/src/v4/mini/coerce.js +27 -0
- package/lib/myLib/zod/src/v4/mini/external.d.ts +11 -0
- package/lib/myLib/zod/src/v4/mini/external.js +16 -0
- package/lib/myLib/zod/src/v4/mini/index.d.ts +3 -0
- package/lib/myLib/zod/src/v4/mini/index.js +3 -0
- package/lib/myLib/zod/src/v4/mini/iso.d.ts +22 -0
- package/lib/myLib/zod/src/v4/mini/iso.js +46 -0
- package/lib/myLib/zod/src/v4/mini/parse.d.ts +1 -0
- package/lib/myLib/zod/src/v4/mini/parse.js +1 -0
- package/lib/myLib/zod/src/v4/mini/schemas.js +1244 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +2 -1
- package/package.json +5 -3
|
@@ -0,0 +1,816 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
// import { $ZodType } from "./schemas.js";
|
|
3
|
+
|
|
4
|
+
import * as core from "./core.js";
|
|
5
|
+
import * as regexes from "./regexes.js";
|
|
6
|
+
import * as util from "./util.js";
|
|
7
|
+
|
|
8
|
+
////////////////////////////// CHECKS ///////////////////////////////////////
|
|
9
|
+
|
|
10
|
+
export const $ZodCheck = /*@__PURE__*/core.$constructor("$ZodCheck", (inst, def) => {
|
|
11
|
+
inst._zod ??= {};
|
|
12
|
+
inst._zod.def = def;
|
|
13
|
+
inst._zod.onattach ??= [];
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
///////////////////////////////////////
|
|
17
|
+
///// $ZodCheckLessThan /////
|
|
18
|
+
///////////////////////////////////////
|
|
19
|
+
|
|
20
|
+
const numericOriginMap = {
|
|
21
|
+
number: "number",
|
|
22
|
+
bigint: "bigint",
|
|
23
|
+
object: "date"
|
|
24
|
+
};
|
|
25
|
+
export const $ZodCheckLessThan = /*@__PURE__*/core.$constructor("$ZodCheckLessThan", (inst, def) => {
|
|
26
|
+
$ZodCheck.init(inst, def);
|
|
27
|
+
const origin = numericOriginMap[typeof def.value];
|
|
28
|
+
inst._zod.onattach.push(inst => {
|
|
29
|
+
var _ref;
|
|
30
|
+
const bag = inst._zod.bag;
|
|
31
|
+
const curr = (_ref = def.inclusive ? bag.maximum : bag.exclusiveMaximum) !== null && _ref !== void 0 ? _ref : Number.POSITIVE_INFINITY;
|
|
32
|
+
if (def.value < curr) {
|
|
33
|
+
if (def.inclusive) bag.maximum = def.value;else bag.exclusiveMaximum = def.value;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
inst._zod.check = payload => {
|
|
37
|
+
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
payload.issues.push({
|
|
41
|
+
origin,
|
|
42
|
+
code: "too_big",
|
|
43
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
44
|
+
input: payload.value,
|
|
45
|
+
inclusive: def.inclusive,
|
|
46
|
+
inst,
|
|
47
|
+
continue: !def.abort
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/////////////////////////////////////
|
|
53
|
+
///// $ZodCheckGreaterThan /////
|
|
54
|
+
/////////////////////////////////////
|
|
55
|
+
|
|
56
|
+
export const $ZodCheckGreaterThan = /*@__PURE__*/core.$constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
57
|
+
$ZodCheck.init(inst, def);
|
|
58
|
+
const origin = numericOriginMap[typeof def.value];
|
|
59
|
+
inst._zod.onattach.push(inst => {
|
|
60
|
+
var _ref2;
|
|
61
|
+
const bag = inst._zod.bag;
|
|
62
|
+
const curr = (_ref2 = def.inclusive ? bag.minimum : bag.exclusiveMinimum) !== null && _ref2 !== void 0 ? _ref2 : Number.NEGATIVE_INFINITY;
|
|
63
|
+
if (def.value > curr) {
|
|
64
|
+
if (def.inclusive) bag.minimum = def.value;else bag.exclusiveMinimum = def.value;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
inst._zod.check = payload => {
|
|
68
|
+
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
payload.issues.push({
|
|
72
|
+
origin,
|
|
73
|
+
code: "too_small",
|
|
74
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
75
|
+
input: payload.value,
|
|
76
|
+
inclusive: def.inclusive,
|
|
77
|
+
inst,
|
|
78
|
+
continue: !def.abort
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/////////////////////////////////////
|
|
84
|
+
///// $ZodCheckMultipleOf /////
|
|
85
|
+
/////////////////////////////////////
|
|
86
|
+
// https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034
|
|
87
|
+
|
|
88
|
+
export const $ZodCheckMultipleOf = /*@__PURE__*/core.$constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
89
|
+
$ZodCheck.init(inst, def);
|
|
90
|
+
inst._zod.onattach.push(inst => {
|
|
91
|
+
inst._zod.bag.multipleOf ??= def.value;
|
|
92
|
+
});
|
|
93
|
+
inst._zod.check = payload => {
|
|
94
|
+
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
95
|
+
const isMultiple = typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : util.floatSafeRemainder(payload.value, def.value) === 0;
|
|
96
|
+
if (isMultiple) return;
|
|
97
|
+
payload.issues.push({
|
|
98
|
+
origin: typeof payload.value,
|
|
99
|
+
code: "not_multiple_of",
|
|
100
|
+
divisor: def.value,
|
|
101
|
+
input: payload.value,
|
|
102
|
+
inst,
|
|
103
|
+
continue: !def.abort
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
/////////////////////////////////////
|
|
109
|
+
///// $ZodCheckFinite /////
|
|
110
|
+
/////////////////////////////////////
|
|
111
|
+
// interface $ZodCheckFiniteDef extends $ZodCheckDef {
|
|
112
|
+
// check: "finite";
|
|
113
|
+
// }
|
|
114
|
+
|
|
115
|
+
// export interface $ZodCheckFinite extends $ZodCheckInternals<number> {
|
|
116
|
+
// _def: $ZodCheckFiniteDef;
|
|
117
|
+
// _issc:
|
|
118
|
+
// | errors.$ZodIssueTooBig<"number", number>
|
|
119
|
+
// | errors.$ZodIssueTooSmall<"number", number>;
|
|
120
|
+
// }
|
|
121
|
+
|
|
122
|
+
// export const $ZodCheckFinite: core.$constructor<$ZodCheckFinite> =
|
|
123
|
+
// core.$constructor("$ZodCheckFinite", (inst, def) => {
|
|
124
|
+
// $ZodCheck.init(inst, def);
|
|
125
|
+
|
|
126
|
+
// inst._zod.onattach = (inst) => {
|
|
127
|
+
// inst["_bag"].finite = true;
|
|
128
|
+
// };
|
|
129
|
+
|
|
130
|
+
// inst._zod.check = (payload) => {
|
|
131
|
+
// if (Number.isFinite(payload.value)) return;
|
|
132
|
+
// payload.issues.push({
|
|
133
|
+
// origin: "number",
|
|
134
|
+
// ...(payload.value === Number.POSITIVE_INFINITY
|
|
135
|
+
// ? {
|
|
136
|
+
// code: "too_big",
|
|
137
|
+
// maximum: Number.POSITIVE_INFINITY,
|
|
138
|
+
// }
|
|
139
|
+
// : {
|
|
140
|
+
// code: "too_small",
|
|
141
|
+
// minimum: Number.NEGATIVE_INFINITY,
|
|
142
|
+
// }),
|
|
143
|
+
// // code: payload.value === Number.POSITIVE_INFINITY ? "too_big" : "too_big",
|
|
144
|
+
// // maximum: Number.POSITIVE_INFINITY,
|
|
145
|
+
// inclusive: false,
|
|
146
|
+
// input: payload.value,
|
|
147
|
+
// inst,
|
|
148
|
+
// });
|
|
149
|
+
// };
|
|
150
|
+
// });
|
|
151
|
+
|
|
152
|
+
///////////////////////////////////////
|
|
153
|
+
///// $ZodCheckNumberFormat /////
|
|
154
|
+
///////////////////////////////////////
|
|
155
|
+
|
|
156
|
+
export const $ZodCheckNumberFormat = /*@__PURE__*/core.$constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
157
|
+
var _def$format;
|
|
158
|
+
$ZodCheck.init(inst, def); // no format checks
|
|
159
|
+
def.format = def.format || "float64";
|
|
160
|
+
const isInt = (_def$format = def.format) === null || _def$format === void 0 ? void 0 : _def$format.includes("int");
|
|
161
|
+
const origin = isInt ? "int" : "number";
|
|
162
|
+
const [minimum, maximum] = util.NUMBER_FORMAT_RANGES[def.format];
|
|
163
|
+
inst._zod.onattach.push(inst => {
|
|
164
|
+
const bag = inst._zod.bag;
|
|
165
|
+
bag.format = def.format;
|
|
166
|
+
bag.minimum = minimum;
|
|
167
|
+
bag.maximum = maximum;
|
|
168
|
+
if (isInt) bag.pattern = regexes.integer;
|
|
169
|
+
});
|
|
170
|
+
inst._zod.check = payload => {
|
|
171
|
+
const input = payload.value;
|
|
172
|
+
if (isInt) {
|
|
173
|
+
if (!Number.isInteger(input)) {
|
|
174
|
+
// invalid_format issue
|
|
175
|
+
// payload.issues.push({
|
|
176
|
+
// expected: def.format,
|
|
177
|
+
// format: def.format,
|
|
178
|
+
// code: "invalid_format",
|
|
179
|
+
// input,
|
|
180
|
+
// inst,
|
|
181
|
+
// });
|
|
182
|
+
// invalid_type issue
|
|
183
|
+
payload.issues.push({
|
|
184
|
+
expected: origin,
|
|
185
|
+
format: def.format,
|
|
186
|
+
code: "invalid_type",
|
|
187
|
+
continue: false,
|
|
188
|
+
input,
|
|
189
|
+
inst
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
|
|
193
|
+
// not_multiple_of issue
|
|
194
|
+
// payload.issues.push({
|
|
195
|
+
// code: "not_multiple_of",
|
|
196
|
+
// origin: "number",
|
|
197
|
+
// input,
|
|
198
|
+
// inst,
|
|
199
|
+
// divisor: 1,
|
|
200
|
+
// });
|
|
201
|
+
}
|
|
202
|
+
if (!Number.isSafeInteger(input)) {
|
|
203
|
+
if (input > 0) {
|
|
204
|
+
// too_big
|
|
205
|
+
payload.issues.push({
|
|
206
|
+
input,
|
|
207
|
+
code: "too_big",
|
|
208
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
209
|
+
note: "Integers must be within the safe integer range.",
|
|
210
|
+
inst,
|
|
211
|
+
origin,
|
|
212
|
+
inclusive: true,
|
|
213
|
+
continue: !def.abort
|
|
214
|
+
});
|
|
215
|
+
} else {
|
|
216
|
+
// too_small
|
|
217
|
+
payload.issues.push({
|
|
218
|
+
input,
|
|
219
|
+
code: "too_small",
|
|
220
|
+
minimum: Number.MIN_SAFE_INTEGER,
|
|
221
|
+
note: "Integers must be within the safe integer range.",
|
|
222
|
+
inst,
|
|
223
|
+
origin,
|
|
224
|
+
inclusive: true,
|
|
225
|
+
continue: !def.abort
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (input < minimum) {
|
|
232
|
+
payload.issues.push({
|
|
233
|
+
origin: "number",
|
|
234
|
+
input,
|
|
235
|
+
code: "too_small",
|
|
236
|
+
minimum,
|
|
237
|
+
inclusive: true,
|
|
238
|
+
inst,
|
|
239
|
+
continue: !def.abort
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
if (input > maximum) {
|
|
243
|
+
payload.issues.push({
|
|
244
|
+
origin: "number",
|
|
245
|
+
input,
|
|
246
|
+
code: "too_big",
|
|
247
|
+
maximum,
|
|
248
|
+
inclusive: true,
|
|
249
|
+
inst,
|
|
250
|
+
continue: !def.abort
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
/////////////////////////////////////
|
|
257
|
+
///// $ZodCheckBigIntFormat /////
|
|
258
|
+
/////////////////////////////////////
|
|
259
|
+
|
|
260
|
+
export const $ZodCheckBigIntFormat = /*@__PURE__*/core.$constructor("$ZodCheckBigIntFormat", (inst, def) => {
|
|
261
|
+
$ZodCheck.init(inst, def); // no format checks
|
|
262
|
+
|
|
263
|
+
const [minimum, maximum] = util.BIGINT_FORMAT_RANGES[def.format];
|
|
264
|
+
inst._zod.onattach.push(inst => {
|
|
265
|
+
const bag = inst._zod.bag;
|
|
266
|
+
bag.format = def.format;
|
|
267
|
+
bag.minimum = minimum;
|
|
268
|
+
bag.maximum = maximum;
|
|
269
|
+
});
|
|
270
|
+
inst._zod.check = payload => {
|
|
271
|
+
const input = payload.value;
|
|
272
|
+
if (input < minimum) {
|
|
273
|
+
payload.issues.push({
|
|
274
|
+
origin: "bigint",
|
|
275
|
+
input,
|
|
276
|
+
code: "too_small",
|
|
277
|
+
minimum: minimum,
|
|
278
|
+
inclusive: true,
|
|
279
|
+
inst,
|
|
280
|
+
continue: !def.abort
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
if (input > maximum) {
|
|
284
|
+
payload.issues.push({
|
|
285
|
+
origin: "bigint",
|
|
286
|
+
input,
|
|
287
|
+
code: "too_big",
|
|
288
|
+
maximum,
|
|
289
|
+
inclusive: true,
|
|
290
|
+
inst,
|
|
291
|
+
continue: !def.abort
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
//////////////////////////////////
|
|
298
|
+
///// $ZodCheckMaxSize /////
|
|
299
|
+
//////////////////////////////////
|
|
300
|
+
|
|
301
|
+
export const $ZodCheckMaxSize = /*@__PURE__*/core.$constructor("$ZodCheckMaxSize", (inst, def) => {
|
|
302
|
+
$ZodCheck.init(inst, def);
|
|
303
|
+
inst._zod.def.when ??= payload => {
|
|
304
|
+
const val = payload.value;
|
|
305
|
+
return !util.nullish(val) && val.size !== undefined;
|
|
306
|
+
};
|
|
307
|
+
inst._zod.onattach.push(inst => {
|
|
308
|
+
var _inst$_zod$bag$maximu;
|
|
309
|
+
const curr = (_inst$_zod$bag$maximu = inst._zod.bag.maximum) !== null && _inst$_zod$bag$maximu !== void 0 ? _inst$_zod$bag$maximu : Number.POSITIVE_INFINITY;
|
|
310
|
+
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
311
|
+
});
|
|
312
|
+
inst._zod.check = payload => {
|
|
313
|
+
const input = payload.value;
|
|
314
|
+
const size = input.size;
|
|
315
|
+
if (size <= def.maximum) return;
|
|
316
|
+
payload.issues.push({
|
|
317
|
+
origin: util.getSizableOrigin(input),
|
|
318
|
+
code: "too_big",
|
|
319
|
+
maximum: def.maximum,
|
|
320
|
+
inclusive: true,
|
|
321
|
+
input,
|
|
322
|
+
inst,
|
|
323
|
+
continue: !def.abort
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
//////////////////////////////////
|
|
329
|
+
///// $ZodCheckMinSize /////
|
|
330
|
+
//////////////////////////////////
|
|
331
|
+
|
|
332
|
+
export const $ZodCheckMinSize = /*@__PURE__*/core.$constructor("$ZodCheckMinSize", (inst, def) => {
|
|
333
|
+
$ZodCheck.init(inst, def);
|
|
334
|
+
inst._zod.def.when ??= payload => {
|
|
335
|
+
const val = payload.value;
|
|
336
|
+
return !util.nullish(val) && val.size !== undefined;
|
|
337
|
+
};
|
|
338
|
+
inst._zod.onattach.push(inst => {
|
|
339
|
+
var _inst$_zod$bag$minimu;
|
|
340
|
+
const curr = (_inst$_zod$bag$minimu = inst._zod.bag.minimum) !== null && _inst$_zod$bag$minimu !== void 0 ? _inst$_zod$bag$minimu : Number.NEGATIVE_INFINITY;
|
|
341
|
+
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
342
|
+
});
|
|
343
|
+
inst._zod.check = payload => {
|
|
344
|
+
const input = payload.value;
|
|
345
|
+
const size = input.size;
|
|
346
|
+
if (size >= def.minimum) return;
|
|
347
|
+
payload.issues.push({
|
|
348
|
+
origin: util.getSizableOrigin(input),
|
|
349
|
+
code: "too_small",
|
|
350
|
+
minimum: def.minimum,
|
|
351
|
+
inclusive: true,
|
|
352
|
+
input,
|
|
353
|
+
inst,
|
|
354
|
+
continue: !def.abort
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
/////////////////////////////////////
|
|
360
|
+
///// $ZodCheckSizeEquals /////
|
|
361
|
+
/////////////////////////////////////
|
|
362
|
+
|
|
363
|
+
export const $ZodCheckSizeEquals = /*@__PURE__*/core.$constructor("$ZodCheckSizeEquals", (inst, def) => {
|
|
364
|
+
$ZodCheck.init(inst, def);
|
|
365
|
+
inst._zod.def.when ??= payload => {
|
|
366
|
+
const val = payload.value;
|
|
367
|
+
return !util.nullish(val) && val.size !== undefined;
|
|
368
|
+
};
|
|
369
|
+
inst._zod.onattach.push(inst => {
|
|
370
|
+
const bag = inst._zod.bag;
|
|
371
|
+
bag.minimum = def.size;
|
|
372
|
+
bag.maximum = def.size;
|
|
373
|
+
bag.size = def.size;
|
|
374
|
+
});
|
|
375
|
+
inst._zod.check = payload => {
|
|
376
|
+
const input = payload.value;
|
|
377
|
+
const size = input.size;
|
|
378
|
+
if (size === def.size) return;
|
|
379
|
+
const tooBig = size > def.size;
|
|
380
|
+
payload.issues.push(_objectSpread(_objectSpread({
|
|
381
|
+
origin: util.getSizableOrigin(input)
|
|
382
|
+
}, tooBig ? {
|
|
383
|
+
code: "too_big",
|
|
384
|
+
maximum: def.size
|
|
385
|
+
} : {
|
|
386
|
+
code: "too_small",
|
|
387
|
+
minimum: def.size
|
|
388
|
+
}), {}, {
|
|
389
|
+
inclusive: true,
|
|
390
|
+
exact: true,
|
|
391
|
+
input: payload.value,
|
|
392
|
+
inst,
|
|
393
|
+
continue: !def.abort
|
|
394
|
+
}));
|
|
395
|
+
};
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
//////////////////////////////////
|
|
399
|
+
///// $ZodCheckMaxLength /////
|
|
400
|
+
//////////////////////////////////
|
|
401
|
+
|
|
402
|
+
export const $ZodCheckMaxLength = /*@__PURE__*/core.$constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
403
|
+
$ZodCheck.init(inst, def);
|
|
404
|
+
inst._zod.def.when ??= payload => {
|
|
405
|
+
const val = payload.value;
|
|
406
|
+
return !util.nullish(val) && val.length !== undefined;
|
|
407
|
+
};
|
|
408
|
+
inst._zod.onattach.push(inst => {
|
|
409
|
+
var _inst$_zod$bag$maximu2;
|
|
410
|
+
const curr = (_inst$_zod$bag$maximu2 = inst._zod.bag.maximum) !== null && _inst$_zod$bag$maximu2 !== void 0 ? _inst$_zod$bag$maximu2 : Number.POSITIVE_INFINITY;
|
|
411
|
+
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
412
|
+
});
|
|
413
|
+
inst._zod.check = payload => {
|
|
414
|
+
const input = payload.value;
|
|
415
|
+
const length = input.length;
|
|
416
|
+
if (length <= def.maximum) return;
|
|
417
|
+
const origin = util.getLengthableOrigin(input);
|
|
418
|
+
payload.issues.push({
|
|
419
|
+
origin,
|
|
420
|
+
code: "too_big",
|
|
421
|
+
maximum: def.maximum,
|
|
422
|
+
inclusive: true,
|
|
423
|
+
input,
|
|
424
|
+
inst,
|
|
425
|
+
continue: !def.abort
|
|
426
|
+
});
|
|
427
|
+
};
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
//////////////////////////////////
|
|
431
|
+
///// $ZodCheckMinLength /////
|
|
432
|
+
//////////////////////////////////
|
|
433
|
+
|
|
434
|
+
export const $ZodCheckMinLength = /*@__PURE__*/core.$constructor("$ZodCheckMinLength", (inst, def) => {
|
|
435
|
+
$ZodCheck.init(inst, def);
|
|
436
|
+
inst._zod.def.when ??= payload => {
|
|
437
|
+
const val = payload.value;
|
|
438
|
+
return !util.nullish(val) && val.length !== undefined;
|
|
439
|
+
};
|
|
440
|
+
inst._zod.onattach.push(inst => {
|
|
441
|
+
var _inst$_zod$bag$minimu2;
|
|
442
|
+
const curr = (_inst$_zod$bag$minimu2 = inst._zod.bag.minimum) !== null && _inst$_zod$bag$minimu2 !== void 0 ? _inst$_zod$bag$minimu2 : Number.NEGATIVE_INFINITY;
|
|
443
|
+
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
444
|
+
});
|
|
445
|
+
inst._zod.check = payload => {
|
|
446
|
+
const input = payload.value;
|
|
447
|
+
const length = input.length;
|
|
448
|
+
if (length >= def.minimum) return;
|
|
449
|
+
const origin = util.getLengthableOrigin(input);
|
|
450
|
+
payload.issues.push({
|
|
451
|
+
origin,
|
|
452
|
+
code: "too_small",
|
|
453
|
+
minimum: def.minimum,
|
|
454
|
+
inclusive: true,
|
|
455
|
+
input,
|
|
456
|
+
inst,
|
|
457
|
+
continue: !def.abort
|
|
458
|
+
});
|
|
459
|
+
};
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
/////////////////////////////////////
|
|
463
|
+
///// $ZodCheckLengthEquals /////
|
|
464
|
+
/////////////////////////////////////
|
|
465
|
+
|
|
466
|
+
export const $ZodCheckLengthEquals = /*@__PURE__*/core.$constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
467
|
+
$ZodCheck.init(inst, def);
|
|
468
|
+
inst._zod.def.when ??= payload => {
|
|
469
|
+
const val = payload.value;
|
|
470
|
+
return !util.nullish(val) && val.length !== undefined;
|
|
471
|
+
};
|
|
472
|
+
inst._zod.onattach.push(inst => {
|
|
473
|
+
const bag = inst._zod.bag;
|
|
474
|
+
bag.minimum = def.length;
|
|
475
|
+
bag.maximum = def.length;
|
|
476
|
+
bag.length = def.length;
|
|
477
|
+
});
|
|
478
|
+
inst._zod.check = payload => {
|
|
479
|
+
const input = payload.value;
|
|
480
|
+
const length = input.length;
|
|
481
|
+
if (length === def.length) return;
|
|
482
|
+
const origin = util.getLengthableOrigin(input);
|
|
483
|
+
const tooBig = length > def.length;
|
|
484
|
+
payload.issues.push(_objectSpread(_objectSpread({
|
|
485
|
+
origin
|
|
486
|
+
}, tooBig ? {
|
|
487
|
+
code: "too_big",
|
|
488
|
+
maximum: def.length
|
|
489
|
+
} : {
|
|
490
|
+
code: "too_small",
|
|
491
|
+
minimum: def.length
|
|
492
|
+
}), {}, {
|
|
493
|
+
inclusive: true,
|
|
494
|
+
exact: true,
|
|
495
|
+
input: payload.value,
|
|
496
|
+
inst,
|
|
497
|
+
continue: !def.abort
|
|
498
|
+
}));
|
|
499
|
+
};
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
/////////////////////////////////////////////
|
|
503
|
+
///// $ZodCheckStringFormatRegex /////
|
|
504
|
+
/////////////////////////////////////////////
|
|
505
|
+
|
|
506
|
+
export const $ZodCheckStringFormat = /*@__PURE__*/core.$constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
507
|
+
$ZodCheck.init(inst, def);
|
|
508
|
+
inst._zod.onattach.push(inst => {
|
|
509
|
+
const bag = inst._zod.bag;
|
|
510
|
+
bag.format = def.format;
|
|
511
|
+
if (def.pattern) {
|
|
512
|
+
bag.patterns ??= new Set();
|
|
513
|
+
bag.patterns.add(def.pattern);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
if (def.pattern) inst._zod.check ??= payload => {
|
|
517
|
+
def.pattern.lastIndex = 0;
|
|
518
|
+
if (def.pattern.test(payload.value)) return;
|
|
519
|
+
payload.issues.push(_objectSpread(_objectSpread({
|
|
520
|
+
origin: "string",
|
|
521
|
+
code: "invalid_format",
|
|
522
|
+
format: def.format,
|
|
523
|
+
input: payload.value
|
|
524
|
+
}, def.pattern ? {
|
|
525
|
+
pattern: def.pattern.toString()
|
|
526
|
+
} : {}), {}, {
|
|
527
|
+
inst,
|
|
528
|
+
continue: !def.abort
|
|
529
|
+
}));
|
|
530
|
+
};else inst._zod.check ??= () => {};
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
////////////////////////////////
|
|
534
|
+
///// $ZodCheckRegex /////
|
|
535
|
+
////////////////////////////////
|
|
536
|
+
|
|
537
|
+
export const $ZodCheckRegex = /*@__PURE__*/core.$constructor("$ZodCheckRegex", (inst, def) => {
|
|
538
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
539
|
+
inst._zod.check = payload => {
|
|
540
|
+
def.pattern.lastIndex = 0;
|
|
541
|
+
if (def.pattern.test(payload.value)) return;
|
|
542
|
+
payload.issues.push({
|
|
543
|
+
origin: "string",
|
|
544
|
+
code: "invalid_format",
|
|
545
|
+
format: "regex",
|
|
546
|
+
input: payload.value,
|
|
547
|
+
pattern: def.pattern.toString(),
|
|
548
|
+
inst,
|
|
549
|
+
continue: !def.abort
|
|
550
|
+
});
|
|
551
|
+
};
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
///////////////////////////////////
|
|
555
|
+
///// $ZodCheckJSONString /////
|
|
556
|
+
///////////////////////////////////
|
|
557
|
+
// interface $ZodCheckJSONStringDef extends $ZodCheckStringFormatDef<"json_string"> {
|
|
558
|
+
// // check: "string_format";
|
|
559
|
+
// // format: "json_string";
|
|
560
|
+
// // error?: errors.$ZodErrorMap<errors.$ZodIssueInvalidStringFormat> | undefined;
|
|
561
|
+
// }
|
|
562
|
+
|
|
563
|
+
// export interface $ZodCheckJSONString extends $ZodCheckStringFormat {
|
|
564
|
+
// _def: $ZodCheckJSONStringDef;
|
|
565
|
+
// }
|
|
566
|
+
|
|
567
|
+
// export const $ZodCheckJSONString: core.$constructor<$ZodCheckJSONString> = /*@__PURE__*/ core.$constructor(
|
|
568
|
+
// "$ZodCheckJSONString",
|
|
569
|
+
// (inst, def) => {
|
|
570
|
+
// $ZodCheck.init(inst, def);
|
|
571
|
+
|
|
572
|
+
// inst._zod.check = (payload) => {
|
|
573
|
+
// try {
|
|
574
|
+
// JSON.parse(payload.value);
|
|
575
|
+
// return;
|
|
576
|
+
// } catch (_) {
|
|
577
|
+
// payload.issues.push({
|
|
578
|
+
// origin: "string",
|
|
579
|
+
// code: "invalid_format",
|
|
580
|
+
// format: def.format,
|
|
581
|
+
// input: payload.value,
|
|
582
|
+
// inst,
|
|
583
|
+
// continue: !def.abort,
|
|
584
|
+
// });
|
|
585
|
+
// }
|
|
586
|
+
// };
|
|
587
|
+
// }
|
|
588
|
+
// );
|
|
589
|
+
|
|
590
|
+
//////////////////////////////////////
|
|
591
|
+
///// $ZodCheckLowerCase /////
|
|
592
|
+
//////////////////////////////////////
|
|
593
|
+
|
|
594
|
+
export const $ZodCheckLowerCase = /*@__PURE__*/core.$constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
595
|
+
def.pattern ??= regexes.lowercase;
|
|
596
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
//////////////////////////////////////
|
|
600
|
+
///// $ZodCheckUpperCase /////
|
|
601
|
+
//////////////////////////////////////
|
|
602
|
+
|
|
603
|
+
export const $ZodCheckUpperCase = /*@__PURE__*/core.$constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
604
|
+
def.pattern ??= regexes.uppercase;
|
|
605
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
///////////////////////////////////
|
|
609
|
+
///// $ZodCheckIncludes /////
|
|
610
|
+
///////////////////////////////////
|
|
611
|
+
|
|
612
|
+
export const $ZodCheckIncludes = /*@__PURE__*/core.$constructor("$ZodCheckIncludes", (inst, def) => {
|
|
613
|
+
$ZodCheck.init(inst, def);
|
|
614
|
+
const escapedRegex = util.escapeRegex(def.includes);
|
|
615
|
+
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
616
|
+
def.pattern = pattern;
|
|
617
|
+
inst._zod.onattach.push(inst => {
|
|
618
|
+
const bag = inst._zod.bag;
|
|
619
|
+
bag.patterns ??= new Set();
|
|
620
|
+
bag.patterns.add(pattern);
|
|
621
|
+
});
|
|
622
|
+
inst._zod.check = payload => {
|
|
623
|
+
if (payload.value.includes(def.includes, def.position)) return;
|
|
624
|
+
payload.issues.push({
|
|
625
|
+
origin: "string",
|
|
626
|
+
code: "invalid_format",
|
|
627
|
+
format: "includes",
|
|
628
|
+
includes: def.includes,
|
|
629
|
+
input: payload.value,
|
|
630
|
+
inst,
|
|
631
|
+
continue: !def.abort
|
|
632
|
+
});
|
|
633
|
+
};
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
/////////////////////////////////////
|
|
637
|
+
///// $ZodCheckStartsWith /////
|
|
638
|
+
/////////////////////////////////////
|
|
639
|
+
|
|
640
|
+
export const $ZodCheckStartsWith = /*@__PURE__*/core.$constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
641
|
+
$ZodCheck.init(inst, def);
|
|
642
|
+
const pattern = new RegExp(`^${util.escapeRegex(def.prefix)}.*`);
|
|
643
|
+
def.pattern ??= pattern;
|
|
644
|
+
inst._zod.onattach.push(inst => {
|
|
645
|
+
const bag = inst._zod.bag;
|
|
646
|
+
bag.patterns ??= new Set();
|
|
647
|
+
bag.patterns.add(pattern);
|
|
648
|
+
});
|
|
649
|
+
inst._zod.check = payload => {
|
|
650
|
+
if (payload.value.startsWith(def.prefix)) return;
|
|
651
|
+
payload.issues.push({
|
|
652
|
+
origin: "string",
|
|
653
|
+
code: "invalid_format",
|
|
654
|
+
format: "starts_with",
|
|
655
|
+
prefix: def.prefix,
|
|
656
|
+
input: payload.value,
|
|
657
|
+
inst,
|
|
658
|
+
continue: !def.abort
|
|
659
|
+
});
|
|
660
|
+
};
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
//////////////////////////////////
|
|
664
|
+
///// $ZodCheckEndsWith /////
|
|
665
|
+
//////////////////////////////////
|
|
666
|
+
|
|
667
|
+
export const $ZodCheckEndsWith = /*@__PURE__*/core.$constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
668
|
+
$ZodCheck.init(inst, def);
|
|
669
|
+
const pattern = new RegExp(`.*${util.escapeRegex(def.suffix)}$`);
|
|
670
|
+
def.pattern ??= pattern;
|
|
671
|
+
inst._zod.onattach.push(inst => {
|
|
672
|
+
const bag = inst._zod.bag;
|
|
673
|
+
bag.patterns ??= new Set();
|
|
674
|
+
bag.patterns.add(pattern);
|
|
675
|
+
});
|
|
676
|
+
inst._zod.check = payload => {
|
|
677
|
+
if (payload.value.endsWith(def.suffix)) return;
|
|
678
|
+
payload.issues.push({
|
|
679
|
+
origin: "string",
|
|
680
|
+
code: "invalid_format",
|
|
681
|
+
format: "ends_with",
|
|
682
|
+
suffix: def.suffix,
|
|
683
|
+
input: payload.value,
|
|
684
|
+
inst,
|
|
685
|
+
continue: !def.abort
|
|
686
|
+
});
|
|
687
|
+
};
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
///////////////////////////////////
|
|
691
|
+
///// $ZodCheckProperty /////
|
|
692
|
+
///////////////////////////////////
|
|
693
|
+
function handleCheckPropertyResult(result, payload, property) {
|
|
694
|
+
if (result.issues.length) {
|
|
695
|
+
payload.issues.push(...util.prefixIssues(property, result.issues));
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
export const $ZodCheckProperty = /*@__PURE__*/core.$constructor("$ZodCheckProperty", (inst, def) => {
|
|
699
|
+
$ZodCheck.init(inst, def);
|
|
700
|
+
inst._zod.check = payload => {
|
|
701
|
+
const result = def.schema._zod.run({
|
|
702
|
+
value: payload.value[def.property],
|
|
703
|
+
issues: []
|
|
704
|
+
}, {});
|
|
705
|
+
if (result instanceof Promise) {
|
|
706
|
+
return result.then(result => handleCheckPropertyResult(result, payload, def.property));
|
|
707
|
+
}
|
|
708
|
+
handleCheckPropertyResult(result, payload, def.property);
|
|
709
|
+
};
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
///////////////////////////////////
|
|
713
|
+
///// $ZodCheckMimeType /////
|
|
714
|
+
///////////////////////////////////
|
|
715
|
+
|
|
716
|
+
export const $ZodCheckMimeType = /*@__PURE__*/core.$constructor("$ZodCheckMimeType", (inst, def) => {
|
|
717
|
+
$ZodCheck.init(inst, def);
|
|
718
|
+
const mimeSet = new Set(def.mime);
|
|
719
|
+
inst._zod.onattach.push(inst => {
|
|
720
|
+
inst._zod.bag.mime = def.mime;
|
|
721
|
+
});
|
|
722
|
+
inst._zod.check = payload => {
|
|
723
|
+
if (mimeSet.has(payload.value.type)) return;
|
|
724
|
+
payload.issues.push({
|
|
725
|
+
code: "invalid_value",
|
|
726
|
+
values: def.mime,
|
|
727
|
+
input: payload.value.type,
|
|
728
|
+
inst,
|
|
729
|
+
continue: !def.abort
|
|
730
|
+
});
|
|
731
|
+
};
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
///////////////////////////////////
|
|
735
|
+
///// $ZodCheckFileName /////
|
|
736
|
+
///////////////////////////////////
|
|
737
|
+
// interface $ZodCheckFileNameDef extends $ZodCheckDef {
|
|
738
|
+
// check: "file_name";
|
|
739
|
+
// fileName: string;
|
|
740
|
+
// error?: errors.$ZodErrorMap<errors.$ZodIssueInvalidType> | undefined;
|
|
741
|
+
// }
|
|
742
|
+
// export interface $ZodCheckFileName<T extends File = File>
|
|
743
|
+
// extends $ZodCheckInternals<T> {
|
|
744
|
+
// _def: $ZodCheckFileNameDef;
|
|
745
|
+
// }
|
|
746
|
+
|
|
747
|
+
// export const $ZodCheckFileName: core.$constructor<$ZodCheckFileName> =
|
|
748
|
+
// core.$constructor("$ZodCheckFileName", (inst, def) => {
|
|
749
|
+
// $ZodCheck.init(inst, def);
|
|
750
|
+
|
|
751
|
+
// inst._zod.check = (payload) => {
|
|
752
|
+
// if (def.fileName === payload.value.name) return;
|
|
753
|
+
// payload.issues.push({
|
|
754
|
+
// origin: "file",
|
|
755
|
+
// code: "invalid_value",
|
|
756
|
+
// options: [def.fileName],
|
|
757
|
+
// input: payload.value,
|
|
758
|
+
// path: ["name"],
|
|
759
|
+
// inst,
|
|
760
|
+
// });
|
|
761
|
+
// };
|
|
762
|
+
// });
|
|
763
|
+
|
|
764
|
+
///////////////////////////////////
|
|
765
|
+
///// $ZodCheckOverwrite /////
|
|
766
|
+
///////////////////////////////////
|
|
767
|
+
|
|
768
|
+
export const $ZodCheckOverwrite = /*@__PURE__*/core.$constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
769
|
+
$ZodCheck.init(inst, def);
|
|
770
|
+
inst._zod.check = payload => {
|
|
771
|
+
payload.value = def.tx(payload.value);
|
|
772
|
+
};
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
// ///////////////////////////////
|
|
776
|
+
// ///// $ZodCheckTrim /////
|
|
777
|
+
// ///////////////////////////////
|
|
778
|
+
// export interface $ZodCheckTrimDef extends $ZodCheckDef {
|
|
779
|
+
// check: "trim";
|
|
780
|
+
// error?: errors.$ZodErrorMap<never> | undefined;
|
|
781
|
+
// }
|
|
782
|
+
// export interface $ZodCheckTrim extends $ZodCheckInternals<string> {
|
|
783
|
+
// _def: $ZodCheckTrimDef;
|
|
784
|
+
// }
|
|
785
|
+
|
|
786
|
+
// export const $ZodCheckTrim: core.$constructor<$ZodCheckTrim> =
|
|
787
|
+
// core.$constructor("$ZodCheckTrim", (inst, def) => {
|
|
788
|
+
// $ZodCheck.init(inst, def);
|
|
789
|
+
|
|
790
|
+
// inst._zod.check = (payload) => {
|
|
791
|
+
// payload.value = payload.value.trim();
|
|
792
|
+
// };
|
|
793
|
+
// });
|
|
794
|
+
|
|
795
|
+
// //////////////////////////////////////
|
|
796
|
+
// ///// $ZodCheckNormalize /////
|
|
797
|
+
// //////////////////////////////////////
|
|
798
|
+
// interface $ZodCheckNormalizeDef extends $ZodCheckDef {
|
|
799
|
+
// check: "normalize";
|
|
800
|
+
// error?: errors.$ZodErrorMap<never> | undefined;
|
|
801
|
+
// }
|
|
802
|
+
|
|
803
|
+
// export interface $ZodCheckNormalize extends $ZodCheckInternals<string> {
|
|
804
|
+
// _def: $ZodCheckNormalizeDef;
|
|
805
|
+
// }
|
|
806
|
+
|
|
807
|
+
// export const $ZodCheckNormalize: core.$constructor<$ZodCheckNormalize> =
|
|
808
|
+
// core.$constructor("$ZodCheckNormalize", (inst, def) => {
|
|
809
|
+
// $ZodCheck.init(inst, def);
|
|
810
|
+
|
|
811
|
+
// inst._zod.check = (payload) => {
|
|
812
|
+
// payload.value = payload.value.normalize();
|
|
813
|
+
// };
|
|
814
|
+
// });
|
|
815
|
+
|
|
816
|
+
// union of string format schema types
|