zod 4.2.1 → 4.3.0-canary.20251216T030621

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod",
3
- "version": "4.2.1",
3
+ "version": "4.3.0-canary.20251216T030621",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Colin McDonnell <zod@colinhacks.com>",
@@ -1023,6 +1023,8 @@ test("E.164 validation", () => {
1023
1023
  "+1 555 555 555", // space after plus sign
1024
1024
  "+1555 555 555", // space between numbers
1025
1025
  "+1555+555", // multiple plus signs
1026
+ "+0000000", // leading zero country code
1027
+ "+0123456789", // leading zero with more digits
1026
1028
  "+1555555555555555", // too long
1027
1029
  "+115abc55", // non numeric characters in number part
1028
1030
  "+1555555 ", // space after number
@@ -82,7 +82,8 @@ export const hostname: RegExp =
82
82
  export const domain: RegExp = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
83
83
 
84
84
  // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
85
- export const e164: RegExp = /^\+(?:[0-9]){6,14}[0-9]$/;
85
+ // E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
86
+ export const e164: RegExp = /^\+[1-9]\d{6,14}$/;
86
87
 
87
88
  // const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
88
89
  const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
@@ -85,7 +85,8 @@ exports.base64url = /^[A-Za-z0-9_-]*$/;
85
85
  exports.hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
86
86
  exports.domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
87
87
  // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
88
- exports.e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
88
+ // E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
89
+ exports.e164 = /^\+[1-9]\d{6,14}$/;
89
90
  // const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
90
91
  const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
91
92
  exports.date = new RegExp(`^${dateSource}$`);
@@ -53,7 +53,8 @@ export const base64url = /^[A-Za-z0-9_-]*$/;
53
53
  export const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
54
54
  export const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
55
55
  // https://blog.stevenlevithan.com/archives/validate-phone-number#r4-3 (regex sans spaces)
56
- export const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
56
+ // E.164: leading digit must be 1-9; total digits (excluding '+') between 7-15
57
+ export const e164 = /^\+[1-9]\d{6,14}$/;
57
58
  // const dateSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
58
59
  const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
59
60
  export const date = /*@__PURE__*/ new RegExp(`^${dateSource}$`);