zod 4.5.3 → 4.6.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/compile.cjs +19 -0
- package/index.cjs +19 -0
- package/locales/index.cjs +19 -0
- package/mini/index.cjs +19 -0
- package/package.json +8 -7
- package/src/v3/helpers/errorUtil.ts +1 -1
- package/src/v4/classic/checks.ts +0 -1
- package/src/v4/classic/external.ts +2 -0
- package/src/v4/classic/from-json-schema.ts +248 -25
- package/src/v4/classic/schemas.ts +255 -164
- package/src/v4/classic/tests/assignability.test.ts +59 -9
- package/src/v4/classic/tests/bigint.test.ts +6 -0
- package/src/v4/classic/tests/continuability.test.ts +2 -2
- package/src/v4/classic/tests/cyclic-data.test.ts +316 -0
- package/src/v4/classic/tests/default.test.ts +46 -0
- package/src/v4/classic/tests/enum.test.ts +9 -0
- package/src/v4/classic/tests/error.test.ts +130 -1
- package/src/v4/classic/tests/firstparty.test.ts +4 -0
- package/src/v4/classic/tests/from-json-schema.test.ts +157 -0
- package/src/v4/classic/tests/iban.test.ts +81 -0
- package/src/v4/classic/tests/instance-footprint.test.ts +18 -2
- package/src/v4/classic/tests/instanceof.test.ts +27 -7
- package/src/v4/classic/tests/issue-schema.test.ts +88 -56
- package/src/v4/classic/tests/object.test.ts +56 -0
- package/src/v4/classic/tests/optin-ladder.test.ts +3 -2
- package/src/v4/classic/tests/properties.test.ts +225 -0
- package/src/v4/classic/tests/recursive-types.test.ts +1 -1
- package/src/v4/classic/tests/standard-schema.test.ts +19 -0
- package/src/v4/classic/tests/string.test.ts +25 -0
- package/src/v4/classic/tests/template-literal.test.ts +33 -1
- package/src/v4/classic/tests/to-json-schema.test.ts +147 -3
- package/src/v4/classic/tests/validate.test.ts +569 -0
- package/src/v4/core/api.ts +30 -6
- package/src/v4/core/checks.ts +1 -101
- package/src/v4/core/compile.ts +193 -81
- package/src/v4/core/doc.ts +6 -2
- package/src/v4/core/errors.ts +3 -6
- package/src/v4/core/json-schema-generator.ts +2 -2
- package/src/v4/core/json-schema-processors.ts +226 -68
- package/src/v4/core/memoizer.ts +162 -36
- package/src/v4/core/parse.ts +37 -16
- package/src/v4/core/regexes.ts +10 -4
- package/src/v4/core/schemas.ts +314 -83
- package/src/v4/core/tests/cached.test.ts +54 -0
- package/src/v4/core/tests/compile-generative.test.ts +445 -0
- package/src/v4/core/tests/compile.test.ts +222 -2
- package/src/v4/core/tests/email-regex.test.ts +140 -0
- package/src/v4/core/tests/polyfill-collision.test.ts +46 -0
- package/src/v4/core/to-json-schema.ts +10 -8
- package/src/v4/core/util.ts +222 -147
- package/src/v4/core/versions.ts +2 -2
- package/src/v4/core/visit.ts +11 -0
- package/src/v4/locales/ar.ts +1 -0
- package/src/v4/locales/az.ts +1 -0
- package/src/v4/locales/be.ts +1 -0
- package/src/v4/locales/bg.ts +1 -0
- package/src/v4/locales/bn.ts +1 -0
- package/src/v4/locales/ca.ts +1 -0
- package/src/v4/locales/ckb.ts +1 -0
- package/src/v4/locales/cs.ts +1 -0
- package/src/v4/locales/da.ts +1 -0
- package/src/v4/locales/de.ts +1 -0
- package/src/v4/locales/el.ts +1 -0
- package/src/v4/locales/en.ts +1 -0
- package/src/v4/locales/eo.ts +1 -0
- package/src/v4/locales/es.ts +1 -0
- package/src/v4/locales/fa.ts +1 -0
- package/src/v4/locales/fi.ts +1 -0
- package/src/v4/locales/fr-CA.ts +1 -0
- package/src/v4/locales/fr.ts +1 -0
- package/src/v4/locales/gu.ts +1 -0
- package/src/v4/locales/he.ts +1 -0
- package/src/v4/locales/hi.ts +1 -0
- package/src/v4/locales/hr.ts +1 -0
- package/src/v4/locales/hu.ts +1 -0
- package/src/v4/locales/hy.ts +1 -0
- package/src/v4/locales/id.ts +1 -0
- package/src/v4/locales/is.ts +1 -0
- package/src/v4/locales/it.ts +1 -0
- package/src/v4/locales/ja.ts +1 -0
- package/src/v4/locales/ka.ts +1 -0
- package/src/v4/locales/km.ts +1 -0
- package/src/v4/locales/kn.ts +1 -0
- package/src/v4/locales/ko.ts +1 -0
- package/src/v4/locales/lt.ts +1 -0
- package/src/v4/locales/mk.ts +1 -0
- package/src/v4/locales/ms.ts +1 -0
- package/src/v4/locales/ne.ts +1 -0
- package/src/v4/locales/nl.ts +1 -0
- package/src/v4/locales/nn.ts +1 -0
- package/src/v4/locales/no.ts +1 -0
- package/src/v4/locales/ota.ts +1 -0
- package/src/v4/locales/pl.ts +1 -0
- package/src/v4/locales/ps.ts +1 -0
- package/src/v4/locales/pt-BR.ts +1 -0
- package/src/v4/locales/pt.ts +1 -0
- package/src/v4/locales/ro.ts +1 -0
- package/src/v4/locales/ru.ts +1 -0
- package/src/v4/locales/sk.ts +1 -0
- package/src/v4/locales/sl.ts +1 -0
- package/src/v4/locales/sv.ts +1 -0
- package/src/v4/locales/ta.ts +1 -0
- package/src/v4/locales/th.ts +1 -0
- package/src/v4/locales/tk.ts +1 -0
- package/src/v4/locales/tr.ts +1 -0
- package/src/v4/locales/uk.ts +1 -0
- package/src/v4/locales/ur.ts +1 -0
- package/src/v4/locales/uz.ts +1 -0
- package/src/v4/locales/vi.ts +1 -0
- package/src/v4/locales/yo.ts +1 -0
- package/src/v4/locales/zh-CN.ts +1 -0
- package/src/v4/locales/zh-TW.ts +1 -0
- package/src/v4/mini/checks.ts +0 -1
- package/src/v4/mini/external.ts +2 -0
- package/src/v4/mini/schemas.ts +38 -2
- package/src/v4/mini/tests/checks.test.ts +1 -1
- package/src/v4/mini/tests/computed.test.ts +11 -17
- package/src/v4/mini/tests/index.test.ts +8 -0
- package/src/v4/mini/tests/string.test.ts +16 -0
- package/v3/ZodError.cjs +19 -0
- package/v3/errors.cjs +19 -0
- package/v3/external.cjs +19 -0
- package/v3/helpers/enumUtil.cjs +19 -0
- package/v3/helpers/errorUtil.cjs +20 -1
- package/v3/helpers/errorUtil.js +1 -1
- package/v3/helpers/parseUtil.cjs +19 -0
- package/v3/helpers/partialUtil.cjs +19 -0
- package/v3/helpers/typeAliases.cjs +19 -0
- package/v3/helpers/util.cjs +19 -0
- package/v3/index.cjs +19 -0
- package/v3/standard-schema.cjs +19 -0
- package/v3/types.cjs +19 -0
- package/v4/classic/checks.cjs +20 -2
- package/v4/classic/checks.d.cts +1 -1
- package/v4/classic/checks.d.ts +1 -1
- package/v4/classic/checks.js +1 -1
- package/v4/classic/coerce.cjs +19 -0
- package/v4/classic/compat.cjs +19 -0
- package/v4/classic/deep-partial.cjs +19 -0
- package/v4/classic/errors.cjs +19 -0
- package/v4/classic/external.cjs +22 -1
- package/v4/classic/external.d.cts +1 -1
- package/v4/classic/external.d.ts +1 -1
- package/v4/classic/external.js +1 -1
- package/v4/classic/from-json-schema.cjs +264 -24
- package/v4/classic/from-json-schema.js +245 -24
- package/v4/classic/in-out.cjs +19 -0
- package/v4/classic/index.cjs +19 -0
- package/v4/classic/iso.cjs +19 -0
- package/v4/classic/parse.cjs +19 -0
- package/v4/classic/schemas.cjs +100 -31
- package/v4/classic/schemas.d.cts +17 -1
- package/v4/classic/schemas.d.ts +17 -1
- package/v4/classic/schemas.js +77 -29
- package/v4/core/api.cjs +37 -2
- package/v4/core/api.d.cts +6 -4
- package/v4/core/api.d.ts +6 -4
- package/v4/core/api.js +17 -2
- package/v4/core/checks.cjs +19 -96
- package/v4/core/checks.d.cts +1 -1
- package/v4/core/checks.d.ts +1 -1
- package/v4/core/checks.js +0 -96
- package/v4/core/compile.cjs +164 -65
- package/v4/core/compile.d.cts +18 -4
- package/v4/core/compile.d.ts +18 -4
- package/v4/core/compile.js +145 -66
- package/v4/core/core.cjs +19 -0
- package/v4/core/doc.cjs +26 -2
- package/v4/core/doc.js +7 -2
- package/v4/core/errors.cjs +21 -5
- package/v4/core/errors.js +2 -5
- package/v4/core/index.cjs +19 -0
- package/v4/core/json-schema-generator.cjs +20 -1
- package/v4/core/json-schema-generator.js +2 -2
- package/v4/core/json-schema-processors.cjs +215 -63
- package/v4/core/json-schema-processors.d.cts +17 -0
- package/v4/core/json-schema-processors.d.ts +17 -0
- package/v4/core/json-schema-processors.js +195 -64
- package/v4/core/json-schema.cjs +19 -0
- package/v4/core/memoizer.cjs +204 -36
- package/v4/core/memoizer.js +162 -36
- package/v4/core/parse.cjs +56 -16
- package/v4/core/parse.js +37 -16
- package/v4/core/regexes.cjs +29 -6
- package/v4/core/regexes.d.cts +2 -0
- package/v4/core/regexes.d.ts +2 -0
- package/v4/core/regexes.js +8 -4
- package/v4/core/registries.cjs +19 -0
- package/v4/core/schemas.cjs +285 -66
- package/v4/core/schemas.d.cts +34 -3
- package/v4/core/schemas.d.ts +34 -3
- package/v4/core/schemas.js +264 -65
- package/v4/core/standard-schema.cjs +19 -0
- package/v4/core/to-json-schema.cjs +29 -7
- package/v4/core/to-json-schema.d.cts +7 -3
- package/v4/core/to-json-schema.d.ts +7 -3
- package/v4/core/to-json-schema.js +8 -7
- package/v4/core/util.cjs +181 -143
- package/v4/core/util.d.cts +25 -4
- package/v4/core/util.d.ts +25 -4
- package/v4/core/util.js +160 -143
- package/v4/core/versions.cjs +21 -2
- package/v4/core/versions.d.cts +1 -1
- package/v4/core/versions.d.ts +1 -1
- package/v4/core/versions.js +2 -2
- package/v4/core/visit.cjs +31 -0
- package/v4/core/visit.js +12 -0
- package/v4/index.cjs +19 -0
- package/v4/locales/ar.cjs +1 -0
- package/v4/locales/ar.js +1 -0
- package/v4/locales/az.cjs +1 -0
- package/v4/locales/az.js +1 -0
- package/v4/locales/be.cjs +1 -0
- package/v4/locales/be.js +1 -0
- package/v4/locales/bg.cjs +1 -0
- package/v4/locales/bg.js +1 -0
- package/v4/locales/bn.cjs +1 -0
- package/v4/locales/bn.js +1 -0
- package/v4/locales/ca.cjs +1 -0
- package/v4/locales/ca.js +1 -0
- package/v4/locales/ckb.cjs +1 -0
- package/v4/locales/ckb.js +1 -0
- package/v4/locales/cs.cjs +1 -0
- package/v4/locales/cs.js +1 -0
- package/v4/locales/da.cjs +1 -0
- package/v4/locales/da.js +1 -0
- package/v4/locales/de.cjs +1 -0
- package/v4/locales/de.js +1 -0
- package/v4/locales/el.cjs +1 -0
- package/v4/locales/el.js +1 -0
- package/v4/locales/en.cjs +1 -0
- package/v4/locales/en.js +1 -0
- package/v4/locales/eo.cjs +1 -0
- package/v4/locales/eo.js +1 -0
- package/v4/locales/es.cjs +1 -0
- package/v4/locales/es.js +1 -0
- package/v4/locales/fa.cjs +1 -0
- package/v4/locales/fa.js +1 -0
- package/v4/locales/fi.cjs +1 -0
- package/v4/locales/fi.js +1 -0
- package/v4/locales/fr-CA.cjs +1 -0
- package/v4/locales/fr-CA.js +1 -0
- package/v4/locales/fr.cjs +1 -0
- package/v4/locales/fr.js +1 -0
- package/v4/locales/gu.cjs +1 -0
- package/v4/locales/gu.js +1 -0
- package/v4/locales/he.cjs +1 -0
- package/v4/locales/he.js +1 -0
- package/v4/locales/hi.cjs +1 -0
- package/v4/locales/hi.js +1 -0
- package/v4/locales/hr.cjs +1 -0
- package/v4/locales/hr.js +1 -0
- package/v4/locales/hu.cjs +1 -0
- package/v4/locales/hu.js +1 -0
- package/v4/locales/hy.cjs +1 -0
- package/v4/locales/hy.js +1 -0
- package/v4/locales/id.cjs +1 -0
- package/v4/locales/id.js +1 -0
- package/v4/locales/index.cjs +19 -0
- package/v4/locales/is.cjs +1 -0
- package/v4/locales/is.js +1 -0
- package/v4/locales/it.cjs +1 -0
- package/v4/locales/it.js +1 -0
- package/v4/locales/ja.cjs +1 -0
- package/v4/locales/ja.js +1 -0
- package/v4/locales/ka.cjs +1 -0
- package/v4/locales/ka.js +1 -0
- package/v4/locales/km.cjs +1 -0
- package/v4/locales/km.js +1 -0
- package/v4/locales/kn.cjs +1 -0
- package/v4/locales/kn.js +1 -0
- package/v4/locales/ko.cjs +1 -0
- package/v4/locales/ko.js +1 -0
- package/v4/locales/lt.cjs +1 -0
- package/v4/locales/lt.js +1 -0
- package/v4/locales/mk.cjs +1 -0
- package/v4/locales/mk.js +1 -0
- package/v4/locales/ms.cjs +1 -0
- package/v4/locales/ms.js +1 -0
- package/v4/locales/ne.cjs +1 -0
- package/v4/locales/ne.js +1 -0
- package/v4/locales/nl.cjs +1 -0
- package/v4/locales/nl.js +1 -0
- package/v4/locales/nn.cjs +1 -0
- package/v4/locales/nn.js +1 -0
- package/v4/locales/no.cjs +1 -0
- package/v4/locales/no.js +1 -0
- package/v4/locales/ota.cjs +1 -0
- package/v4/locales/ota.js +1 -0
- package/v4/locales/pl.cjs +1 -0
- package/v4/locales/pl.js +1 -0
- package/v4/locales/ps.cjs +1 -0
- package/v4/locales/ps.js +1 -0
- package/v4/locales/pt-BR.cjs +1 -0
- package/v4/locales/pt-BR.js +1 -0
- package/v4/locales/pt.cjs +1 -0
- package/v4/locales/pt.js +1 -0
- package/v4/locales/ro.cjs +1 -0
- package/v4/locales/ro.js +1 -0
- package/v4/locales/ru.cjs +1 -0
- package/v4/locales/ru.js +1 -0
- package/v4/locales/sk.cjs +1 -0
- package/v4/locales/sk.js +1 -0
- package/v4/locales/sl.cjs +1 -0
- package/v4/locales/sl.js +1 -0
- package/v4/locales/sv.cjs +1 -0
- package/v4/locales/sv.js +1 -0
- package/v4/locales/ta.cjs +1 -0
- package/v4/locales/ta.js +1 -0
- package/v4/locales/th.cjs +1 -0
- package/v4/locales/th.js +1 -0
- package/v4/locales/tk.cjs +1 -0
- package/v4/locales/tk.js +1 -0
- package/v4/locales/tr.cjs +1 -0
- package/v4/locales/tr.js +1 -0
- package/v4/locales/uk.cjs +1 -0
- package/v4/locales/uk.js +1 -0
- package/v4/locales/ur.cjs +1 -0
- package/v4/locales/ur.js +1 -0
- package/v4/locales/uz.cjs +1 -0
- package/v4/locales/uz.js +1 -0
- package/v4/locales/vi.cjs +1 -0
- package/v4/locales/vi.js +1 -0
- package/v4/locales/yo.cjs +1 -0
- package/v4/locales/yo.js +1 -0
- package/v4/locales/zh-CN.cjs +1 -0
- package/v4/locales/zh-CN.js +1 -0
- package/v4/locales/zh-TW.cjs +1 -0
- package/v4/locales/zh-TW.js +1 -0
- package/v4/mini/checks.cjs +20 -2
- package/v4/mini/checks.d.cts +1 -1
- package/v4/mini/checks.d.ts +1 -1
- package/v4/mini/checks.js +1 -1
- package/v4/mini/coerce.cjs +19 -0
- package/v4/mini/deep-partial.cjs +19 -0
- package/v4/mini/external.cjs +22 -1
- package/v4/mini/external.d.cts +1 -1
- package/v4/mini/external.d.ts +1 -1
- package/v4/mini/external.js +1 -1
- package/v4/mini/in-out.cjs +19 -0
- package/v4/mini/index.cjs +19 -0
- package/v4/mini/iso.cjs +19 -0
- package/v4/mini/parse.cjs +19 -0
- package/v4/mini/schemas.cjs +42 -4
- package/v4/mini/schemas.d.cts +8 -0
- package/v4/mini/schemas.d.ts +8 -0
- package/v4/mini/schemas.js +19 -2
- package/v4-mini/index.cjs +19 -0
package/src/v4/core/checks.ts
CHANGED
|
@@ -79,15 +79,6 @@ export const $ZodCheckLessThan: core.$constructor<$ZodCheckLessThan> = /*@__PURE
|
|
|
79
79
|
$ZodCheck.init(inst, def);
|
|
80
80
|
const origin = numericOriginMap[typeof def.value as "number" | "bigint" | "object"];
|
|
81
81
|
|
|
82
|
-
inst._zod.onattach.push((inst) => {
|
|
83
|
-
const bag = inst._zod.bag;
|
|
84
|
-
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
85
|
-
if (def.value < curr) {
|
|
86
|
-
if (def.inclusive) bag.maximum = def.value;
|
|
87
|
-
else bag.exclusiveMaximum = def.value;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
82
|
inst._zod.check = (payload) => {
|
|
92
83
|
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
|
|
93
84
|
return;
|
|
@@ -130,15 +121,6 @@ export const $ZodCheckGreaterThan: core.$constructor<$ZodCheckGreaterThan> = /*@
|
|
|
130
121
|
$ZodCheck.init(inst, def);
|
|
131
122
|
const origin = numericOriginMap[typeof def.value as "number" | "bigint" | "object"];
|
|
132
123
|
|
|
133
|
-
inst._zod.onattach.push((inst) => {
|
|
134
|
-
const bag = inst._zod.bag;
|
|
135
|
-
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
136
|
-
if (def.value > curr) {
|
|
137
|
-
if (def.inclusive) bag.minimum = def.value;
|
|
138
|
-
else bag.exclusiveMinimum = def.value;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
|
|
142
124
|
inst._zod.check = (payload) => {
|
|
143
125
|
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
|
|
144
126
|
return;
|
|
@@ -181,10 +163,6 @@ export const $ZodCheckMultipleOf: core.$constructor<$ZodCheckMultipleOf<number |
|
|
|
181
163
|
/*@__PURE__*/ core.$constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
182
164
|
$ZodCheck.init(inst, def);
|
|
183
165
|
|
|
184
|
-
inst._zod.onattach.push((inst) => {
|
|
185
|
-
inst._zod.bag.multipleOf ??= def.value;
|
|
186
|
-
});
|
|
187
|
-
|
|
188
166
|
inst._zod.check = (payload) => {
|
|
189
167
|
if (typeof payload.value !== typeof def.value)
|
|
190
168
|
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
@@ -285,14 +263,6 @@ export const $ZodCheckNumberFormat: core.$constructor<$ZodCheckNumberFormat> = /
|
|
|
285
263
|
const origin = isInt ? "int" : "number";
|
|
286
264
|
const [minimum, maximum] = util.NUMBER_FORMAT_RANGES[def.format];
|
|
287
265
|
|
|
288
|
-
inst._zod.onattach.push((inst) => {
|
|
289
|
-
const bag = inst._zod.bag;
|
|
290
|
-
bag.format = def.format;
|
|
291
|
-
bag.minimum = minimum;
|
|
292
|
-
bag.maximum = maximum;
|
|
293
|
-
if (isInt) bag.pattern = regexes.integer;
|
|
294
|
-
});
|
|
295
|
-
|
|
296
266
|
inst._zod.check = (payload) => {
|
|
297
267
|
const input = payload.value;
|
|
298
268
|
|
|
@@ -413,13 +383,6 @@ export const $ZodCheckBigIntFormat: core.$constructor<$ZodCheckBigIntFormat> = /
|
|
|
413
383
|
|
|
414
384
|
const [minimum, maximum] = util.BIGINT_FORMAT_RANGES[def.format];
|
|
415
385
|
|
|
416
|
-
inst._zod.onattach.push((inst) => {
|
|
417
|
-
const bag = inst._zod.bag;
|
|
418
|
-
bag.format = def.format;
|
|
419
|
-
bag.minimum = minimum;
|
|
420
|
-
bag.maximum = maximum;
|
|
421
|
-
});
|
|
422
|
-
|
|
423
386
|
inst._zod.check = (payload) => {
|
|
424
387
|
const input = payload.value;
|
|
425
388
|
|
|
@@ -474,11 +437,6 @@ export const $ZodCheckMaxSize: core.$constructor<$ZodCheckMaxSize> = /*@__PURE__
|
|
|
474
437
|
|
|
475
438
|
inst._zod.def.when ??= _whenHasSize;
|
|
476
439
|
|
|
477
|
-
inst._zod.onattach.push((inst) => {
|
|
478
|
-
const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY) as number;
|
|
479
|
-
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
480
|
-
});
|
|
481
|
-
|
|
482
440
|
inst._zod.check = (payload) => {
|
|
483
441
|
const input = payload.value;
|
|
484
442
|
const size = input.size;
|
|
@@ -521,11 +479,6 @@ export const $ZodCheckMinSize: core.$constructor<$ZodCheckMinSize> = /*@__PURE__
|
|
|
521
479
|
|
|
522
480
|
inst._zod.def.when ??= _whenHasSize;
|
|
523
481
|
|
|
524
|
-
inst._zod.onattach.push((inst) => {
|
|
525
|
-
const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY) as number;
|
|
526
|
-
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
527
|
-
});
|
|
528
|
-
|
|
529
482
|
inst._zod.check = (payload) => {
|
|
530
483
|
const input = payload.value;
|
|
531
484
|
const size = input.size;
|
|
@@ -568,13 +521,6 @@ export const $ZodCheckSizeEquals: core.$constructor<$ZodCheckSizeEquals> = /*@__
|
|
|
568
521
|
|
|
569
522
|
inst._zod.def.when ??= _whenHasSize;
|
|
570
523
|
|
|
571
|
-
inst._zod.onattach.push((inst) => {
|
|
572
|
-
const bag = inst._zod.bag;
|
|
573
|
-
bag.minimum = def.size;
|
|
574
|
-
bag.maximum = def.size;
|
|
575
|
-
bag.size = def.size;
|
|
576
|
-
});
|
|
577
|
-
|
|
578
524
|
inst._zod.check = (payload) => {
|
|
579
525
|
const input = payload.value;
|
|
580
526
|
const size = input.size;
|
|
@@ -619,11 +565,6 @@ export const $ZodCheckMaxLength: core.$constructor<$ZodCheckMaxLength> = /*@__PU
|
|
|
619
565
|
|
|
620
566
|
inst._zod.def.when ??= _whenHasLength;
|
|
621
567
|
|
|
622
|
-
inst._zod.onattach.push((inst) => {
|
|
623
|
-
const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY) as number;
|
|
624
|
-
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
625
|
-
});
|
|
626
|
-
|
|
627
568
|
inst._zod.check = (payload) => {
|
|
628
569
|
const input = payload.value;
|
|
629
570
|
const units = input.length;
|
|
@@ -669,11 +610,6 @@ export const $ZodCheckMinLength: core.$constructor<$ZodCheckMinLength> = /*@__PU
|
|
|
669
610
|
|
|
670
611
|
inst._zod.def.when ??= _whenHasLength;
|
|
671
612
|
|
|
672
|
-
inst._zod.onattach.push((inst) => {
|
|
673
|
-
const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY) as number;
|
|
674
|
-
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
675
|
-
});
|
|
676
|
-
|
|
677
613
|
inst._zod.check = (payload) => {
|
|
678
614
|
const input = payload.value;
|
|
679
615
|
const units = input.length;
|
|
@@ -723,13 +659,6 @@ export const $ZodCheckLengthEquals: core.$constructor<$ZodCheckLengthEquals> = /
|
|
|
723
659
|
|
|
724
660
|
inst._zod.def.when ??= _whenHasLength;
|
|
725
661
|
|
|
726
|
-
inst._zod.onattach.push((inst) => {
|
|
727
|
-
const bag = inst._zod.bag;
|
|
728
|
-
bag.minimum = def.length;
|
|
729
|
-
bag.maximum = def.length;
|
|
730
|
-
bag.length = def.length;
|
|
731
|
-
});
|
|
732
|
-
|
|
733
662
|
inst._zod.check = (payload) => {
|
|
734
663
|
const input = payload.value;
|
|
735
664
|
const units = input.length;
|
|
@@ -782,6 +711,7 @@ export type $ZodStringFormats =
|
|
|
782
711
|
| "json_string"
|
|
783
712
|
| "e164"
|
|
784
713
|
| "credit_card"
|
|
714
|
+
| "iban"
|
|
785
715
|
| "lowercase"
|
|
786
716
|
| "uppercase"
|
|
787
717
|
| "regex"
|
|
@@ -809,15 +739,6 @@ export const $ZodCheckStringFormat: core.$constructor<$ZodCheckStringFormat> = /
|
|
|
809
739
|
(inst, def) => {
|
|
810
740
|
$ZodCheck.init(inst, def);
|
|
811
741
|
|
|
812
|
-
inst._zod.onattach.push((inst) => {
|
|
813
|
-
const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
|
|
814
|
-
bag.format = def.format;
|
|
815
|
-
if (def.pattern) {
|
|
816
|
-
bag.patterns ??= new Set();
|
|
817
|
-
bag.patterns.add(def.pattern);
|
|
818
|
-
}
|
|
819
|
-
});
|
|
820
|
-
|
|
821
742
|
if (def.pattern)
|
|
822
743
|
inst._zod.check ??= (payload) => {
|
|
823
744
|
def.pattern!.lastIndex = 0;
|
|
@@ -982,12 +903,6 @@ export const $ZodCheckIncludes: core.$constructor<$ZodCheckIncludes> = /*@__PURE
|
|
|
982
903
|
// (`{N,}`), not exactly `position` chars (`{N}`).
|
|
983
904
|
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
|
|
984
905
|
def.pattern = pattern;
|
|
985
|
-
inst._zod.onattach.push((inst) => {
|
|
986
|
-
const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
|
|
987
|
-
bag.patterns ??= new Set();
|
|
988
|
-
bag.patterns.add(pattern);
|
|
989
|
-
});
|
|
990
|
-
|
|
991
906
|
inst._zod.check = (payload) => {
|
|
992
907
|
if (payload.value.includes(def.includes, def.position)) return;
|
|
993
908
|
payload.issues.push({
|
|
@@ -1026,12 +941,6 @@ export const $ZodCheckStartsWith: core.$constructor<$ZodCheckStartsWith> = /*@__
|
|
|
1026
941
|
|
|
1027
942
|
const pattern = new RegExp(`^${util.escapeRegex(def.prefix)}.*`);
|
|
1028
943
|
def.pattern ??= pattern;
|
|
1029
|
-
inst._zod.onattach.push((inst) => {
|
|
1030
|
-
const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
|
|
1031
|
-
bag.patterns ??= new Set();
|
|
1032
|
-
bag.patterns.add(pattern);
|
|
1033
|
-
});
|
|
1034
|
-
|
|
1035
944
|
inst._zod.check = (payload) => {
|
|
1036
945
|
if (payload.value.startsWith(def.prefix)) return;
|
|
1037
946
|
payload.issues.push({
|
|
@@ -1070,12 +979,6 @@ export const $ZodCheckEndsWith: core.$constructor<$ZodCheckEndsWith> = /*@__PURE
|
|
|
1070
979
|
|
|
1071
980
|
const pattern = new RegExp(`.*${util.escapeRegex(def.suffix)}$`);
|
|
1072
981
|
def.pattern ??= pattern;
|
|
1073
|
-
inst._zod.onattach.push((inst) => {
|
|
1074
|
-
const bag = inst._zod.bag as schemas.$ZodStringInternals<unknown>["bag"];
|
|
1075
|
-
bag.patterns ??= new Set();
|
|
1076
|
-
bag.patterns.add(pattern);
|
|
1077
|
-
});
|
|
1078
|
-
|
|
1079
982
|
inst._zod.check = (payload) => {
|
|
1080
983
|
if (payload.value.endsWith(def.suffix)) return;
|
|
1081
984
|
payload.issues.push({
|
|
@@ -1164,9 +1067,6 @@ export const $ZodCheckMimeType: core.$constructor<$ZodCheckMimeType> = /*@__PURE
|
|
|
1164
1067
|
(inst, def) => {
|
|
1165
1068
|
$ZodCheck.init(inst, def);
|
|
1166
1069
|
const mimeSet = new Set(def.mime);
|
|
1167
|
-
inst._zod.onattach.push((inst) => {
|
|
1168
|
-
inst._zod.bag.mime = def.mime;
|
|
1169
|
-
});
|
|
1170
1070
|
inst._zod.check = (payload) => {
|
|
1171
1071
|
if (mimeSet.has(payload.value.type)) return;
|
|
1172
1072
|
payload.issues.push({
|