@learncard/react 2.4.0 → 2.5.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.
Files changed (215) hide show
  1. package/dist/base.css +1 -1
  2. package/dist/base.js +1 -1
  3. package/dist/cjs/BoostSmallCard-c5b7cb24.js +110 -0
  4. package/dist/cjs/BoostSmallCard-c5b7cb24.js.map +1 -0
  5. package/dist/cjs/CaretRightFilled.svg +3 -0
  6. package/dist/cjs/{FlippyCard-2cbe2dbe.js → FlippyCard-209549c5.js} +2 -2
  7. package/dist/cjs/FlippyCard-209549c5.js.map +1 -0
  8. package/dist/cjs/{GenericCard-346b55ab.js → GenericCard-c3a42a6c.js} +2 -2
  9. package/dist/cjs/GenericCard-c3a42a6c.js.map +1 -0
  10. package/dist/cjs/{Notification-10b40c07.js → Notification-28ace54f.js} +50 -16
  11. package/dist/cjs/Notification-28ace54f.js.map +1 -0
  12. package/dist/cjs/SchoolIDCard-1baf77e8.js.map +1 -1
  13. package/dist/cjs/{VCCard-32c759a8.js → VCCard-8515516c.js} +3 -3
  14. package/dist/cjs/{VCCard-32c759a8.js.map → VCCard-8515516c.js.map} +1 -1
  15. package/dist/cjs/{VCDisplayBackFace-128b5cb2.js → VCDisplayBackFace-8c10fe7d.js} +3 -3
  16. package/dist/cjs/{VCDisplayBackFace-128b5cb2.js.map → VCDisplayBackFace-8c10fe7d.js.map} +1 -1
  17. package/dist/cjs/{VCDisplayCard-77133b71.js → VCDisplayCard-2356076d.js} +5 -5
  18. package/dist/cjs/VCDisplayCard-2356076d.js.map +1 -0
  19. package/dist/cjs/{VCDisplayCard2-a0a66aa6.js → VCDisplayCard2-721684cf.js} +55 -18
  20. package/dist/cjs/VCDisplayCard2-721684cf.js.map +1 -0
  21. package/dist/cjs/{VCVerificationPill-66e2a90f.js → VCVerificationPill-3ef39509.js} +2 -2
  22. package/dist/cjs/{VCVerificationPill-66e2a90f.js.map → VCVerificationPill-3ef39509.js.map} +1 -1
  23. package/dist/cjs/addawardlight.svg +8 -0
  24. package/dist/cjs/badge.png +0 -0
  25. package/dist/cjs/{constants-82581ffe.js → constants-00935dd2.js} +9 -4
  26. package/dist/cjs/constants-00935dd2.js.map +1 -0
  27. package/dist/cjs/{credential.helpers-7f7b9b02.js → credential.helpers-80101c51.js} +2 -2
  28. package/dist/cjs/{credential.helpers-7f7b9b02.js.map → credential.helpers-80101c51.js.map} +1 -1
  29. package/dist/cjs/index-6b34c190.js.map +1 -1
  30. package/dist/cjs/index.js +17 -12
  31. package/dist/cjs/index.js.map +1 -1
  32. package/dist/cjs/index10.js +4 -108
  33. package/dist/cjs/index10.js.map +1 -1
  34. package/dist/cjs/index11.js +134 -1
  35. package/dist/cjs/index11.js.map +1 -1
  36. package/dist/cjs/index12.js +3 -15
  37. package/dist/cjs/index12.js.map +1 -1
  38. package/dist/cjs/index13.js +15 -3
  39. package/dist/cjs/index13.js.map +1 -1
  40. package/dist/cjs/index14.js +3 -5
  41. package/dist/cjs/index14.js.map +1 -1
  42. package/dist/cjs/index15.js +5 -14
  43. package/dist/cjs/index15.js.map +1 -1
  44. package/dist/cjs/index16.js +14 -2
  45. package/dist/cjs/index16.js.map +1 -1
  46. package/dist/cjs/index17.js +2 -3
  47. package/dist/cjs/index17.js.map +1 -1
  48. package/dist/cjs/index18.js +3 -5
  49. package/dist/cjs/index18.js.map +1 -1
  50. package/dist/cjs/index19.js +6 -3
  51. package/dist/cjs/index19.js.map +1 -1
  52. package/dist/cjs/index20.js +3 -15
  53. package/dist/cjs/index20.js.map +1 -1
  54. package/dist/cjs/index21.js +4 -19
  55. package/dist/cjs/index21.js.map +1 -1
  56. package/dist/cjs/index22.js +31 -2
  57. package/dist/cjs/index22.js.map +1 -1
  58. package/dist/cjs/index23.js +2 -3
  59. package/dist/cjs/index23.js.map +1 -1
  60. package/dist/cjs/index24.js +3 -3
  61. package/dist/cjs/index25.js +3 -16
  62. package/dist/cjs/index25.js.map +1 -1
  63. package/dist/cjs/index26.js +16 -3
  64. package/dist/cjs/index26.js.map +1 -1
  65. package/dist/cjs/index27.js +3 -3
  66. package/dist/cjs/index28.js +3 -13
  67. package/dist/cjs/index28.js.map +1 -1
  68. package/dist/cjs/index29.js +13 -21
  69. package/dist/cjs/index29.js.map +1 -1
  70. package/dist/cjs/index3.js +30 -2
  71. package/dist/cjs/index3.js.map +1 -1
  72. package/dist/cjs/index30.js +14 -6
  73. package/dist/cjs/index30.js.map +1 -1
  74. package/dist/cjs/index31.js +6 -10
  75. package/dist/cjs/index31.js.map +1 -1
  76. package/dist/cjs/index32.js +13 -6
  77. package/dist/cjs/index32.js.map +1 -1
  78. package/dist/cjs/index33.js +12 -3
  79. package/dist/cjs/index33.js.map +1 -1
  80. package/dist/cjs/index34.js +4 -7
  81. package/dist/cjs/index34.js.map +1 -1
  82. package/dist/cjs/index35.js +4 -6
  83. package/dist/cjs/index35.js.map +1 -1
  84. package/dist/cjs/index36.js +6 -6
  85. package/dist/cjs/index37.js +15 -0
  86. package/dist/cjs/index37.js.map +1 -0
  87. package/dist/cjs/index4.js +2 -15
  88. package/dist/cjs/index4.js.map +1 -1
  89. package/dist/cjs/index5.js +4 -4
  90. package/dist/cjs/index6.js +14 -5
  91. package/dist/cjs/index6.js.map +1 -1
  92. package/dist/cjs/index7.js +2 -14
  93. package/dist/cjs/index7.js.map +1 -1
  94. package/dist/cjs/index8.js +18 -2
  95. package/dist/cjs/index8.js.map +1 -1
  96. package/dist/cjs/index9.js +2 -27
  97. package/dist/cjs/index9.js.map +1 -1
  98. package/dist/cjs/{types.esm-034454a2.js → types.esm-fa693b17.js} +695 -107
  99. package/dist/cjs/types.esm-fa693b17.js.map +1 -0
  100. package/dist/esm/BoostSmallCard-0f4fec3b.js +101 -0
  101. package/dist/esm/BoostSmallCard-0f4fec3b.js.map +1 -0
  102. package/dist/esm/CaretRightFilled.svg +3 -0
  103. package/dist/esm/{FlippyCard-f4f0b3f8.js → FlippyCard-a2de5cf1.js} +2 -2
  104. package/dist/esm/FlippyCard-a2de5cf1.js.map +1 -0
  105. package/dist/esm/{GenericCard-446f46e0.js → GenericCard-c2d91e3c.js} +3 -3
  106. package/dist/esm/GenericCard-c2d91e3c.js.map +1 -0
  107. package/dist/esm/{Notification-ac50790d.js → Notification-60c43061.js} +51 -17
  108. package/dist/esm/Notification-60c43061.js.map +1 -0
  109. package/dist/esm/SchoolIDCard-3b746226.js.map +1 -1
  110. package/dist/esm/{VCCard-c4096573.js → VCCard-c71cfd7f.js} +3 -3
  111. package/dist/esm/{VCCard-c4096573.js.map → VCCard-c71cfd7f.js.map} +1 -1
  112. package/dist/esm/{VCDisplayBackFace-853b8fdf.js → VCDisplayBackFace-2949e56d.js} +3 -3
  113. package/dist/esm/{VCDisplayBackFace-853b8fdf.js.map → VCDisplayBackFace-2949e56d.js.map} +1 -1
  114. package/dist/esm/{VCDisplayCard-be496708.js → VCDisplayCard-c23f431e.js} +5 -5
  115. package/dist/esm/VCDisplayCard-c23f431e.js.map +1 -0
  116. package/dist/esm/{VCDisplayCard2-c8e96ce8.js → VCDisplayCard2-33a1dc1d.js} +55 -18
  117. package/dist/esm/VCDisplayCard2-33a1dc1d.js.map +1 -0
  118. package/dist/esm/{VCVerificationPill-fc7b53d0.js → VCVerificationPill-8e2a3850.js} +2 -2
  119. package/dist/esm/{VCVerificationPill-fc7b53d0.js.map → VCVerificationPill-8e2a3850.js.map} +1 -1
  120. package/dist/esm/addawardlight.svg +8 -0
  121. package/dist/esm/badge.png +0 -0
  122. package/dist/esm/{constants-c0a08298.js → constants-6bb0dc94.js} +8 -4
  123. package/dist/esm/constants-6bb0dc94.js.map +1 -0
  124. package/dist/esm/{credential.helpers-78d3c24a.js → credential.helpers-5929133d.js} +2 -2
  125. package/dist/esm/{credential.helpers-78d3c24a.js.map → credential.helpers-5929133d.js.map} +1 -1
  126. package/dist/esm/index-52cf2d17.js.map +1 -1
  127. package/dist/esm/index.js +16 -12
  128. package/dist/esm/index.js.map +1 -1
  129. package/dist/esm/index10.js +4 -57
  130. package/dist/esm/index10.js.map +1 -1
  131. package/dist/esm/index11.js +82 -1
  132. package/dist/esm/index11.js.map +1 -1
  133. package/dist/esm/index12.js +2 -13
  134. package/dist/esm/index12.js.map +1 -1
  135. package/dist/esm/index13.js +13 -2
  136. package/dist/esm/index13.js.map +1 -1
  137. package/dist/esm/index14.js +2 -4
  138. package/dist/esm/index14.js.map +1 -1
  139. package/dist/esm/index15.js +4 -13
  140. package/dist/esm/index15.js.map +1 -1
  141. package/dist/esm/index16.js +13 -1
  142. package/dist/esm/index16.js.map +1 -1
  143. package/dist/esm/index17.js +1 -2
  144. package/dist/esm/index17.js.map +1 -1
  145. package/dist/esm/index18.js +2 -3
  146. package/dist/esm/index18.js.map +1 -1
  147. package/dist/esm/index19.js +4 -2
  148. package/dist/esm/index19.js.map +1 -1
  149. package/dist/esm/index20.js +2 -13
  150. package/dist/esm/index20.js.map +1 -1
  151. package/dist/esm/index21.js +2 -14
  152. package/dist/esm/index21.js.map +1 -1
  153. package/dist/esm/index22.js +26 -1
  154. package/dist/esm/index22.js.map +1 -1
  155. package/dist/esm/index23.js +1 -1
  156. package/dist/esm/index24.js +1 -2
  157. package/dist/esm/index24.js.map +1 -1
  158. package/dist/esm/index25.js +2 -15
  159. package/dist/esm/index25.js.map +1 -1
  160. package/dist/esm/index26.js +15 -2
  161. package/dist/esm/index26.js.map +1 -1
  162. package/dist/esm/index27.js +2 -2
  163. package/dist/esm/index28.js +2 -4
  164. package/dist/esm/index28.js.map +1 -1
  165. package/dist/esm/index29.js +4 -20
  166. package/dist/esm/index29.js.map +1 -1
  167. package/dist/esm/index3.js +29 -1
  168. package/dist/esm/index3.js.map +1 -1
  169. package/dist/esm/index30.js +13 -5
  170. package/dist/esm/index30.js.map +1 -1
  171. package/dist/esm/index31.js +5 -9
  172. package/dist/esm/index31.js.map +1 -1
  173. package/dist/esm/index32.js +12 -5
  174. package/dist/esm/index32.js.map +1 -1
  175. package/dist/esm/index33.js +7 -3
  176. package/dist/esm/index33.js.map +1 -1
  177. package/dist/esm/index34.js +4 -2
  178. package/dist/esm/index34.js.map +1 -1
  179. package/dist/esm/index35.js +3 -3
  180. package/dist/esm/index36.js +3 -5
  181. package/dist/esm/index36.js.map +1 -1
  182. package/dist/esm/index37.js +7 -0
  183. package/dist/esm/index37.js.map +1 -0
  184. package/dist/esm/index4.js +1 -14
  185. package/dist/esm/index4.js.map +1 -1
  186. package/dist/esm/index5.js +3 -2
  187. package/dist/esm/index5.js.map +1 -1
  188. package/dist/esm/index6.js +12 -4
  189. package/dist/esm/index6.js.map +1 -1
  190. package/dist/esm/index7.js +1 -13
  191. package/dist/esm/index7.js.map +1 -1
  192. package/dist/esm/index8.js +17 -1
  193. package/dist/esm/index8.js.map +1 -1
  194. package/dist/esm/index9.js +1 -26
  195. package/dist/esm/index9.js.map +1 -1
  196. package/dist/esm/{types.esm-9db3d858.js → types.esm-877355bb.js} +695 -107
  197. package/dist/esm/types.esm-877355bb.js.map +1 -0
  198. package/dist/index.d.ts +153 -171
  199. package/dist/main.css +1 -1
  200. package/dist/main.js +1 -1
  201. package/package.json +6 -6
  202. package/dist/cjs/FlippyCard-2cbe2dbe.js.map +0 -1
  203. package/dist/cjs/GenericCard-346b55ab.js.map +0 -1
  204. package/dist/cjs/Notification-10b40c07.js.map +0 -1
  205. package/dist/cjs/VCDisplayCard-77133b71.js.map +0 -1
  206. package/dist/cjs/VCDisplayCard2-a0a66aa6.js.map +0 -1
  207. package/dist/cjs/constants-82581ffe.js.map +0 -1
  208. package/dist/cjs/types.esm-034454a2.js.map +0 -1
  209. package/dist/esm/FlippyCard-f4f0b3f8.js.map +0 -1
  210. package/dist/esm/GenericCard-446f46e0.js.map +0 -1
  211. package/dist/esm/Notification-ac50790d.js.map +0 -1
  212. package/dist/esm/VCDisplayCard-be496708.js.map +0 -1
  213. package/dist/esm/VCDisplayCard2-c8e96ce8.js.map +0 -1
  214. package/dist/esm/constants-c0a08298.js.map +0 -1
  215. package/dist/esm/types.esm-9db3d858.js.map +0 -1
