zod 4.2.0-canary.20250911T051520 → 4.2.0-canary.20250911T052041
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/package.json
CHANGED
|
@@ -920,6 +920,8 @@ test("CIDR v6 validation", () => {
|
|
|
920
920
|
expect(cidrV6.safeParse("not a cidr").success).toBe(false); // Invalid format
|
|
921
921
|
expect(cidrV6.safeParse("192.168.0.0/24").success).toBe(false); // IPv4 CIDR in v6 validation
|
|
922
922
|
expect(cidrV6.safeParse("2001:0db8:85a3::/64/whatever-after").success).toBe(false);
|
|
923
|
+
expect(cidrV6.safeParse("22d9:f4a8:6a90:f3bf:dcaa:2beb:5fba:0000/112").success).toBe(true);
|
|
924
|
+
expect(cidrV6.safeParse("22d9:f4a8:6a90:f3bf:dcaa:2beb:5fba:0000/112/268").success).toBe(false);
|
|
923
925
|
});
|
|
924
926
|
|
|
925
927
|
test("E.164 validation", () => {
|
package/src/v4/core/schemas.ts
CHANGED
|
@@ -830,10 +830,11 @@ export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$con
|
|
|
830
830
|
$ZodStringFormat.init(inst, def);
|
|
831
831
|
|
|
832
832
|
inst._zod.check = (payload) => {
|
|
833
|
-
const
|
|
834
|
-
const [address, prefix] = segments;
|
|
833
|
+
const parts = payload.value.split("/");
|
|
835
834
|
try {
|
|
836
|
-
if (
|
|
835
|
+
if (parts.length !== 2) throw new Error();
|
|
836
|
+
const [address, prefix] = parts;
|
|
837
|
+
if (!prefix) throw new Error();
|
|
837
838
|
const prefixNum = Number(prefix);
|
|
838
839
|
if (`${prefixNum}` !== prefix) throw new Error();
|
|
839
840
|
if (prefixNum < 0 || prefixNum > 128) throw new Error();
|
|
@@ -1763,7 +1764,7 @@ export interface $ZodObject<
|
|
|
1763
1764
|
function normalizeDef(def: $ZodObjectDef) {
|
|
1764
1765
|
const keys = Object.keys(def.shape);
|
|
1765
1766
|
for (const k of keys) {
|
|
1766
|
-
if (!def.shape[k]
|
|
1767
|
+
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
1767
1768
|
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
1768
1769
|
}
|
|
1769
1770
|
}
|
package/v4/core/schemas.cjs
CHANGED
|
@@ -364,10 +364,12 @@ exports.$ZodCIDRv6 = core.$constructor("$ZodCIDRv6", (inst, def) => {
|
|
|
364
364
|
def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
|
|
365
365
|
exports.$ZodStringFormat.init(inst, def);
|
|
366
366
|
inst._zod.check = (payload) => {
|
|
367
|
-
const
|
|
368
|
-
const [address, prefix] = segments;
|
|
367
|
+
const parts = payload.value.split("/");
|
|
369
368
|
try {
|
|
370
|
-
if (
|
|
369
|
+
if (parts.length !== 2)
|
|
370
|
+
throw new Error();
|
|
371
|
+
const [address, prefix] = parts;
|
|
372
|
+
if (!prefix)
|
|
371
373
|
throw new Error();
|
|
372
374
|
const prefixNum = Number(prefix);
|
|
373
375
|
if (`${prefixNum}` !== prefix)
|
|
@@ -747,7 +749,7 @@ function handlePropertyResult(result, final, key, input) {
|
|
|
747
749
|
function normalizeDef(def) {
|
|
748
750
|
const keys = Object.keys(def.shape);
|
|
749
751
|
for (const k of keys) {
|
|
750
|
-
if (!def.shape[k]
|
|
752
|
+
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
751
753
|
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
752
754
|
}
|
|
753
755
|
}
|
package/v4/core/schemas.js
CHANGED
|
@@ -333,10 +333,12 @@ export const $ZodCIDRv6 = /*@__PURE__*/ core.$constructor("$ZodCIDRv6", (inst, d
|
|
|
333
333
|
def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
|
|
334
334
|
$ZodStringFormat.init(inst, def);
|
|
335
335
|
inst._zod.check = (payload) => {
|
|
336
|
-
const
|
|
337
|
-
const [address, prefix] = segments;
|
|
336
|
+
const parts = payload.value.split("/");
|
|
338
337
|
try {
|
|
339
|
-
if (
|
|
338
|
+
if (parts.length !== 2)
|
|
339
|
+
throw new Error();
|
|
340
|
+
const [address, prefix] = parts;
|
|
341
|
+
if (!prefix)
|
|
340
342
|
throw new Error();
|
|
341
343
|
const prefixNum = Number(prefix);
|
|
342
344
|
if (`${prefixNum}` !== prefix)
|
|
@@ -716,7 +718,7 @@ function handlePropertyResult(result, final, key, input) {
|
|
|
716
718
|
function normalizeDef(def) {
|
|
717
719
|
const keys = Object.keys(def.shape);
|
|
718
720
|
for (const k of keys) {
|
|
719
|
-
if (!def.shape[k]
|
|
721
|
+
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
720
722
|
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
721
723
|
}
|
|
722
724
|
}
|