@@ -98,6 +98,8 @@ const getParsedType = (data) => {
98
98
  return ZodParsedType.function;
99
99
  case "bigint":
100
100
  return ZodParsedType.bigint;
101
+ case "symbol":
102
+ return ZodParsedType.symbol;
101
103
  case "object":
102
104
  if (Array.isArray(data)) {
103
105
  return ZodParsedType.array;
@@ -142,6 +144,7 @@ const ZodIssueCode = util.arrayToEnum([
142
144
  "too_big",
143
145
  "invalid_intersection_types",
144
146
  "not_multiple_of",
147
+ "not_finite",
145
148
  ]);
146
149
  const quotelessJson = (obj) => {
147
150
  const json = JSON.stringify(obj, null, 2);
@@ -308,25 +311,41 @@ const errorMap = (issue, _ctx) => {
308
311
  break;
309
312
  case ZodIssueCode.too_small:
310
313
  if (issue.type === "array")
311
- message = `Array must contain ${issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
314
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
312
315
  else if (issue.type === "string")
313
- message = `String must contain ${issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
316
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
314
317
  else if (issue.type === "number")
315
- message = `Number must be greater than ${issue.inclusive ? `or equal to ` : ``}${issue.minimum}`;
318
+ message = `Number must be ${issue.exact
319
+ ? `exactly equal to `
320
+ : issue.inclusive
321
+ ? `greater than or equal to `
322
+ : `greater than `}${issue.minimum}`;
316
323
  else if (issue.type === "date")
317
- message = `Date must be greater than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.minimum)}`;
324
+ message = `Date must be ${issue.exact
325
+ ? `exactly equal to `
326
+ : issue.inclusive
327
+ ? `greater than or equal to `
328
+ : `greater than `}${new Date(issue.minimum)}`;
318
329
  else
319
330
  message = "Invalid input";
320
331
  break;
321
332
  case ZodIssueCode.too_big:
322
333
  if (issue.type === "array")
323
- message = `Array must contain ${issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
334
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
324
335
  else if (issue.type === "string")
325
- message = `String must contain ${issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
336
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
326
337
  else if (issue.type === "number")
327
- message = `Number must be less than ${issue.inclusive ? `or equal to ` : ``}${issue.maximum}`;
338
+ message = `Number must be ${issue.exact
339
+ ? `exactly`
340
+ : issue.inclusive
341
+ ? `less than or equal to`
342
+ : `less than`} ${issue.maximum}`;
328
343
  else if (issue.type === "date")
329
- message = `Date must be smaller than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.maximum)}`;
344
+ message = `Date must be ${issue.exact
345
+ ? `exactly`
346
+ : issue.inclusive
347
+ ? `smaller than or equal to`
348
+ : `smaller than`} ${new Date(issue.maximum)}`;
330
349
  else
331
350
  message = "Invalid input";
332
351
  break;
@@ -339,6 +358,9 @@ const errorMap = (issue, _ctx) => {
339
358
  case ZodIssueCode.not_multiple_of:
340
359
  message = `Number must be a multiple of ${issue.multipleOf}`;
341
360
  break;
361
+ case ZodIssueCode.not_finite:
362
+ message = "Number must be finite";
363
+ break;
342
364
  default:
343
365
  message = _ctx.defaultError;
344
366
  util.assertNever(issue);
@@ -385,7 +407,7 @@ function addIssueToContext(ctx, issueData) {
385
407
  ctx.common.contextualErrorMap,
386
408
  ctx.schemaErrorMap,
387
409
  getErrorMap(),
388
- errorMap,
410
+ errorMap, // then global default map
389
411
  ].filter((x) => !!x),
390
412
  });
391
413
  ctx.common.issues.push(issue);
@@ -450,7 +472,7 @@ const OK = (value) => ({ status: "valid", value });
450
472
  const isAborted = (x) => x.status === "aborted";
451
473
  const isDirty = (x) => x.status === "dirty";
452
474
  const isValid = (x) => x.status === "valid";
453
- const isAsync = (x) => typeof Promise !== undefined && x instanceof Promise;
475
+ const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
454
476
 
455
477
  var errorUtil;
456
478
  (function (errorUtil) {
@@ -504,7 +526,6 @@ class ZodType {
504
526
  constructor(def) {
505
527
  /** Alias of safeParseAsync */
506
528
  this.spa = this.safeParseAsync;
507
- this.superRefine = this._refinement;
508
529
  this._def = def;
509
530
  this.parse = this.parse.bind(this);
510
531
  this.safeParse = this.safeParse.bind(this);
@@ -522,8 +543,11 @@ class ZodType {
522
543
  this.or = this.or.bind(this);
523
544
  this.and = this.and.bind(this);
524
545
  this.transform = this.transform.bind(this);
546
+ this.brand = this.brand.bind(this);
525
547
  this.default = this.default.bind(this);
548
+ this.catch = this.catch.bind(this);
526
549
  this.describe = this.describe.bind(this);
550
+ this.pipe = this.pipe.bind(this);
527
551
  this.isNullable = this.isNullable.bind(this);
528
552
  this.isOptional = this.isOptional.bind(this);
529
553
  }
@@ -609,7 +633,7 @@ class ZodType {
609
633
  data,
610
634
  parsedType: getParsedType(data),
611
635
  };
612
- const maybeAsyncResult = this._parse({ data, path: [], parent: ctx });
636
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
613
637
  const result = await (isAsync(maybeAsyncResult)
614
638
  ? maybeAsyncResult
615
639
  : Promise.resolve(maybeAsyncResult));
@@ -673,29 +697,33 @@ class ZodType {
673
697
  effect: { type: "refinement", refinement },
674
698
  });
675
699
  }
700
+ superRefine(refinement) {
701
+ return this._refinement(refinement);
702
+ }
676
703
  optional() {
677
- return ZodOptional.create(this);
704
+ return ZodOptional.create(this, this._def);
678
705
  }
679
706
  nullable() {
680
- return ZodNullable.create(this);
707
+ return ZodNullable.create(this, this._def);
681
708
  }
682
709
  nullish() {
683
- return this.optional().nullable();
710
+ return this.nullable().optional();
684
711
  }
685
712
  array() {
686
- return ZodArray.create(this);
713
+ return ZodArray.create(this, this._def);
687
714
  }
688
715
  promise() {
689
- return ZodPromise.create(this);
716
+ return ZodPromise.create(this, this._def);
690
717
  }
691
718
  or(option) {
692
- return ZodUnion.create([this, option]);
719
+ return ZodUnion.create([this, option], this._def);
693
720
  }
694
721
  and(incoming) {
695
- return ZodIntersection.create(this, incoming);
722
+ return ZodIntersection.create(this, incoming, this._def);
696
723
  }
697
724
  transform(transform) {
698
725
  return new ZodEffects({
726
+ ...processCreateParams(this._def),
699
727
  schema: this,
700
728
  typeName: ZodFirstPartyTypeKind.ZodEffects,
701
729
  effect: { type: "transform", transform },
@@ -704,6 +732,7 @@ class ZodType {
704
732
  default(def) {
705
733
  const defaultValueFunc = typeof def === "function" ? def : () => def;
706
734
  return new ZodDefault({
735
+ ...processCreateParams(this._def),
707
736
  innerType: this,
708
737
  defaultValue: defaultValueFunc,
709
738
  typeName: ZodFirstPartyTypeKind.ZodDefault,
@@ -713,7 +742,16 @@ class ZodType {
713
742
  return new ZodBranded({
714
743
  typeName: ZodFirstPartyTypeKind.ZodBranded,
715
744
  type: this,
716
- ...processCreateParams(undefined),
745
+ ...processCreateParams(this._def),
746
+ });
747
+ }
748
+ catch(def) {
749
+ const catchValueFunc = typeof def === "function" ? def : () => def;
750
+ return new ZodCatch({
751
+ ...processCreateParams(this._def),
752
+ innerType: this,
753
+ catchValue: catchValueFunc,
754
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
717
755
  });
718
756
  }
719
757
  describe(description) {
@@ -723,6 +761,9 @@ class ZodType {
723
761
  description,
724
762
  });
725
763
  }
764
+ pipe(target) {
765
+ return ZodPipeline.create(this, target);
766
+ }
726
767
  isOptional() {
727
768
  return this.safeParse(undefined).success;
728
769
  }
@@ -731,12 +772,48 @@ class ZodType {
731
772
  }
732
773
  }
733
774
  const cuidRegex = /^c[^\s-]{8,}$/i;
775
+ const cuid2Regex = /^[a-z][a-z0-9]*$/;
734
776
  const uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
735
777
  // from https://stackoverflow.com/a/46181/1550155
736
778
  // old version: too slow, didn't support unicode
737
779
  // const emailRegex = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
780
+ //old email regex
781
+ // const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@((?!-)([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{1,})[^-<>()[\].,;:\s@"]$/i;
738
782
  // eslint-disable-next-line
739
- const emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
783
+ const emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|([^-]([a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}))$/;
784
+ // interface IsDateStringOptions extends StringDateOptions {
785
+ /**
786
+ * Match any configuration
787
+ */
788
+ // any?: boolean;
789
+ // }
790
+ // Adapted from https://stackoverflow.com/a/3143231
791
+ const datetimeRegex = (args) => {
792
+ if (args.precision) {
793
+ if (args.offset) {
794
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
795
+ }
796
+ else {
797
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
798
+ }
799
+ }
800
+ else if (args.precision === 0) {
801
+ if (args.offset) {
802
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
803
+ }
804
+ else {
805
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
806
+ }
807
+ }
808
+ else {
809
+ if (args.offset) {
810
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
811
+ }
812
+ else {
813
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
814
+ }
815
+ }
816
+ };
740
817
  class ZodString extends ZodType {
741
818
  constructor() {
742
819
  super(...arguments);
@@ -756,6 +833,9 @@ class ZodString extends ZodType {
756
833
  });
757
834
  }
758
835
  _parse(input) {
836
+ if (this._def.coerce) {
837
+ input.data = String(input.data);
838
+ }
759
839
  const parsedType = this._getType(input);
760
840
  if (parsedType !== ZodParsedType.string) {
761
841
  const ctx = this._getOrReturnCtx(input);
@@ -779,6 +859,7 @@ class ZodString extends ZodType {
779
859
  minimum: check.value,
780
860
  type: "string",
781
861
  inclusive: true,
862
+ exact: false,
782
863
  message: check.message,
783
864
  });
784
865
  status.dirty();
@@ -792,11 +873,40 @@ class ZodString extends ZodType {
792
873
  maximum: check.value,
793
874
  type: "string",
794
875
  inclusive: true,
876
+ exact: false,
795
877
  message: check.message,
796
878
  });
797
879
  status.dirty();
798
880
  }
799
881
  }
882
+ else if (check.kind === "length") {
883
+ const tooBig = input.data.length > check.value;
884
+ const tooSmall = input.data.length < check.value;
885
+ if (tooBig || tooSmall) {
886
+ ctx = this._getOrReturnCtx(input, ctx);
887
+ if (tooBig) {
888
+ addIssueToContext(ctx, {
889
+ code: ZodIssueCode.too_big,
890
+ maximum: check.value,
891
+ type: "string",
892
+ inclusive: true,
893
+ exact: true,
894
+ message: check.message,
895
+ });
896
+ }
897
+ else if (tooSmall) {
898
+ addIssueToContext(ctx, {
899
+ code: ZodIssueCode.too_small,
900
+ minimum: check.value,
901
+ type: "string",
902
+ inclusive: true,
903
+ exact: true,
904
+ message: check.message,
905
+ });
906
+ }
907
+ status.dirty();
908
+ }
909
+ }
800
910
  else if (check.kind === "email") {
801
911
  if (!emailRegex.test(input.data)) {
802
912
  ctx = this._getOrReturnCtx(input, ctx);
@@ -830,6 +940,17 @@ class ZodString extends ZodType {
830
940
  status.dirty();
831
941
  }
832
942
  }
943
+ else if (check.kind === "cuid2") {
944
+ if (!cuid2Regex.test(input.data)) {
945
+ ctx = this._getOrReturnCtx(input, ctx);
946
+ addIssueToContext(ctx, {
947
+ validation: "cuid2",
948
+ code: ZodIssueCode.invalid_string,
949
+ message: check.message,
950
+ });
951
+ status.dirty();
952
+ }
953
+ }
833
954
  else if (check.kind === "url") {
834
955
  try {
835
956
  new URL(input.data);
@@ -882,6 +1003,18 @@ class ZodString extends ZodType {
882
1003
  status.dirty();
883
1004
  }
884
1005
  }
1006
+ else if (check.kind === "datetime") {
1007
+ const regex = datetimeRegex(check);
1008
+ if (!regex.test(input.data)) {
1009
+ ctx = this._getOrReturnCtx(input, ctx);
1010
+ addIssueToContext(ctx, {
1011
+ code: ZodIssueCode.invalid_string,
1012
+ validation: "datetime",
1013
+ message: check.message,
1014
+ });
1015
+ status.dirty();
1016
+ }
1017
+ }
885
1018
  else {
886
1019
  util.assertNever(check);
887
1020
  }
@@ -906,6 +1039,26 @@ class ZodString extends ZodType {
906
1039
  cuid(message) {
907
1040
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
908
1041
  }
1042
+ cuid2(message) {
1043
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1044
+ }
1045
+ datetime(options) {
1046
+ var _a;
1047
+ if (typeof options === "string") {
1048
+ return this._addCheck({
1049
+ kind: "datetime",
1050
+ precision: null,
1051
+ offset: false,
1052
+ message: options,
1053
+ });
1054
+ }
1055
+ return this._addCheck({
1056
+ kind: "datetime",
1057
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1058
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1059
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
1060
+ });
1061
+ }
909
1062
  regex(regex, message) {
910
1063
  return this._addCheck({
911
1064
  kind: "regex",
@@ -942,7 +1095,14 @@ class ZodString extends ZodType {
942
1095
  });
943
1096
  }
944
1097
  length(len, message) {
945
- return this.min(len, message).max(len, message);
1098
+ return this._addCheck({
1099
+ kind: "length",
1100
+ value: len,
1101
+ ...errorUtil.errToObj(message),
1102
+ });
1103
+ }
1104
+ get isDatetime() {
1105
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
946
1106
  }
947
1107
  get isEmail() {
948
1108
  return !!this._def.checks.find((ch) => ch.kind === "email");
@@ -956,6 +1116,9 @@ class ZodString extends ZodType {
956
1116
  get isCUID() {
957
1117
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
958
1118
  }
1119
+ get isCUID2() {
1120
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1121
+ }
959
1122
  get minLength() {
960
1123
  let min = null;
961
1124
  for (const ch of this._def.checks) {
@@ -978,9 +1141,11 @@ class ZodString extends ZodType {
978
1141
  }
979
1142
  }
980
1143
  ZodString.create = (params) => {
1144
+ var _a;
981
1145
  return new ZodString({
982
1146
  checks: [],
983
1147
  typeName: ZodFirstPartyTypeKind.ZodString,
1148
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
984
1149
  ...processCreateParams(params),
985
1150
  });
986
1151
  };
@@ -1001,6 +1166,9 @@ class ZodNumber extends ZodType {
1001
1166
  this.step = this.multipleOf;
1002
1167
  }
1003
1168
  _parse(input) {
1169
+ if (this._def.coerce) {
1170
+ input.data = Number(input.data);
1171
+ }
1004
1172
  const parsedType = this._getType(input);
1005
1173
  if (parsedType !== ZodParsedType.number) {
1006
1174
  const ctx = this._getOrReturnCtx(input);
@@ -1037,6 +1205,7 @@ class ZodNumber extends ZodType {
1037
1205
  minimum: check.value,
1038
1206
  type: "number",
1039
1207
  inclusive: check.inclusive,
1208
+ exact: false,
1040
1209
  message: check.message,
1041
1210
  });
1042
1211
  status.dirty();
@@ -1053,6 +1222,7 @@ class ZodNumber extends ZodType {
1053
1222
  maximum: check.value,
1054
1223
  type: "number",
1055
1224
  inclusive: check.inclusive,
1225
+ exact: false,
1056
1226
  message: check.message,
1057
1227
  });
1058
1228
  status.dirty();
@@ -1069,6 +1239,16 @@ class ZodNumber extends ZodType {
1069
1239
  status.dirty();
1070
1240
  }
1071
1241
  }
1242
+ else if (check.kind === "finite") {
1243
+ if (!Number.isFinite(input.data)) {
1244
+ ctx = this._getOrReturnCtx(input, ctx);
1245
+ addIssueToContext(ctx, {
1246
+ code: ZodIssueCode.not_finite,
1247
+ message: check.message,
1248
+ });
1249
+ status.dirty();
1250
+ }
1251
+ }
1072
1252
  else {
1073
1253
  util.assertNever(check);
1074
1254
  }
@@ -1152,6 +1332,12 @@ class ZodNumber extends ZodType {
1152
1332
  message: errorUtil.toString(message),
1153
1333
  });
1154
1334
  }
1335
+ finite(message) {
1336
+ return this._addCheck({
1337
+ kind: "finite",
1338
+ message: errorUtil.toString(message),
1339
+ });
1340
+ }
1155
1341
  get minValue() {
1156
1342
  let min = null;
1157
1343
  for (const ch of this._def.checks) {
@@ -1173,18 +1359,42 @@ class ZodNumber extends ZodType {
1173
1359
  return max;
1174
1360
  }
1175
1361
  get isInt() {
1176
- return !!this._def.checks.find((ch) => ch.kind === "int");
1362
+ return !!this._def.checks.find((ch) => ch.kind === "int" ||
1363
+ (ch.kind === "multipleOf" && util.isInteger(ch.value)));
1364
+ }
1365
+ get isFinite() {
1366
+ let max = null, min = null;
1367
+ for (const ch of this._def.checks) {
1368
+ if (ch.kind === "finite" ||
1369
+ ch.kind === "int" ||
1370
+ ch.kind === "multipleOf") {
1371
+ return true;
1372
+ }
1373
+ else if (ch.kind === "min") {
1374
+ if (min === null || ch.value > min)
1375
+ min = ch.value;
1376
+ }
1377
+ else if (ch.kind === "max") {
1378
+ if (max === null || ch.value < max)
1379
+ max = ch.value;
1380
+ }
1381
+ }
1382
+ return Number.isFinite(min) && Number.isFinite(max);
1177
1383
  }
1178
1384
  }
1179
1385
  ZodNumber.create = (params) => {
1180
1386
  return new ZodNumber({
1181
1387
  checks: [],
1182
1388
  typeName: ZodFirstPartyTypeKind.ZodNumber,
1389
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1183
1390
  ...processCreateParams(params),
1184
1391
  });
1185
1392
  };
1186
1393
  class ZodBigInt extends ZodType {
1187
1394
  _parse(input) {
1395
+ if (this._def.coerce) {
1396
+ input.data = BigInt(input.data);
1397
+ }
1188
1398
  const parsedType = this._getType(input);
1189
1399
  if (parsedType !== ZodParsedType.bigint) {
1190
1400
  const ctx = this._getOrReturnCtx(input);
@@ -1199,13 +1409,18 @@ class ZodBigInt extends ZodType {
1199
1409
  }
1200
1410
  }
1201
1411
  ZodBigInt.create = (params) => {
1412
+ var _a;
1202
1413
  return new ZodBigInt({
1203
1414
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
1415
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1204
1416
  ...processCreateParams(params),
1205
1417
  });
1206
1418
  };
1207
1419
  class ZodBoolean extends ZodType {
1208
1420
  _parse(input) {
1421
+ if (this._def.coerce) {
1422
+ input.data = Boolean(input.data);
1423
+ }
1209
1424
  const parsedType = this._getType(input);
1210
1425
  if (parsedType !== ZodParsedType.boolean) {
1211
1426
  const ctx = this._getOrReturnCtx(input);
@@ -1222,11 +1437,15 @@ class ZodBoolean extends ZodType {
1222
1437
  ZodBoolean.create = (params) => {
1223
1438
  return new ZodBoolean({
1224
1439
  typeName: ZodFirstPartyTypeKind.ZodBoolean,
1440
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1225
1441
  ...processCreateParams(params),
1226
1442
  });
1227
1443
  };
1228
1444
  class ZodDate extends ZodType {
1229
1445
  _parse(input) {
1446
+ if (this._def.coerce) {
1447
+ input.data = new Date(input.data);
1448
+ }
1230
1449
  const parsedType = this._getType(input);
1231
1450
  if (parsedType !== ZodParsedType.date) {
1232
1451
  const ctx = this._getOrReturnCtx(input);
@@ -1254,6 +1473,7 @@ class ZodDate extends ZodType {
1254
1473
  code: ZodIssueCode.too_small,
1255
1474
  message: check.message,
1256
1475
  inclusive: true,
1476
+ exact: false,
1257
1477
  minimum: check.value,
1258
1478
  type: "date",
1259
1479
  });
@@ -1267,6 +1487,7 @@ class ZodDate extends ZodType {
1267
1487
  code: ZodIssueCode.too_big,
1268
1488
  message: check.message,
1269
1489
  inclusive: true,
1490
+ exact: false,
1270
1491
  maximum: check.value,
1271
1492
  type: "date",
1272
1493
  });
@@ -1326,10 +1547,32 @@ class ZodDate extends ZodType {
1326
1547
  ZodDate.create = (params) => {
1327
1548
  return new ZodDate({
1328
1549
  checks: [],
1550
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1329
1551
  typeName: ZodFirstPartyTypeKind.ZodDate,
1330
1552
  ...processCreateParams(params),
1331
1553
  });
1332
1554
  };
1555
+ class ZodSymbol extends ZodType {
1556
+ _parse(input) {
1557
+ const parsedType = this._getType(input);
1558
+ if (parsedType !== ZodParsedType.symbol) {
1559
+ const ctx = this._getOrReturnCtx(input);
1560
+ addIssueToContext(ctx, {
1561
+ code: ZodIssueCode.invalid_type,
1562
+ expected: ZodParsedType.symbol,
1563
+ received: ctx.parsedType,
1564
+ });
1565
+ return INVALID;
1566
+ }
1567
+ return OK(input.data);
1568
+ }
1569
+ }
1570
+ ZodSymbol.create = (params) => {
1571
+ return new ZodSymbol({
1572
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
1573
+ ...processCreateParams(params),
1574
+ });
1575
+ };
1333
1576
  class ZodUndefined extends ZodType {
1334
1577
  _parse(input) {
1335
1578
  const parsedType = this._getType(input);
@@ -1454,6 +1697,22 @@ class ZodArray extends ZodType {
1454
1697
  });
1455
1698
  return INVALID;
1456
1699
  }
1700
+ if (def.exactLength !== null) {
1701
+ const tooBig = ctx.data.length > def.exactLength.value;
1702
+ const tooSmall = ctx.data.length < def.exactLength.value;
1703
+ if (tooBig || tooSmall) {
1704
+ addIssueToContext(ctx, {
1705
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
1706
+ minimum: (tooSmall ? def.exactLength.value : undefined),
1707
+ maximum: (tooBig ? def.exactLength.value : undefined),
1708
+ type: "array",
1709
+ inclusive: true,
1710
+ exact: true,
1711
+ message: def.exactLength.message,
1712
+ });
1713
+ status.dirty();
1714
+ }
1715
+ }
1457
1716
  if (def.minLength !== null) {
1458
1717
  if (ctx.data.length < def.minLength.value) {
1459
1718
  addIssueToContext(ctx, {
@@ -1461,6 +1720,7 @@ class ZodArray extends ZodType {
1461
1720
  minimum: def.minLength.value,
1462
1721
  type: "array",
1463
1722
  inclusive: true,
1723
+ exact: false,
1464
1724
  message: def.minLength.message,
1465
1725
  });
1466
1726
  status.dirty();
@@ -1473,19 +1733,20 @@ class ZodArray extends ZodType {
1473
1733
  maximum: def.maxLength.value,
1474
1734
  type: "array",
1475
1735
  inclusive: true,
1736
+ exact: false,
1476
1737
  message: def.maxLength.message,
1477
1738
  });
1478
1739
  status.dirty();
1479
1740
  }
1480
1741
  }
1481
1742
  if (ctx.common.async) {
1482
- return Promise.all(ctx.data.map((item, i) => {
1743
+ return Promise.all([...ctx.data].map((item, i) => {
1483
1744
  return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1484
1745
  })).then((result) => {
1485
1746
  return ParseStatus.mergeArray(status, result);
1486
1747
  });
1487
1748
  }
1488
- const result = ctx.data.map((item, i) => {
1749
+ const result = [...ctx.data].map((item, i) => {
1489
1750
  return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1490
1751
  });
1491
1752
  return ParseStatus.mergeArray(status, result);
@@ -1506,7 +1767,10 @@ class ZodArray extends ZodType {
1506
1767
  });
1507
1768
  }
1508
1769
  length(len, message) {
1509
- return this.min(len, message).max(len, message);
1770
+ return new ZodArray({
1771
+ ...this._def,
1772
+ exactLength: { value: len, message: errorUtil.toString(message) },
1773
+ });
1510
1774
  }
1511
1775
  nonempty(message) {
1512
1776
  return this.min(1, message);
@@ -1517,6 +1781,7 @@ ZodArray.create = (schema, params) => {
1517
1781
  type: schema,
1518
1782
  minLength: null,
1519
1783
  maxLength: null,
1784
+ exactLength: null,
1520
1785
  typeName: ZodFirstPartyTypeKind.ZodArray,
1521
1786
  ...processCreateParams(params),
1522
1787
  });
@@ -1533,19 +1798,10 @@ var objectUtil;
1533
1798
  objectUtil.mergeShapes = (first, second) => {
1534
1799
  return {
1535
1800
  ...first,
1536
- ...second,
1801
+ ...second, // second overwrites first
1537
1802
  };
1538
1803
  };
1539
1804
  })(objectUtil || (objectUtil = {}));
1540
- const AugmentFactory = (def) => (augmentation) => {
1541
- return new ZodObject({
1542
- ...def,
1543
- shape: () => ({
1544
- ...def.shape(),
1545
- ...augmentation,
1546
- }),
1547
- });
1548
- };
1549
1805
  function deepPartialify(schema) {
1550
1806
  if (schema instanceof ZodObject) {
1551
1807
  const newShape = {};
@@ -1583,8 +1839,43 @@ class ZodObject extends ZodType {
1583
1839
  * If you want to pass through unknown properties, use `.passthrough()` instead.
1584
1840
  */
1585
1841
  this.nonstrict = this.passthrough;
1586
- this.augment = AugmentFactory(this._def);
1587
- this.extend = AugmentFactory(this._def);
1842
+ // extend<
1843
+ // Augmentation extends ZodRawShape,
1844
+ // NewOutput extends util.flatten<{
1845
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1846
+ // ? Augmentation[k]["_output"]
1847
+ // : k extends keyof Output
1848
+ // ? Output[k]
1849
+ // : never;
1850
+ // }>,
1851
+ // NewInput extends util.flatten<{
1852
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1853
+ // ? Augmentation[k]["_input"]
1854
+ // : k extends keyof Input
1855
+ // ? Input[k]
1856
+ // : never;
1857
+ // }>
1858
+ // >(
1859
+ // augmentation: Augmentation
1860
+ // ): ZodObject<
1861
+ // extendShape<T, Augmentation>,
1862
+ // UnknownKeys,
1863
+ // Catchall,
1864
+ // NewOutput,
1865
+ // NewInput
1866
+ // > {
1867
+ // return new ZodObject({
1868
+ // ...this._def,
1869
+ // shape: () => ({
1870
+ // ...this._def.shape(),
1871
+ // ...augmentation,
1872
+ // }),
1873
+ // }) as any;
1874
+ // }
1875
+ /**
1876
+ * @deprecated Use `.extend` instead
1877
+ * */
1878
+ this.augment = this.extend;
1588
1879
  }
1589
1880
  _getCached() {
1590
1881
  if (this._cached !== null)
@@ -1721,8 +2012,31 @@ class ZodObject extends ZodType {
1721
2012
  unknownKeys: "passthrough",
1722
2013
  });
1723
2014
  }
1724
- setKey(key, schema) {
1725
- return this.augment({ [key]: schema });
2015
+ // const AugmentFactory =
2016
+ // <Def extends ZodObjectDef>(def: Def) =>
2017
+ // <Augmentation extends ZodRawShape>(
2018
+ // augmentation: Augmentation
2019
+ // ): ZodObject<
2020
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2021
+ // Def["unknownKeys"],
2022
+ // Def["catchall"]
2023
+ // > => {
2024
+ // return new ZodObject({
2025
+ // ...def,
2026
+ // shape: () => ({
2027
+ // ...def.shape(),
2028
+ // ...augmentation,
2029
+ // }),
2030
+ // }) as any;
2031
+ // };
2032
+ extend(augmentation) {
2033
+ return new ZodObject({
2034
+ ...this._def,
2035
+ shape: () => ({
2036
+ ...this._def.shape(),
2037
+ ...augmentation,
2038
+ }),
2039
+ });
1726
2040
  }
1727
2041
  /**
1728
2042
  * Prior to zod@1.0.12 there was a bug in the
@@ -1730,10 +2044,6 @@ class ZodObject extends ZodType {
1730
2044
  * upgrade if you are experiencing issues.
1731
2045
  */
1732
2046
  merge(merging) {
1733
- // const mergedShape = objectUtil.mergeShapes(
1734
- // this._def.shape(),
1735
- // merging._def.shape()
1736
- // );
1737
2047
  const merged = new ZodObject({
1738
2048
  unknownKeys: merging._def.unknownKeys,
1739
2049
  catchall: merging._def.catchall,
@@ -1742,6 +2052,65 @@ class ZodObject extends ZodType {
1742
2052
  });
1743
2053
  return merged;
1744
2054
  }
2055
+ // merge<
2056
+ // Incoming extends AnyZodObject,
2057
+ // Augmentation extends Incoming["shape"],
2058
+ // NewOutput extends {
2059
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2060
+ // ? Augmentation[k]["_output"]
2061
+ // : k extends keyof Output
2062
+ // ? Output[k]
2063
+ // : never;
2064
+ // },
2065
+ // NewInput extends {
2066
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2067
+ // ? Augmentation[k]["_input"]
2068
+ // : k extends keyof Input
2069
+ // ? Input[k]
2070
+ // : never;
2071
+ // }
2072
+ // >(
2073
+ // merging: Incoming
2074
+ // ): ZodObject<
2075
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2076
+ // Incoming["_def"]["unknownKeys"],
2077
+ // Incoming["_def"]["catchall"],
2078
+ // NewOutput,
2079
+ // NewInput
2080
+ // > {
2081
+ // const merged: any = new ZodObject({
2082
+ // unknownKeys: merging._def.unknownKeys,
2083
+ // catchall: merging._def.catchall,
2084
+ // shape: () =>
2085
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2086
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2087
+ // }) as any;
2088
+ // return merged;
2089
+ // }
2090
+ setKey(key, schema) {
2091
+ return this.augment({ [key]: schema });
2092
+ }
2093
+ // merge<Incoming extends AnyZodObject>(
2094
+ // merging: Incoming
2095
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2096
+ // ZodObject<
2097
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2098
+ // Incoming["_def"]["unknownKeys"],
2099
+ // Incoming["_def"]["catchall"]
2100
+ // > {
2101
+ // // const mergedShape = objectUtil.mergeShapes(
2102
+ // // this._def.shape(),
2103
+ // // merging._def.shape()
2104
+ // // );
2105
+ // const merged: any = new ZodObject({
2106
+ // unknownKeys: merging._def.unknownKeys,
2107
+ // catchall: merging._def.catchall,
2108
+ // shape: () =>
2109
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2110
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2111
+ // }) as any;
2112
+ // return merged;
2113
+ // }
1745
2114
  catchall(index) {
1746
2115
  return new ZodObject({
1747
2116
  ...this._def,
@@ -1750,10 +2119,10 @@ class ZodObject extends ZodType {
1750
2119
  }
1751
2120
  pick(mask) {
1752
2121
  const shape = {};
1753
- util.objectKeys(mask).map((key) => {
1754
- // only add to shape if key corresponds to an element of the current shape
1755
- if (this.shape[key])
2122
+ util.objectKeys(mask).forEach((key) => {
2123
+ if (mask[key] && this.shape[key]) {
1756
2124
  shape[key] = this.shape[key];
2125
+ }
1757
2126
  });
1758
2127
  return new ZodObject({
1759
2128
  ...this._def,
@@ -1762,8 +2131,8 @@ class ZodObject extends ZodType {
1762
2131
  }
1763
2132
  omit(mask) {
1764
2133
  const shape = {};
1765
- util.objectKeys(this.shape).map((key) => {
1766
- if (util.objectKeys(mask).indexOf(key) === -1) {
2134
+ util.objectKeys(this.shape).forEach((key) => {
2135
+ if (!mask[key]) {
1767
2136
  shape[key] = this.shape[key];
1768
2137
  }
1769
2138
  });
@@ -1777,41 +2146,35 @@ class ZodObject extends ZodType {
1777
2146
  }
1778
2147
  partial(mask) {
1779
2148
  const newShape = {};
1780
- if (mask) {
1781
- util.objectKeys(this.shape).map((key) => {
1782
- if (util.objectKeys(mask).indexOf(key) === -1) {
1783
- newShape[key] = this.shape[key];
1784
- }
1785
- else {
1786
- newShape[key] = this.shape[key].optional();
1787
- }
1788
- });
1789
- return new ZodObject({
1790
- ...this._def,
1791
- shape: () => newShape,
1792
- });
1793
- }
1794
- else {
1795
- for (const key in this.shape) {
1796
- const fieldSchema = this.shape[key];
2149
+ util.objectKeys(this.shape).forEach((key) => {
2150
+ const fieldSchema = this.shape[key];
2151
+ if (mask && !mask[key]) {
2152
+ newShape[key] = fieldSchema;
2153
+ }
2154
+ else {
1797
2155
  newShape[key] = fieldSchema.optional();
1798
2156
  }
1799
- }
2157
+ });
1800
2158
  return new ZodObject({
1801
2159
  ...this._def,
1802
2160
  shape: () => newShape,
1803
2161
  });
1804
2162
  }
1805
- required() {
2163
+ required(mask) {
1806
2164
  const newShape = {};
1807
- for (const key in this.shape) {
1808
- const fieldSchema = this.shape[key];
1809
- let newField = fieldSchema;
1810
- while (newField instanceof ZodOptional) {
1811
- newField = newField._def.innerType;
2165
+ util.objectKeys(this.shape).forEach((key) => {
2166
+ if (mask && !mask[key]) {
2167
+ newShape[key] = this.shape[key];
1812
2168
  }
1813
- newShape[key] = newField;
1814
- }
2169
+ else {
2170
+ const fieldSchema = this.shape[key];
2171
+ let newField = fieldSchema;
2172
+ while (newField instanceof ZodOptional) {
2173
+ newField = newField._def.innerType;
2174
+ }
2175
+ newShape[key] = newField;
2176
+ }
2177
+ });
1815
2178
  return new ZodObject({
1816
2179
  ...this._def,
1817
2180
  shape: () => newShape,
@@ -1944,6 +2307,43 @@ ZodUnion.create = (types, params) => {
1944
2307
  ...processCreateParams(params),
1945
2308
  });
1946
2309
  };
2310
+ /////////////////////////////////////////////////////
2311
+ /////////////////////////////////////////////////////
2312
+ ////////// //////////
2313
+ ////////// ZodDiscriminatedUnion //////////
2314
+ ////////// //////////
2315
+ /////////////////////////////////////////////////////
2316
+ /////////////////////////////////////////////////////
2317
+ const getDiscriminator = (type) => {
2318
+ if (type instanceof ZodLazy) {
2319
+ return getDiscriminator(type.schema);
2320
+ }
2321
+ else if (type instanceof ZodEffects) {
2322
+ return getDiscriminator(type.innerType());
2323
+ }
2324
+ else if (type instanceof ZodLiteral) {
2325
+ return [type.value];
2326
+ }
2327
+ else if (type instanceof ZodEnum) {
2328
+ return type.options;
2329
+ }
2330
+ else if (type instanceof ZodNativeEnum) {
2331
+ // eslint-disable-next-line ban/ban
2332
+ return Object.keys(type.enum);
2333
+ }
2334
+ else if (type instanceof ZodDefault) {
2335
+ return getDiscriminator(type._def.innerType);
2336
+ }
2337
+ else if (type instanceof ZodUndefined) {
2338
+ return [undefined];
2339
+ }
2340
+ else if (type instanceof ZodNull) {
2341
+ return [null];
2342
+ }
2343
+ else {
2344
+ return null;
2345
+ }
2346
+ };
1947
2347
  class ZodDiscriminatedUnion extends ZodType {
1948
2348
  _parse(input) {
1949
2349
  const { ctx } = this._processInputParams(input);
@@ -1957,11 +2357,11 @@ class ZodDiscriminatedUnion extends ZodType {
1957
2357
  }
1958
2358
  const discriminator = this.discriminator;
1959
2359
  const discriminatorValue = ctx.data[discriminator];
1960
- const option = this.options.get(discriminatorValue);
2360
+ const option = this.optionsMap.get(discriminatorValue);
1961
2361
  if (!option) {
1962
2362
  addIssueToContext(ctx, {
1963
2363
  code: ZodIssueCode.invalid_union_discriminator,
1964
- options: this.validDiscriminatorValues,
2364
+ options: Array.from(this.optionsMap.keys()),
1965
2365
  path: [discriminator],
1966
2366
  });
1967
2367
  return INVALID;
@@ -1984,12 +2384,12 @@ class ZodDiscriminatedUnion extends ZodType {
1984
2384
  get discriminator() {
1985
2385
  return this._def.discriminator;
1986
2386
  }
1987
- get validDiscriminatorValues() {
1988
- return Array.from(this.options.keys());
1989
- }
1990
2387
  get options() {
1991
2388
  return this._def.options;
1992
2389
  }
2390
+ get optionsMap() {
2391
+ return this._def.optionsMap;
2392
+ }
1993
2393
  /**
1994
2394
  * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
1995
2395
  * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
@@ -1998,26 +2398,27 @@ class ZodDiscriminatedUnion extends ZodType {
1998
2398
  * @param types an array of object schemas
1999
2399
  * @param params
2000
2400
  */
2001
- static create(discriminator, types, params) {
2401
+ static create(discriminator, options, params) {
2002
2402
  // Get all the valid discriminator values
2003
- const options = new Map();
2004
- try {
2005
- types.forEach((type) => {
2006
- const discriminatorValue = type.shape[discriminator].value;
2007
- options.set(discriminatorValue, type);
2008
- });
2009
- }
2010
- catch (e) {
2011
- throw new Error("The discriminator value could not be extracted from all the provided schemas");
2012
- }
2013
- // Assert that all the discriminator values are unique
2014
- if (options.size !== types.length) {
2015
- throw new Error("Some of the discriminator values are not unique");
2403
+ const optionsMap = new Map();
2404
+ // try {
2405
+ for (const type of options) {
2406
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2407
+ if (!discriminatorValues) {
2408
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2409
+ }
2410
+ for (const value of discriminatorValues) {
2411
+ if (optionsMap.has(value)) {
2412
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2413
+ }
2414
+ optionsMap.set(value, type);
2415
+ }
2016
2416
  }
2017
2417
  return new ZodDiscriminatedUnion({
2018
2418
  typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2019
2419
  discriminator,
2020
2420
  options,
2421
+ optionsMap,
2021
2422
  ...processCreateParams(params),
2022
2423
  });
2023
2424
  }
@@ -2138,6 +2539,7 @@ class ZodTuple extends ZodType {
2138
2539
  code: ZodIssueCode.too_small,
2139
2540
  minimum: this._def.items.length,
2140
2541
  inclusive: true,
2542
+ exact: false,
2141
2543
  type: "array",
2142
2544
  });
2143
2545
  return INVALID;
@@ -2148,11 +2550,12 @@ class ZodTuple extends ZodType {
2148
2550
  code: ZodIssueCode.too_big,
2149
2551
  maximum: this._def.items.length,
2150
2552
  inclusive: true,
2553
+ exact: false,
2151
2554
  type: "array",
2152
2555
  });
2153
2556
  status.dirty();
2154
2557
  }
2155
- const items = ctx.data
2558
+ const items = [...ctx.data]
2156
2559
  .map((item, itemIndex) => {
2157
2560
  const schema = this._def.items[itemIndex] || this._def.rest;
2158
2561
  if (!schema)
@@ -2323,6 +2726,7 @@ class ZodSet extends ZodType {
2323
2726
  minimum: def.minSize.value,
2324
2727
  type: "set",
2325
2728
  inclusive: true,
2729
+ exact: false,
2326
2730
  message: def.minSize.message,
2327
2731
  });
2328
2732
  status.dirty();
@@ -2335,6 +2739,7 @@ class ZodSet extends ZodType {
2335
2739
  maximum: def.maxSize.value,
2336
2740
  type: "set",
2337
2741
  inclusive: true,
2742
+ exact: false,
2338
2743
  message: def.maxSize.message,
2339
2744
  });
2340
2745
  status.dirty();
@@ -2530,6 +2935,7 @@ class ZodLiteral extends ZodType {
2530
2935
  if (input.data !== this._def.value) {
2531
2936
  const ctx = this._getOrReturnCtx(input);
2532
2937
  addIssueToContext(ctx, {
2938
+ received: ctx.data,
2533
2939
  code: ZodIssueCode.invalid_literal,
2534
2940
  expected: this._def.value,
2535
2941
  });
@@ -2603,6 +3009,12 @@ class ZodEnum extends ZodType {
2603
3009
  }
2604
3010
  return enumValues;
2605
3011
  }
3012
+ extract(values) {
3013
+ return ZodEnum.create(values);
3014
+ }
3015
+ exclude(values) {
3016
+ return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
3017
+ }
2606
3018
  }
2607
3019
  ZodEnum.create = createZodEnum;
2608
3020
  class ZodNativeEnum extends ZodType {
@@ -2642,6 +3054,9 @@ ZodNativeEnum.create = (values, params) => {
2642
3054
  });
2643
3055
  };
2644
3056
  class ZodPromise extends ZodType {
3057
+ unwrap() {
3058
+ return this._def.type;
3059
+ }
2645
3060
  _parse(input) {
2646
3061
  const { ctx } = this._processInputParams(input);
2647
3062
  if (ctx.parsedType !== ZodParsedType.promise &&
@@ -2675,6 +3090,11 @@ class ZodEffects extends ZodType {
2675
3090
  innerType() {
2676
3091
  return this._def.schema;
2677
3092
  }
3093
+ sourceType() {
3094
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects
3095
+ ? this._def.schema.sourceType()
3096
+ : this._def.schema;
3097
+ }
2678
3098
  _parse(input) {
2679
3099
  const { status, ctx } = this._processInputParams(input);
2680
3100
  const effect = this._def.effect || null;
@@ -2861,9 +3281,53 @@ class ZodDefault extends ZodType {
2861
3281
  }
2862
3282
  }
2863
3283
  ZodDefault.create = (type, params) => {
2864
- return new ZodOptional({
3284
+ return new ZodDefault({
2865
3285
  innerType: type,
2866
- typeName: ZodFirstPartyTypeKind.ZodOptional,
3286
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3287
+ defaultValue: typeof params.default === "function"
3288
+ ? params.default
3289
+ : () => params.default,
3290
+ ...processCreateParams(params),
3291
+ });
3292
+ };
3293
+ class ZodCatch extends ZodType {
3294
+ _parse(input) {
3295
+ const { ctx } = this._processInputParams(input);
3296
+ const result = this._def.innerType._parse({
3297
+ data: ctx.data,
3298
+ path: ctx.path,
3299
+ parent: {
3300
+ ...ctx,
3301
+ common: {
3302
+ ...ctx.common,
3303
+ issues: [], // don't collect issues from inner type
3304
+ },
3305
+ },
3306
+ });
3307
+ if (isAsync(result)) {
3308
+ return result.then((result) => {
3309
+ return {
3310
+ status: "valid",
3311
+ value: result.status === "valid" ? result.value : this._def.catchValue(),
3312
+ };
3313
+ });
3314
+ }
3315
+ else {
3316
+ return {
3317
+ status: "valid",
3318
+ value: result.status === "valid" ? result.value : this._def.catchValue(),
3319
+ };
3320
+ }
3321
+ }
3322
+ removeCatch() {
3323
+ return this._def.innerType;
3324
+ }
3325
+ }
3326
+ ZodCatch.create = (type, params) => {
3327
+ return new ZodCatch({
3328
+ innerType: type,
3329
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3330
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
2867
3331
  ...processCreateParams(params),
2868
3332
  });
2869
3333
  };
@@ -2903,6 +3367,64 @@ class ZodBranded extends ZodType {
2903
3367
  return this._def.type;
2904
3368
  }
2905
3369
  }
3370
+ class ZodPipeline extends ZodType {
3371
+ _parse(input) {
3372
+ const { status, ctx } = this._processInputParams(input);
3373
+ if (ctx.common.async) {
3374
+ const handleAsync = async () => {
3375
+ const inResult = await this._def.in._parseAsync({
3376
+ data: ctx.data,
3377
+ path: ctx.path,
3378
+ parent: ctx,
3379
+ });
3380
+ if (inResult.status === "aborted")
3381
+ return INVALID;
3382
+ if (inResult.status === "dirty") {
3383
+ status.dirty();
3384
+ return DIRTY(inResult.value);
3385
+ }
3386
+ else {
3387
+ return this._def.out._parseAsync({
3388
+ data: inResult.value,
3389
+ path: ctx.path,
3390
+ parent: ctx,
3391
+ });
3392
+ }
3393
+ };
3394
+ return handleAsync();
3395
+ }
3396
+ else {
3397
+ const inResult = this._def.in._parseSync({
3398
+ data: ctx.data,
3399
+ path: ctx.path,
3400
+ parent: ctx,
3401
+ });
3402
+ if (inResult.status === "aborted")
3403
+ return INVALID;
3404
+ if (inResult.status === "dirty") {
3405
+ status.dirty();
3406
+ return {
3407
+ status: "dirty",
3408
+ value: inResult.value,
3409
+ };
3410
+ }
3411
+ else {
3412
+ return this._def.out._parseSync({
3413
+ data: inResult.value,
3414
+ path: ctx.path,
3415
+ parent: ctx,
3416
+ });
3417
+ }
3418
+ }
3419
+ }
3420
+ static create(a, b) {
3421
+ return new ZodPipeline({
3422
+ in: a,
3423
+ out: b,
3424
+ typeName: ZodFirstPartyTypeKind.ZodPipeline,
3425
+ });
3426
+ }
3427
+ }
2906
3428
  const custom = (check, params = {}, fatal) => {
2907
3429
  if (check)
2908
3430
  return ZodAny.create().superRefine((data, ctx) => {
@@ -2925,6 +3447,7 @@ var ZodFirstPartyTypeKind;
2925
3447
  ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
2926
3448
  ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
2927
3449
  ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
3450
+ ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
2928
3451
  ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
2929
3452
  ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
2930
3453
  ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
@@ -2949,16 +3472,14 @@ var ZodFirstPartyTypeKind;
2949
3472
  ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
2950
3473
  ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
2951
3474
  ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
3475
+ ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
2952
3476
  ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
2953
3477
  ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
3478
+ ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
2954
3479
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
2955
- // new approach that works for abstract classes
2956
- // but required TS 4.4+
2957
- // abstract class Class {
2958
- // constructor(..._: any[]) {}
2959
- // }
2960
- // const instanceOfType = <T extends typeof Class>(
2961
- const instanceOfType = (cls, params = {
3480
+ const instanceOfType = (
3481
+ // const instanceOfType = <T extends new (...args: any[]) => any>(
3482
+ cls, params = {
2962
3483
  message: `Input not instance of ${cls.name}`,
2963
3484
  }) => custom((data) => data instanceof cls, params, true);
2964
3485
  const stringType = ZodString.create;
@@ -2967,6 +3488,7 @@ const nanType = ZodNaN.create;
2967
3488
  const bigIntType = ZodBigInt.create;
2968
3489
  const booleanType = ZodBoolean.create;
2969
3490
  const dateType = ZodDate.create;
3491
+ const symbolType = ZodSymbol.create;
2970
3492
  const undefinedType = ZodUndefined.create;
2971
3493
  const nullType = ZodNull.create;
2972
3494
  const anyType = ZodAny.create;
@@ -2993,15 +3515,24 @@ const effectsType = ZodEffects.create;
2993
3515
  const optionalType = ZodOptional.create;
2994
3516
  const nullableType = ZodNullable.create;
2995
3517
  const preprocessType = ZodEffects.createWithPreprocess;
3518
+ const pipelineType = ZodPipeline.create;
2996
3519
  const ostring = () => stringType().optional();
2997
3520
  const onumber = () => numberType().optional();
2998
3521
  const oboolean = () => booleanType().optional();
3522
+ const coerce = {
3523
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
3524
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
3525
+ boolean: ((arg) => ZodBoolean.create({
3526
+ ...arg,
3527
+ coerce: true,
3528
+ })),
3529
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
3530
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true })),
3531
+ };
2999
3532
  const NEVER = INVALID;
3000
3533
 
3001
3534
  var mod = /*#__PURE__*/Object.freeze({
3002
3535
  __proto__: null,
3003
- getParsedType: getParsedType,
3004
- ZodParsedType: ZodParsedType,
3005
3536
  defaultErrorMap: errorMap,
3006
3537
  setErrorMap: setErrorMap,
3007
3538
  getErrorMap: getErrorMap,
@@ -3016,12 +3547,16 @@ var mod = /*#__PURE__*/Object.freeze({
3016
3547
  isDirty: isDirty,
3017
3548
  isValid: isValid,
3018
3549
  isAsync: isAsync,
3550
+ get util () { return util; },
3551
+ ZodParsedType: ZodParsedType,
3552
+ getParsedType: getParsedType,
3019
3553
  ZodType: ZodType,
3020
3554
  ZodString: ZodString,
3021
3555
  ZodNumber: ZodNumber,
3022
3556
  ZodBigInt: ZodBigInt,
3023
3557
  ZodBoolean: ZodBoolean,
3024
3558
  ZodDate: ZodDate,
3559
+ ZodSymbol: ZodSymbol,
3025
3560
  ZodUndefined: ZodUndefined,
3026
3561
  ZodNull: ZodNull,
3027
3562
  ZodAny: ZodAny,
@@ -3049,14 +3584,17 @@ var mod = /*#__PURE__*/Object.freeze({
3049
3584
  ZodOptional: ZodOptional,
3050
3585
  ZodNullable: ZodNullable,
3051
3586
  ZodDefault: ZodDefault,
3587
+ ZodCatch: ZodCatch,
3052
3588
  ZodNaN: ZodNaN,
3053
3589
  BRAND: BRAND,
3054
3590
  ZodBranded: ZodBranded,
3591
+ ZodPipeline: ZodPipeline,
3055
3592
  custom: custom,
3056
3593
  Schema: ZodType,
3057
3594
  ZodSchema: ZodType,
3058
3595
  late: late,
3059
3596
  get ZodFirstPartyTypeKind () { return ZodFirstPartyTypeKind; },
3597
+ coerce: coerce,
3060
3598
  any: anyType,
3061
3599
  array: arrayType,
3062
3600
  bigint: bigIntType,
@@ -3082,12 +3620,14 @@ var mod = /*#__PURE__*/Object.freeze({
3082
3620
  onumber: onumber,
3083
3621
  optional: optionalType,
3084
3622
  ostring: ostring,
3623
+ pipeline: pipelineType,
3085
3624
  preprocess: preprocessType,
3086
3625
  promise: promiseType,
3087
3626
  record: recordType,
3088
3627
  set: setType,
3089
3628
  strictObject: strictObjectType,
3090
3629
  string: stringType,
3630
+ symbol: symbolType,
3091
3631
  transformer: effectsType,
3092
3632
  tuple: tupleType,
3093
3633
  'undefined': undefinedType,
@@ -3422,13 +3962,61 @@ mod.object({
3422
3962
  credentialSubject: CredentialSubjectValidator.optional()
3423
3963
  });
3424
3964
  mod.object({ id: mod.string(), uri: mod.string() }).catchall(mod.any());
3965
+ var LCNProfileValidator = mod.object({
3966
+ profileId: mod.string().min(3).max(40),
3967
+ displayName: mod.string().default(""),
3968
+ did: mod.string(),
3969
+ email: mod.string().optional(),
3970
+ image: mod.string().optional(),
3971
+ isServiceProfile: mod.boolean().default(false).optional()
3972
+ });
3425
3973
  mod.object({
3974
+ uri: mod.string(),
3975
+ to: mod.string(),
3976
+ from: mod.string(),
3977
+ sent: mod.string().datetime(),
3978
+ received: mod.string().datetime().optional()
3979
+ });
3980
+ mod.object({
3981
+ uri: mod.string(),
3982
+ name: mod.string().optional(),
3983
+ type: mod.string().optional(),
3984
+ category: mod.string().optional()
3985
+ });
3986
+ mod.object({
3987
+ to: LCNProfileValidator,
3988
+ from: mod.string(),
3989
+ received: mod.string()
3990
+ });
3991
+ var JWKValidator = mod.object({
3426
3992
  kty: mod.string(),
3427
3993
  crv: mod.string(),
3428
3994
  x: mod.string(),
3429
3995
  y: mod.string().optional(),
3996
+ n: mod.string().optional(),
3430
3997
  d: mod.string()
3431
3998
  });
3999
+ var JWERecipientHeaderValidator = mod.object({
4000
+ alg: mod.string(),
4001
+ iv: mod.string(),
4002
+ tag: mod.string(),
4003
+ epk: JWKValidator.partial().optional(),
4004
+ kid: mod.string().optional(),
4005
+ apv: mod.string().optional(),
4006
+ apu: mod.string().optional()
4007
+ });
4008
+ var JWERecipientValidator = mod.object({
4009
+ header: JWERecipientHeaderValidator,
4010
+ encrypted_key: mod.string()
4011
+ });
4012
+ mod.object({
4013
+ protected: mod.string(),
4014
+ iv: mod.string(),
4015
+ ciphertext: mod.string(),
4016
+ tag: mod.string(),
4017
+ aad: mod.string().optional(),
4018
+ recipients: JWERecipientValidator.array().optional()
4019
+ });
3432
4020
 
3433
4021
  export { VerificationStatusEnum as V };
3434
- //# sourceMappingURL=types.esm-9db3d858.js.map
4022
+ //# sourceMappingURL=types.esm-877355bb.js.map