@learncard/react 2.3.69 → 2.5.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.
Files changed (240) hide show
  1. package/dist/cjs/{AchievementCard-0123be96.js → AchievementCard-69413826.js} +5 -5
  2. package/dist/cjs/{AchievementCard-0123be96.js.map → AchievementCard-69413826.js.map} +1 -1
  3. package/dist/cjs/AwardRibbon-14ba45fb.js +33 -0
  4. package/dist/cjs/AwardRibbon-14ba45fb.js.map +1 -0
  5. package/dist/cjs/{CircleCheckButton-97c4f608.js → CircleCheckButton-78959cce.js} +2 -2
  6. package/dist/cjs/{CircleCheckButton-97c4f608.js.map → CircleCheckButton-78959cce.js.map} +1 -1
  7. package/dist/cjs/CircleIcon-03cc33dc.js +1083 -0
  8. package/dist/cjs/CircleIcon-03cc33dc.js.map +1 -0
  9. package/dist/cjs/{CourseVerticalCard-ef3e7ea6.js → CourseVerticalCard-5ac6adea.js} +4 -4
  10. package/dist/cjs/{CourseVerticalCard-ef3e7ea6.js.map → CourseVerticalCard-5ac6adea.js.map} +1 -1
  11. package/dist/cjs/{FlippyCard-2cbe2dbe.js → FlippyCard-209549c5.js} +2 -2
  12. package/dist/cjs/FlippyCard-209549c5.js.map +1 -0
  13. package/dist/cjs/{GenericCard-39248302.js → GenericCard-346b55ab.js} +4 -4
  14. package/dist/cjs/{GenericCard-39248302.js.map → GenericCard-346b55ab.js.map} +1 -1
  15. package/dist/cjs/{JobListCard-f9033e07.js → JobListCard-672fadc3.js} +3 -3
  16. package/dist/cjs/{JobListCard-f9033e07.js.map → JobListCard-672fadc3.js.map} +1 -1
  17. package/dist/cjs/{LearnCardCreditCardFrontFace-4452fd7a.js → LearnCardCreditCardFrontFace-4ce0d049.js} +2 -2
  18. package/dist/cjs/{LearnCardCreditCardFrontFace-4452fd7a.js.map → LearnCardCreditCardFrontFace-4ce0d049.js.map} +1 -1
  19. package/dist/cjs/{LearnPill-23ff7225.js → LearnPill-75e3af2f.js} +3 -3
  20. package/dist/cjs/{LearnPill-23ff7225.js.map → LearnPill-75e3af2f.js.map} +1 -1
  21. package/dist/cjs/{Notification-10b40c07.js → Notification-88cc727a.js} +24 -8
  22. package/dist/cjs/Notification-88cc727a.js.map +1 -0
  23. package/dist/cjs/{QRCodeCard-efaa58e1.js → QRCodeCard-b60c0500.js} +2 -2
  24. package/dist/cjs/{QRCodeCard-efaa58e1.js.map → QRCodeCard-b60c0500.js.map} +1 -1
  25. package/dist/cjs/{RoundedPill-15c0aca9.js → RoundedPill-75454f72.js} +2 -2
  26. package/dist/cjs/{RoundedPill-15c0aca9.js.map → RoundedPill-75454f72.js.map} +1 -1
  27. package/dist/cjs/SchoolIDCard-1baf77e8.js.map +1 -1
  28. package/dist/cjs/{SkillTabCard-2f6e8b78.js → SkillTabCard-eb50fde5.js} +4 -4
  29. package/dist/cjs/{SkillTabCard-2f6e8b78.js.map → SkillTabCard-eb50fde5.js.map} +1 -1
  30. package/dist/cjs/{VCCard-47af6178.js → VCCard-9c328aba.js} +33 -7
  31. package/dist/cjs/VCCard-9c328aba.js.map +1 -0
  32. package/dist/cjs/{VCDisplayBackFace-b1e35a5e.js → VCDisplayBackFace-f10d3acc.js} +5 -25
  33. package/dist/cjs/VCDisplayBackFace-f10d3acc.js.map +1 -0
  34. package/dist/cjs/VCDisplayCard-641cc1de.js +191 -0
  35. package/dist/cjs/VCDisplayCard-641cc1de.js.map +1 -0
  36. package/dist/cjs/VCDisplayCard2-ddc332ce.js +920 -0
  37. package/dist/cjs/VCDisplayCard2-ddc332ce.js.map +1 -0
  38. package/dist/cjs/{VCVerificationCheck-0e495524.js → VCVerificationCheck-08011d1a.js} +32 -22
  39. package/dist/cjs/VCVerificationCheck-08011d1a.js.map +1 -0
  40. package/dist/cjs/VCVerificationPill-f322ffef.js +75 -0
  41. package/dist/cjs/VCVerificationPill-f322ffef.js.map +1 -0
  42. package/dist/cjs/award.svg +3 -0
  43. package/dist/cjs/{constants-678d0aa9.js → constants-82581ffe.js} +10 -12
  44. package/dist/cjs/constants-82581ffe.js.map +1 -0
  45. package/dist/cjs/credential.helpers-da5d874e.js +2188 -0
  46. package/dist/cjs/credential.helpers-da5d874e.js.map +1 -0
  47. package/dist/cjs/{icons-cf98ef88.js → icons-6433b474.js} +6 -3
  48. package/dist/cjs/icons-6433b474.js.map +1 -0
  49. package/dist/cjs/{index-63ee021e.js → index-6b34c190.js} +3 -1
  50. package/dist/cjs/index-6b34c190.js.map +1 -0
  51. package/dist/{esm/VCDisplayCard-1bd179d2.js → cjs/index-a961acab.js} +12 -2328
  52. package/dist/cjs/index-a961acab.js.map +1 -0
  53. package/dist/cjs/{index-82de573c.js → index-c340a7f0.js} +1 -1
  54. package/dist/{esm/index-aa1098e1.js.map → cjs/index-c340a7f0.js.map} +1 -1
  55. package/dist/cjs/{index-6cab6d37.js → index-f30fca07.js} +12 -6
  56. package/dist/cjs/index-f30fca07.js.map +1 -0
  57. package/dist/cjs/index.js +33 -23
  58. package/dist/cjs/index.js.map +1 -1
  59. package/dist/cjs/index10.js +33 -23
  60. package/dist/cjs/index10.js.map +1 -1
  61. package/dist/cjs/index12.js +4 -3
  62. package/dist/cjs/index12.js.map +1 -1
  63. package/dist/cjs/index14.js +2 -2
  64. package/dist/cjs/index15.js +4 -3
  65. package/dist/cjs/index15.js.map +1 -1
  66. package/dist/cjs/index18.js +1 -1
  67. package/dist/cjs/index19.js +2 -2
  68. package/dist/cjs/index2.js +8 -6
  69. package/dist/cjs/index2.js.map +1 -1
  70. package/dist/cjs/index20.js +4 -3
  71. package/dist/cjs/index20.js.map +1 -1
  72. package/dist/cjs/index21.js +7 -5
  73. package/dist/cjs/index21.js.map +1 -1
  74. package/dist/cjs/index25.js +6 -5
  75. package/dist/cjs/index25.js.map +1 -1
  76. package/dist/cjs/index28.js +3 -1
  77. package/dist/cjs/index28.js.map +1 -1
  78. package/dist/cjs/index29.js +11 -6
  79. package/dist/cjs/index29.js.map +1 -1
  80. package/dist/cjs/index30.js +6 -3
  81. package/dist/cjs/index30.js.map +1 -1
  82. package/dist/cjs/index31.js +8 -5
  83. package/dist/cjs/index31.js.map +1 -1
  84. package/dist/cjs/index32.js +12 -1
  85. package/dist/cjs/index32.js.map +1 -1
  86. package/dist/cjs/index33.js +4 -7
  87. package/dist/cjs/index33.js.map +1 -1
  88. package/dist/cjs/index34.js +4 -5
  89. package/dist/cjs/index34.js.map +1 -1
  90. package/dist/cjs/index35.js +6 -5
  91. package/dist/cjs/index35.js.map +1 -1
  92. package/dist/cjs/index36.js +15 -0
  93. package/dist/cjs/index36.js.map +1 -0
  94. package/dist/cjs/index4.js +5 -4
  95. package/dist/cjs/index4.js.map +1 -1
  96. package/dist/cjs/index5.js +4 -3
  97. package/dist/cjs/index5.js.map +1 -1
  98. package/dist/cjs/index7.js +6 -5
  99. package/dist/cjs/index7.js.map +1 -1
  100. package/dist/cjs/index8.js +1 -1
  101. package/dist/cjs/index9.js +8 -6
  102. package/dist/cjs/index9.js.map +1 -1
  103. package/dist/cjs/social-badge.png +0 -0
  104. package/dist/cjs/{VCVerificationPill-9e8e4264.js → types.esm-c09dbd3b.js} +495 -123
  105. package/dist/cjs/types.esm-c09dbd3b.js.map +1 -0
  106. package/dist/esm/{AchievementCard-92b5a3ea.js → AchievementCard-3f315f82.js} +5 -5
  107. package/dist/esm/{AchievementCard-92b5a3ea.js.map → AchievementCard-3f315f82.js.map} +1 -1
  108. package/dist/esm/AwardRibbon-3e682281.js +27 -0
  109. package/dist/esm/AwardRibbon-3e682281.js.map +1 -0
  110. package/dist/esm/{CircleCheckButton-a55dfd2a.js → CircleCheckButton-3bad7847.js} +2 -2
  111. package/dist/esm/{CircleCheckButton-a55dfd2a.js.map → CircleCheckButton-3bad7847.js.map} +1 -1
  112. package/dist/esm/CircleIcon-3ab835f3.js +1076 -0
  113. package/dist/esm/CircleIcon-3ab835f3.js.map +1 -0
  114. package/dist/esm/{CourseVerticalCard-c91c7a7a.js → CourseVerticalCard-cfb09a77.js} +4 -4
  115. package/dist/esm/{CourseVerticalCard-c91c7a7a.js.map → CourseVerticalCard-cfb09a77.js.map} +1 -1
  116. package/dist/esm/{FlippyCard-f4f0b3f8.js → FlippyCard-a2de5cf1.js} +2 -2
  117. package/dist/esm/FlippyCard-a2de5cf1.js.map +1 -0
  118. package/dist/esm/{GenericCard-2aaadb4b.js → GenericCard-446f46e0.js} +4 -4
  119. package/dist/esm/{GenericCard-2aaadb4b.js.map → GenericCard-446f46e0.js.map} +1 -1
  120. package/dist/esm/{JobListCard-3a2bd655.js → JobListCard-9ac7ac1b.js} +3 -3
  121. package/dist/esm/{JobListCard-3a2bd655.js.map → JobListCard-9ac7ac1b.js.map} +1 -1
  122. package/dist/esm/{LearnCardCreditCardFrontFace-cf793917.js → LearnCardCreditCardFrontFace-c221facc.js} +2 -2
  123. package/dist/esm/{LearnCardCreditCardFrontFace-cf793917.js.map → LearnCardCreditCardFrontFace-c221facc.js.map} +1 -1
  124. package/dist/esm/{LearnPill-a1001ae7.js → LearnPill-a62adef1.js} +3 -3
  125. package/dist/esm/{LearnPill-a1001ae7.js.map → LearnPill-a62adef1.js.map} +1 -1
  126. package/dist/esm/{Notification-ac50790d.js → Notification-75f2b46f.js} +25 -9
  127. package/dist/esm/Notification-75f2b46f.js.map +1 -0
  128. package/dist/esm/{QRCodeCard-c57e2067.js → QRCodeCard-d147d009.js} +2 -2
  129. package/dist/esm/{QRCodeCard-c57e2067.js.map → QRCodeCard-d147d009.js.map} +1 -1
  130. package/dist/esm/{RoundedPill-2f4dc646.js → RoundedPill-c03442e5.js} +2 -2
  131. package/dist/esm/{RoundedPill-2f4dc646.js.map → RoundedPill-c03442e5.js.map} +1 -1
  132. package/dist/esm/SchoolIDCard-3b746226.js.map +1 -1
  133. package/dist/esm/{SkillTabCard-82b97c62.js → SkillTabCard-2677de0d.js} +4 -4
  134. package/dist/esm/{SkillTabCard-82b97c62.js.map → SkillTabCard-2677de0d.js.map} +1 -1
  135. package/dist/esm/{VCCard-f53514a4.js → VCCard-ac061e87.js} +33 -7
  136. package/dist/esm/VCCard-ac061e87.js.map +1 -0
  137. package/dist/esm/{VCDisplayBackFace-919ed9e8.js → VCDisplayBackFace-dbf68095.js} +5 -23
  138. package/dist/esm/VCDisplayBackFace-dbf68095.js.map +1 -0
  139. package/dist/esm/VCDisplayCard-ec21dfe8.js +183 -0
  140. package/dist/esm/VCDisplayCard-ec21dfe8.js.map +1 -0
  141. package/dist/esm/VCDisplayCard2-50e1a81a.js +913 -0
  142. package/dist/esm/VCDisplayCard2-50e1a81a.js.map +1 -0
  143. package/dist/esm/{VCVerificationCheck-b2de0477.js → VCVerificationCheck-a6909b44.js} +32 -23
  144. package/dist/esm/VCVerificationCheck-a6909b44.js.map +1 -0
  145. package/dist/esm/VCVerificationPill-9559507a.js +65 -0
  146. package/dist/esm/VCVerificationPill-9559507a.js.map +1 -0
  147. package/dist/esm/award.svg +3 -0
  148. package/dist/esm/{constants-e0d87a29.js → constants-c0a08298.js} +10 -12
  149. package/dist/esm/constants-c0a08298.js.map +1 -0
  150. package/dist/esm/credential.helpers-fbf88b8c.js +2182 -0
  151. package/dist/esm/credential.helpers-fbf88b8c.js.map +1 -0
  152. package/dist/esm/{icons-10f38bbd.js → icons-2c3532f9.js} +5 -3
  153. package/dist/esm/icons-2c3532f9.js.map +1 -0
  154. package/dist/esm/{index-15b828c0.js → index-52cf2d17.js} +3 -1
  155. package/dist/esm/index-52cf2d17.js.map +1 -0
  156. package/dist/esm/{index-aa1098e1.js → index-54ccc558.js} +1 -1
  157. package/dist/esm/index-54ccc558.js.map +1 -0
  158. package/dist/esm/{index-2ef79548.js → index-ac32d7be.js} +11 -6
  159. package/dist/esm/index-ac32d7be.js.map +1 -0
  160. package/dist/{cjs/VCDisplayCard-2981600a.js → esm/index-e1f279c6.js} +4 -2337
  161. package/dist/esm/index-e1f279c6.js.map +1 -0
  162. package/dist/esm/index.js +30 -23
  163. package/dist/esm/index.js.map +1 -1
  164. package/dist/esm/index10.js +30 -23
  165. package/dist/esm/index10.js.map +1 -1
  166. package/dist/esm/index12.js +4 -3
  167. package/dist/esm/index12.js.map +1 -1
  168. package/dist/esm/index14.js +2 -2
  169. package/dist/esm/index15.js +4 -3
  170. package/dist/esm/index15.js.map +1 -1
  171. package/dist/esm/index18.js +1 -1
  172. package/dist/esm/index19.js +2 -2
  173. package/dist/esm/index2.js +8 -6
  174. package/dist/esm/index2.js.map +1 -1
  175. package/dist/esm/index20.js +4 -3
  176. package/dist/esm/index20.js.map +1 -1
  177. package/dist/esm/index21.js +7 -5
  178. package/dist/esm/index21.js.map +1 -1
  179. package/dist/esm/index25.js +6 -5
  180. package/dist/esm/index25.js.map +1 -1
  181. package/dist/esm/index28.js +2 -1
  182. package/dist/esm/index28.js.map +1 -1
  183. package/dist/esm/index29.js +11 -6
  184. package/dist/esm/index29.js.map +1 -1
  185. package/dist/esm/index30.js +6 -3
  186. package/dist/esm/index30.js.map +1 -1
  187. package/dist/esm/index31.js +8 -5
  188. package/dist/esm/index31.js.map +1 -1
  189. package/dist/esm/index32.js +7 -1
  190. package/dist/esm/index32.js.map +1 -1
  191. package/dist/esm/index33.js +4 -2
  192. package/dist/esm/index33.js.map +1 -1
  193. package/dist/esm/index34.js +3 -3
  194. package/dist/esm/index35.js +3 -4
  195. package/dist/esm/index35.js.map +1 -1
  196. package/dist/esm/index36.js +7 -0
  197. package/dist/esm/index36.js.map +1 -0
  198. package/dist/esm/index4.js +5 -4
  199. package/dist/esm/index4.js.map +1 -1
  200. package/dist/esm/index5.js +4 -3
  201. package/dist/esm/index5.js.map +1 -1
  202. package/dist/esm/index7.js +6 -5
  203. package/dist/esm/index7.js.map +1 -1
  204. package/dist/esm/index8.js +1 -1
  205. package/dist/esm/index9.js +8 -6
  206. package/dist/esm/index9.js.map +1 -1
  207. package/dist/esm/social-badge.png +0 -0
  208. package/dist/esm/{VCVerificationPill-7a09f9fa.js → types.esm-9b3b15f7.js} +495 -115
  209. package/dist/esm/types.esm-9b3b15f7.js.map +1 -0
  210. package/dist/index.d.ts +72 -7
  211. package/dist/main.css +1 -1
  212. package/dist/main.js +1 -1
  213. package/package.json +9 -6
  214. package/dist/cjs/CircleIcon-41b3fa88.js +0 -67
  215. package/dist/cjs/CircleIcon-41b3fa88.js.map +0 -1
  216. package/dist/cjs/FlippyCard-2cbe2dbe.js.map +0 -1
  217. package/dist/cjs/Notification-10b40c07.js.map +0 -1
  218. package/dist/cjs/VCCard-47af6178.js.map +0 -1
  219. package/dist/cjs/VCDisplayBackFace-b1e35a5e.js.map +0 -1
  220. package/dist/cjs/VCDisplayCard-2981600a.js.map +0 -1
  221. package/dist/cjs/VCVerificationCheck-0e495524.js.map +0 -1
  222. package/dist/cjs/VCVerificationPill-9e8e4264.js.map +0 -1
  223. package/dist/cjs/constants-678d0aa9.js.map +0 -1
  224. package/dist/cjs/icons-cf98ef88.js.map +0 -1
  225. package/dist/cjs/index-63ee021e.js.map +0 -1
  226. package/dist/cjs/index-6cab6d37.js.map +0 -1
  227. package/dist/cjs/index-82de573c.js.map +0 -1
  228. package/dist/esm/CircleIcon-b0dca4b6.js +0 -60
  229. package/dist/esm/CircleIcon-b0dca4b6.js.map +0 -1
  230. package/dist/esm/FlippyCard-f4f0b3f8.js.map +0 -1
  231. package/dist/esm/Notification-ac50790d.js.map +0 -1
  232. package/dist/esm/VCCard-f53514a4.js.map +0 -1
  233. package/dist/esm/VCDisplayBackFace-919ed9e8.js.map +0 -1
  234. package/dist/esm/VCDisplayCard-1bd179d2.js.map +0 -1
  235. package/dist/esm/VCVerificationCheck-b2de0477.js.map +0 -1
  236. package/dist/esm/VCVerificationPill-7a09f9fa.js.map +0 -1
  237. package/dist/esm/constants-e0d87a29.js.map +0 -1
  238. package/dist/esm/icons-10f38bbd.js.map +0 -1
  239. package/dist/esm/index-15b828c0.js.map +0 -1
  240. package/dist/esm/index-2ef79548.js.map +0 -1
@@ -1,8 +1,3 @@
1
- import React from 'react';
2
- import VerificationFailedIcon from './RedXCircle.svg';
3
- import VerificationPassedIcon from './GreenCheckCircle.svg';
4
- import VerificationWarningIcon from './YellowWarningCircle.svg';
5
-
6
1
  var util;
7
2
  (function (util) {
8
3
  util.assertEqual = (val) => val;
@@ -103,6 +98,8 @@ const getParsedType = (data) => {
103
98
  return ZodParsedType.function;
104
99
  case "bigint":
105
100
  return ZodParsedType.bigint;
101
+ case "symbol":
102
+ return ZodParsedType.symbol;
106
103
  case "object":
107
104
  if (Array.isArray(data)) {
108
105
  return ZodParsedType.array;
@@ -147,6 +144,7 @@ const ZodIssueCode = util.arrayToEnum([
147
144
  "too_big",
148
145
  "invalid_intersection_types",
149
146
  "not_multiple_of",
147
+ "not_finite",
150
148
  ]);
151
149
  const quotelessJson = (obj) => {
152
150
  const json = JSON.stringify(obj, null, 2);
@@ -313,25 +311,41 @@ const errorMap = (issue, _ctx) => {
313
311
  break;
314
312
  case ZodIssueCode.too_small:
315
313
  if (issue.type === "array")
316
- 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)`;
317
315
  else if (issue.type === "string")
318
- 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)`;
319
317
  else if (issue.type === "number")
320
- 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}`;
321
323
  else if (issue.type === "date")
322
- 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)}`;
323
329
  else
324
330
  message = "Invalid input";
325
331
  break;
326
332
  case ZodIssueCode.too_big:
327
333
  if (issue.type === "array")
328
- 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)`;
329
335
  else if (issue.type === "string")
330
- 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)`;
331
337
  else if (issue.type === "number")
332
- 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}`;
333
343
  else if (issue.type === "date")
334
- 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)}`;
335
349
  else
336
350
  message = "Invalid input";
337
351
  break;
@@ -344,6 +358,9 @@ const errorMap = (issue, _ctx) => {
344
358
  case ZodIssueCode.not_multiple_of:
345
359
  message = `Number must be a multiple of ${issue.multipleOf}`;
346
360
  break;
361
+ case ZodIssueCode.not_finite:
362
+ message = "Number must be finite";
363
+ break;
347
364
  default:
348
365
  message = _ctx.defaultError;
349
366
  util.assertNever(issue);
@@ -390,7 +407,7 @@ function addIssueToContext(ctx, issueData) {
390
407
  ctx.common.contextualErrorMap,
391
408
  ctx.schemaErrorMap,
392
409
  getErrorMap(),
393
- errorMap,
410
+ errorMap, // then global default map
394
411
  ].filter((x) => !!x),
395
412
  });
396
413
  ctx.common.issues.push(issue);
@@ -509,7 +526,6 @@ class ZodType {
509
526
  constructor(def) {
510
527
  /** Alias of safeParseAsync */
511
528
  this.spa = this.safeParseAsync;
512
- this.superRefine = this._refinement;
513
529
  this._def = def;
514
530
  this.parse = this.parse.bind(this);
515
531
  this.safeParse = this.safeParse.bind(this);
@@ -527,8 +543,11 @@ class ZodType {
527
543
  this.or = this.or.bind(this);
528
544
  this.and = this.and.bind(this);
529
545
  this.transform = this.transform.bind(this);
546
+ this.brand = this.brand.bind(this);
530
547
  this.default = this.default.bind(this);
548
+ this.catch = this.catch.bind(this);
531
549
  this.describe = this.describe.bind(this);
550
+ this.pipe = this.pipe.bind(this);
532
551
  this.isNullable = this.isNullable.bind(this);
533
552
  this.isOptional = this.isOptional.bind(this);
534
553
  }
@@ -614,7 +633,7 @@ class ZodType {
614
633
  data,
615
634
  parsedType: getParsedType(data),
616
635
  };
617
- const maybeAsyncResult = this._parse({ data, path: [], parent: ctx });
636
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
618
637
  const result = await (isAsync(maybeAsyncResult)
619
638
  ? maybeAsyncResult
620
639
  : Promise.resolve(maybeAsyncResult));
@@ -678,6 +697,9 @@ class ZodType {
678
697
  effect: { type: "refinement", refinement },
679
698
  });
680
699
  }
700
+ superRefine(refinement) {
701
+ return this._refinement(refinement);
702
+ }
681
703
  optional() {
682
704
  return ZodOptional.create(this);
683
705
  }
@@ -721,6 +743,14 @@ class ZodType {
721
743
  ...processCreateParams(undefined),
722
744
  });
723
745
  }
746
+ catch(def) {
747
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
748
+ return new ZodCatch({
749
+ innerType: this,
750
+ defaultValue: defaultValueFunc,
751
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
752
+ });
753
+ }
724
754
  describe(description) {
725
755
  const This = this.constructor;
726
756
  return new This({
@@ -728,6 +758,9 @@ class ZodType {
728
758
  description,
729
759
  });
730
760
  }
761
+ pipe(target) {
762
+ return ZodPipeline.create(this, target);
763
+ }
731
764
  isOptional() {
732
765
  return this.safeParse(undefined).success;
733
766
  }
@@ -742,6 +775,39 @@ const uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-
742
775
  // 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;
743
776
  // eslint-disable-next-line
744
777
  const emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
778
+ // interface IsDateStringOptions extends StringDateOptions {
779
+ /**
780
+ * Match any configuration
781
+ */
782
+ // any?: boolean;
783
+ // }
784
+ // Adapted from https://stackoverflow.com/a/3143231
785
+ const datetimeRegex = (args) => {
786
+ if (args.precision) {
787
+ if (args.offset) {
788
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}:\\d{2})|Z)$`);
789
+ }
790
+ else {
791
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
792
+ }
793
+ }
794
+ else if (args.precision === 0) {
795
+ if (args.offset) {
796
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$`);
797
+ }
798
+ else {
799
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
800
+ }
801
+ }
802
+ else {
803
+ if (args.offset) {
804
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
805
+ }
806
+ else {
807
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
808
+ }
809
+ }
810
+ };
745
811
  class ZodString extends ZodType {
746
812
  constructor() {
747
813
  super(...arguments);
@@ -761,6 +827,9 @@ class ZodString extends ZodType {
761
827
  });
762
828
  }
763
829
  _parse(input) {
830
+ if (this._def.coerce) {
831
+ input.data = String(input.data);
832
+ }
764
833
  const parsedType = this._getType(input);
765
834
  if (parsedType !== ZodParsedType.string) {
766
835
  const ctx = this._getOrReturnCtx(input);
@@ -784,6 +853,7 @@ class ZodString extends ZodType {
784
853
  minimum: check.value,
785
854
  type: "string",
786
855
  inclusive: true,
856
+ exact: false,
787
857
  message: check.message,
788
858
  });
789
859
  status.dirty();
@@ -797,11 +867,40 @@ class ZodString extends ZodType {
797
867
  maximum: check.value,
798
868
  type: "string",
799
869
  inclusive: true,
870
+ exact: false,
800
871
  message: check.message,
801
872
  });
802
873
  status.dirty();
803
874
  }
804
875
  }
876
+ else if (check.kind === "length") {
877
+ const tooBig = input.data.length > check.value;
878
+ const tooSmall = input.data.length < check.value;
879
+ if (tooBig || tooSmall) {
880
+ ctx = this._getOrReturnCtx(input, ctx);
881
+ if (tooBig) {
882
+ addIssueToContext(ctx, {
883
+ code: ZodIssueCode.too_big,
884
+ maximum: check.value,
885
+ type: "string",
886
+ inclusive: true,
887
+ exact: true,
888
+ message: check.message,
889
+ });
890
+ }
891
+ else if (tooSmall) {
892
+ addIssueToContext(ctx, {
893
+ code: ZodIssueCode.too_small,
894
+ minimum: check.value,
895
+ type: "string",
896
+ inclusive: true,
897
+ exact: true,
898
+ message: check.message,
899
+ });
900
+ }
901
+ status.dirty();
902
+ }
903
+ }
805
904
  else if (check.kind === "email") {
806
905
  if (!emailRegex.test(input.data)) {
807
906
  ctx = this._getOrReturnCtx(input, ctx);
@@ -887,6 +986,18 @@ class ZodString extends ZodType {
887
986
  status.dirty();
888
987
  }
889
988
  }
989
+ else if (check.kind === "datetime") {
990
+ const regex = datetimeRegex(check);
991
+ if (!regex.test(input.data)) {
992
+ ctx = this._getOrReturnCtx(input, ctx);
993
+ addIssueToContext(ctx, {
994
+ code: ZodIssueCode.invalid_string,
995
+ validation: "datetime",
996
+ message: check.message,
997
+ });
998
+ status.dirty();
999
+ }
1000
+ }
890
1001
  else {
891
1002
  util.assertNever(check);
892
1003
  }
@@ -911,6 +1022,23 @@ class ZodString extends ZodType {
911
1022
  cuid(message) {
912
1023
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
913
1024
  }
1025
+ datetime(options) {
1026
+ var _a;
1027
+ if (typeof options === "string") {
1028
+ return this._addCheck({
1029
+ kind: "datetime",
1030
+ precision: null,
1031
+ offset: false,
1032
+ message: options,
1033
+ });
1034
+ }
1035
+ return this._addCheck({
1036
+ kind: "datetime",
1037
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1038
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1039
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
1040
+ });
1041
+ }
914
1042
  regex(regex, message) {
915
1043
  return this._addCheck({
916
1044
  kind: "regex",
@@ -947,7 +1075,14 @@ class ZodString extends ZodType {
947
1075
  });
948
1076
  }
949
1077
  length(len, message) {
950
- return this.min(len, message).max(len, message);
1078
+ return this._addCheck({
1079
+ kind: "length",
1080
+ value: len,
1081
+ ...errorUtil.errToObj(message),
1082
+ });
1083
+ }
1084
+ get isDatetime() {
1085
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
951
1086
  }
952
1087
  get isEmail() {
953
1088
  return !!this._def.checks.find((ch) => ch.kind === "email");
@@ -983,9 +1118,11 @@ class ZodString extends ZodType {
983
1118
  }
984
1119
  }
985
1120
  ZodString.create = (params) => {
1121
+ var _a;
986
1122
  return new ZodString({
987
1123
  checks: [],
988
1124
  typeName: ZodFirstPartyTypeKind.ZodString,
1125
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
989
1126
  ...processCreateParams(params),
990
1127
  });
991
1128
  };
@@ -1006,6 +1143,9 @@ class ZodNumber extends ZodType {
1006
1143
  this.step = this.multipleOf;
1007
1144
  }
1008
1145
  _parse(input) {
1146
+ if (this._def.coerce) {
1147
+ input.data = Number(input.data);
1148
+ }
1009
1149
  const parsedType = this._getType(input);
1010
1150
  if (parsedType !== ZodParsedType.number) {
1011
1151
  const ctx = this._getOrReturnCtx(input);
@@ -1042,6 +1182,7 @@ class ZodNumber extends ZodType {
1042
1182
  minimum: check.value,
1043
1183
  type: "number",
1044
1184
  inclusive: check.inclusive,
1185
+ exact: false,
1045
1186
  message: check.message,
1046
1187
  });
1047
1188
  status.dirty();
@@ -1058,6 +1199,7 @@ class ZodNumber extends ZodType {
1058
1199
  maximum: check.value,
1059
1200
  type: "number",
1060
1201
  inclusive: check.inclusive,
1202
+ exact: false,
1061
1203
  message: check.message,
1062
1204
  });
1063
1205
  status.dirty();
@@ -1074,6 +1216,16 @@ class ZodNumber extends ZodType {
1074
1216
  status.dirty();
1075
1217
  }
1076
1218
  }
1219
+ else if (check.kind === "finite") {
1220
+ if (!Number.isFinite(input.data)) {
1221
+ ctx = this._getOrReturnCtx(input, ctx);
1222
+ addIssueToContext(ctx, {
1223
+ code: ZodIssueCode.not_finite,
1224
+ message: check.message,
1225
+ });
1226
+ status.dirty();
1227
+ }
1228
+ }
1077
1229
  else {
1078
1230
  util.assertNever(check);
1079
1231
  }
@@ -1157,6 +1309,12 @@ class ZodNumber extends ZodType {
1157
1309
  message: errorUtil.toString(message),
1158
1310
  });
1159
1311
  }
1312
+ finite(message) {
1313
+ return this._addCheck({
1314
+ kind: "finite",
1315
+ message: errorUtil.toString(message),
1316
+ });
1317
+ }
1160
1318
  get minValue() {
1161
1319
  let min = null;
1162
1320
  for (const ch of this._def.checks) {
@@ -1185,11 +1343,15 @@ ZodNumber.create = (params) => {
1185
1343
  return new ZodNumber({
1186
1344
  checks: [],
1187
1345
  typeName: ZodFirstPartyTypeKind.ZodNumber,
1346
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1188
1347
  ...processCreateParams(params),
1189
1348
  });
1190
1349
  };
1191
1350
  class ZodBigInt extends ZodType {
1192
1351
  _parse(input) {
1352
+ if (this._def.coerce) {
1353
+ input.data = BigInt(input.data);
1354
+ }
1193
1355
  const parsedType = this._getType(input);
1194
1356
  if (parsedType !== ZodParsedType.bigint) {
1195
1357
  const ctx = this._getOrReturnCtx(input);
@@ -1204,13 +1366,18 @@ class ZodBigInt extends ZodType {
1204
1366
  }
1205
1367
  }
1206
1368
  ZodBigInt.create = (params) => {
1369
+ var _a;
1207
1370
  return new ZodBigInt({
1208
1371
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
1372
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1209
1373
  ...processCreateParams(params),
1210
1374
  });
1211
1375
  };
1212
1376
  class ZodBoolean extends ZodType {
1213
1377
  _parse(input) {
1378
+ if (this._def.coerce) {
1379
+ input.data = Boolean(input.data);
1380
+ }
1214
1381
  const parsedType = this._getType(input);
1215
1382
  if (parsedType !== ZodParsedType.boolean) {
1216
1383
  const ctx = this._getOrReturnCtx(input);
@@ -1227,11 +1394,15 @@ class ZodBoolean extends ZodType {
1227
1394
  ZodBoolean.create = (params) => {
1228
1395
  return new ZodBoolean({
1229
1396
  typeName: ZodFirstPartyTypeKind.ZodBoolean,
1397
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1230
1398
  ...processCreateParams(params),
1231
1399
  });
1232
1400
  };
1233
1401
  class ZodDate extends ZodType {
1234
1402
  _parse(input) {
1403
+ if (this._def.coerce) {
1404
+ input.data = new Date(input.data);
1405
+ }
1235
1406
  const parsedType = this._getType(input);
1236
1407
  if (parsedType !== ZodParsedType.date) {
1237
1408
  const ctx = this._getOrReturnCtx(input);
@@ -1259,6 +1430,7 @@ class ZodDate extends ZodType {
1259
1430
  code: ZodIssueCode.too_small,
1260
1431
  message: check.message,
1261
1432
  inclusive: true,
1433
+ exact: false,
1262
1434
  minimum: check.value,
1263
1435
  type: "date",
1264
1436
  });
@@ -1272,6 +1444,7 @@ class ZodDate extends ZodType {
1272
1444
  code: ZodIssueCode.too_big,
1273
1445
  message: check.message,
1274
1446
  inclusive: true,
1447
+ exact: false,
1275
1448
  maximum: check.value,
1276
1449
  type: "date",
1277
1450
  });
@@ -1331,10 +1504,32 @@ class ZodDate extends ZodType {
1331
1504
  ZodDate.create = (params) => {
1332
1505
  return new ZodDate({
1333
1506
  checks: [],
1507
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1334
1508
  typeName: ZodFirstPartyTypeKind.ZodDate,
1335
1509
  ...processCreateParams(params),
1336
1510
  });
1337
1511
  };
1512
+ class ZodSymbol extends ZodType {
1513
+ _parse(input) {
1514
+ const parsedType = this._getType(input);
1515
+ if (parsedType !== ZodParsedType.symbol) {
1516
+ const ctx = this._getOrReturnCtx(input);
1517
+ addIssueToContext(ctx, {
1518
+ code: ZodIssueCode.invalid_type,
1519
+ expected: ZodParsedType.symbol,
1520
+ received: ctx.parsedType,
1521
+ });
1522
+ return INVALID;
1523
+ }
1524
+ return OK(input.data);
1525
+ }
1526
+ }
1527
+ ZodSymbol.create = (params) => {
1528
+ return new ZodSymbol({
1529
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
1530
+ ...processCreateParams(params),
1531
+ });
1532
+ };
1338
1533
  class ZodUndefined extends ZodType {
1339
1534
  _parse(input) {
1340
1535
  const parsedType = this._getType(input);
@@ -1459,6 +1654,22 @@ class ZodArray extends ZodType {
1459
1654
  });
1460
1655
  return INVALID;
1461
1656
  }
1657
+ if (def.exactLength !== null) {
1658
+ const tooBig = ctx.data.length > def.exactLength.value;
1659
+ const tooSmall = ctx.data.length < def.exactLength.value;
1660
+ if (tooBig || tooSmall) {
1661
+ addIssueToContext(ctx, {
1662
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
1663
+ minimum: (tooSmall ? def.exactLength.value : undefined),
1664
+ maximum: (tooBig ? def.exactLength.value : undefined),
1665
+ type: "array",
1666
+ inclusive: true,
1667
+ exact: true,
1668
+ message: def.exactLength.message,
1669
+ });
1670
+ status.dirty();
1671
+ }
1672
+ }
1462
1673
  if (def.minLength !== null) {
1463
1674
  if (ctx.data.length < def.minLength.value) {
1464
1675
  addIssueToContext(ctx, {
@@ -1466,6 +1677,7 @@ class ZodArray extends ZodType {
1466
1677
  minimum: def.minLength.value,
1467
1678
  type: "array",
1468
1679
  inclusive: true,
1680
+ exact: false,
1469
1681
  message: def.minLength.message,
1470
1682
  });
1471
1683
  status.dirty();
@@ -1478,6 +1690,7 @@ class ZodArray extends ZodType {
1478
1690
  maximum: def.maxLength.value,
1479
1691
  type: "array",
1480
1692
  inclusive: true,
1693
+ exact: false,
1481
1694
  message: def.maxLength.message,
1482
1695
  });
1483
1696
  status.dirty();
@@ -1511,7 +1724,10 @@ class ZodArray extends ZodType {
1511
1724
  });
1512
1725
  }
1513
1726
  length(len, message) {
1514
- return this.min(len, message).max(len, message);
1727
+ return new ZodArray({
1728
+ ...this._def,
1729
+ exactLength: { value: len, message: errorUtil.toString(message) },
1730
+ });
1515
1731
  }
1516
1732
  nonempty(message) {
1517
1733
  return this.min(1, message);
@@ -1522,6 +1738,7 @@ ZodArray.create = (schema, params) => {
1522
1738
  type: schema,
1523
1739
  minLength: null,
1524
1740
  maxLength: null,
1741
+ exactLength: null,
1525
1742
  typeName: ZodFirstPartyTypeKind.ZodArray,
1526
1743
  ...processCreateParams(params),
1527
1744
  });
@@ -1538,7 +1755,7 @@ var objectUtil;
1538
1755
  objectUtil.mergeShapes = (first, second) => {
1539
1756
  return {
1540
1757
  ...first,
1541
- ...second,
1758
+ ...second, // second overwrites first
1542
1759
  };
1543
1760
  };
1544
1761
  })(objectUtil || (objectUtil = {}));
@@ -1807,15 +2024,32 @@ class ZodObject extends ZodType {
1807
2024
  shape: () => newShape,
1808
2025
  });
1809
2026
  }
1810
- required() {
2027
+ required(mask) {
1811
2028
  const newShape = {};
1812
- for (const key in this.shape) {
1813
- const fieldSchema = this.shape[key];
1814
- let newField = fieldSchema;
1815
- while (newField instanceof ZodOptional) {
1816
- newField = newField._def.innerType;
2029
+ if (mask) {
2030
+ util.objectKeys(this.shape).map((key) => {
2031
+ if (util.objectKeys(mask).indexOf(key) === -1) {
2032
+ newShape[key] = this.shape[key];
2033
+ }
2034
+ else {
2035
+ const fieldSchema = this.shape[key];
2036
+ let newField = fieldSchema;
2037
+ while (newField instanceof ZodOptional) {
2038
+ newField = newField._def.innerType;
2039
+ }
2040
+ newShape[key] = newField;
2041
+ }
2042
+ });
2043
+ }
2044
+ else {
2045
+ for (const key in this.shape) {
2046
+ const fieldSchema = this.shape[key];
2047
+ let newField = fieldSchema;
2048
+ while (newField instanceof ZodOptional) {
2049
+ newField = newField._def.innerType;
2050
+ }
2051
+ newShape[key] = newField;
1817
2052
  }
1818
- newShape[key] = newField;
1819
2053
  }
1820
2054
  return new ZodObject({
1821
2055
  ...this._def,
@@ -1949,6 +2183,43 @@ ZodUnion.create = (types, params) => {
1949
2183
  ...processCreateParams(params),
1950
2184
  });
1951
2185
  };
2186
+ /////////////////////////////////////////////////////
2187
+ /////////////////////////////////////////////////////
2188
+ ////////// //////////
2189
+ ////////// ZodDiscriminatedUnion //////////
2190
+ ////////// //////////
2191
+ /////////////////////////////////////////////////////
2192
+ /////////////////////////////////////////////////////
2193
+ const getDiscriminator = (type) => {
2194
+ if (type instanceof ZodLazy) {
2195
+ return getDiscriminator(type.schema);
2196
+ }
2197
+ else if (type instanceof ZodEffects) {
2198
+ return getDiscriminator(type.innerType());
2199
+ }
2200
+ else if (type instanceof ZodLiteral) {
2201
+ return [type.value];
2202
+ }
2203
+ else if (type instanceof ZodEnum) {
2204
+ return type.options;
2205
+ }
2206
+ else if (type instanceof ZodNativeEnum) {
2207
+ // eslint-disable-next-line ban/ban
2208
+ return Object.keys(type.enum);
2209
+ }
2210
+ else if (type instanceof ZodDefault) {
2211
+ return getDiscriminator(type._def.innerType);
2212
+ }
2213
+ else if (type instanceof ZodUndefined) {
2214
+ return [undefined];
2215
+ }
2216
+ else if (type instanceof ZodNull) {
2217
+ return [null];
2218
+ }
2219
+ else {
2220
+ return null;
2221
+ }
2222
+ };
1952
2223
  class ZodDiscriminatedUnion extends ZodType {
1953
2224
  _parse(input) {
1954
2225
  const { ctx } = this._processInputParams(input);
@@ -1962,11 +2233,11 @@ class ZodDiscriminatedUnion extends ZodType {
1962
2233
  }
1963
2234
  const discriminator = this.discriminator;
1964
2235
  const discriminatorValue = ctx.data[discriminator];
1965
- const option = this.options.get(discriminatorValue);
2236
+ const option = this.optionsMap.get(discriminatorValue);
1966
2237
  if (!option) {
1967
2238
  addIssueToContext(ctx, {
1968
2239
  code: ZodIssueCode.invalid_union_discriminator,
1969
- options: this.validDiscriminatorValues,
2240
+ options: Array.from(this.optionsMap.keys()),
1970
2241
  path: [discriminator],
1971
2242
  });
1972
2243
  return INVALID;
@@ -1989,12 +2260,12 @@ class ZodDiscriminatedUnion extends ZodType {
1989
2260
  get discriminator() {
1990
2261
  return this._def.discriminator;
1991
2262
  }
1992
- get validDiscriminatorValues() {
1993
- return Array.from(this.options.keys());
1994
- }
1995
2263
  get options() {
1996
2264
  return this._def.options;
1997
2265
  }
2266
+ get optionsMap() {
2267
+ return this._def.optionsMap;
2268
+ }
1998
2269
  /**
1999
2270
  * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2000
2271
  * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
@@ -2003,26 +2274,27 @@ class ZodDiscriminatedUnion extends ZodType {
2003
2274
  * @param types an array of object schemas
2004
2275
  * @param params
2005
2276
  */
2006
- static create(discriminator, types, params) {
2277
+ static create(discriminator, options, params) {
2007
2278
  // Get all the valid discriminator values
2008
- const options = new Map();
2009
- try {
2010
- types.forEach((type) => {
2011
- const discriminatorValue = type.shape[discriminator].value;
2012
- options.set(discriminatorValue, type);
2013
- });
2014
- }
2015
- catch (e) {
2016
- throw new Error("The discriminator value could not be extracted from all the provided schemas");
2017
- }
2018
- // Assert that all the discriminator values are unique
2019
- if (options.size !== types.length) {
2020
- throw new Error("Some of the discriminator values are not unique");
2279
+ const optionsMap = new Map();
2280
+ // try {
2281
+ for (const type of options) {
2282
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2283
+ if (!discriminatorValues) {
2284
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2285
+ }
2286
+ for (const value of discriminatorValues) {
2287
+ if (optionsMap.has(value)) {
2288
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2289
+ }
2290
+ optionsMap.set(value, type);
2291
+ }
2021
2292
  }
2022
2293
  return new ZodDiscriminatedUnion({
2023
2294
  typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2024
2295
  discriminator,
2025
2296
  options,
2297
+ optionsMap,
2026
2298
  ...processCreateParams(params),
2027
2299
  });
2028
2300
  }
@@ -2143,6 +2415,7 @@ class ZodTuple extends ZodType {
2143
2415
  code: ZodIssueCode.too_small,
2144
2416
  minimum: this._def.items.length,
2145
2417
  inclusive: true,
2418
+ exact: false,
2146
2419
  type: "array",
2147
2420
  });
2148
2421
  return INVALID;
@@ -2153,6 +2426,7 @@ class ZodTuple extends ZodType {
2153
2426
  code: ZodIssueCode.too_big,
2154
2427
  maximum: this._def.items.length,
2155
2428
  inclusive: true,
2429
+ exact: false,
2156
2430
  type: "array",
2157
2431
  });
2158
2432
  status.dirty();
@@ -2328,6 +2602,7 @@ class ZodSet extends ZodType {
2328
2602
  minimum: def.minSize.value,
2329
2603
  type: "set",
2330
2604
  inclusive: true,
2605
+ exact: false,
2331
2606
  message: def.minSize.message,
2332
2607
  });
2333
2608
  status.dirty();
@@ -2340,6 +2615,7 @@ class ZodSet extends ZodType {
2340
2615
  maximum: def.maxSize.value,
2341
2616
  type: "set",
2342
2617
  inclusive: true,
2618
+ exact: false,
2343
2619
  message: def.maxSize.message,
2344
2620
  });
2345
2621
  status.dirty();
@@ -2680,6 +2956,11 @@ class ZodEffects extends ZodType {
2680
2956
  innerType() {
2681
2957
  return this._def.schema;
2682
2958
  }
2959
+ sourceType() {
2960
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects
2961
+ ? this._def.schema.sourceType()
2962
+ : this._def.schema;
2963
+ }
2683
2964
  _parse(input) {
2684
2965
  const { status, ctx } = this._processInputParams(input);
2685
2966
  const effect = this._def.effect || null;
@@ -2866,9 +3147,49 @@ class ZodDefault extends ZodType {
2866
3147
  }
2867
3148
  }
2868
3149
  ZodDefault.create = (type, params) => {
2869
- return new ZodOptional({
3150
+ return new ZodDefault({
2870
3151
  innerType: type,
2871
- typeName: ZodFirstPartyTypeKind.ZodOptional,
3152
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3153
+ defaultValue: typeof params.default === "function"
3154
+ ? params.default
3155
+ : () => params.default,
3156
+ ...processCreateParams(params),
3157
+ });
3158
+ };
3159
+ class ZodCatch extends ZodType {
3160
+ _parse(input) {
3161
+ const { ctx } = this._processInputParams(input);
3162
+ const result = this._def.innerType._parse({
3163
+ data: ctx.data,
3164
+ path: ctx.path,
3165
+ parent: ctx,
3166
+ });
3167
+ if (isAsync(result)) {
3168
+ return result.then((result) => {
3169
+ return {
3170
+ status: "valid",
3171
+ value: result.status === "valid" ? result.value : this._def.defaultValue(),
3172
+ };
3173
+ });
3174
+ }
3175
+ else {
3176
+ return {
3177
+ status: "valid",
3178
+ value: result.status === "valid" ? result.value : this._def.defaultValue(),
3179
+ };
3180
+ }
3181
+ }
3182
+ removeDefault() {
3183
+ return this._def.innerType;
3184
+ }
3185
+ }
3186
+ ZodCatch.create = (type, params) => {
3187
+ return new ZodCatch({
3188
+ innerType: type,
3189
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3190
+ defaultValue: typeof params.default === "function"
3191
+ ? params.default
3192
+ : () => params.default,
2872
3193
  ...processCreateParams(params),
2873
3194
  });
2874
3195
  };
@@ -2908,6 +3229,64 @@ class ZodBranded extends ZodType {
2908
3229
  return this._def.type;
2909
3230
  }
2910
3231
  }
3232
+ class ZodPipeline extends ZodType {
3233
+ _parse(input) {
3234
+ const { status, ctx } = this._processInputParams(input);
3235
+ if (ctx.common.async) {
3236
+ const handleAsync = async () => {
3237
+ const inResult = await this._def.in._parseAsync({
3238
+ data: ctx.data,
3239
+ path: ctx.path,
3240
+ parent: ctx,
3241
+ });
3242
+ if (inResult.status === "aborted")
3243
+ return INVALID;
3244
+ if (inResult.status === "dirty") {
3245
+ status.dirty();
3246
+ return DIRTY(inResult.value);
3247
+ }
3248
+ else {
3249
+ return this._def.out._parseAsync({
3250
+ data: inResult.value,
3251
+ path: ctx.path,
3252
+ parent: ctx,
3253
+ });
3254
+ }
3255
+ };
3256
+ return handleAsync();
3257
+ }
3258
+ else {
3259
+ const inResult = this._def.in._parseSync({
3260
+ data: ctx.data,
3261
+ path: ctx.path,
3262
+ parent: ctx,
3263
+ });
3264
+ if (inResult.status === "aborted")
3265
+ return INVALID;
3266
+ if (inResult.status === "dirty") {
3267
+ status.dirty();
3268
+ return {
3269
+ status: "dirty",
3270
+ value: inResult.value,
3271
+ };
3272
+ }
3273
+ else {
3274
+ return this._def.out._parseSync({
3275
+ data: inResult.value,
3276
+ path: ctx.path,
3277
+ parent: ctx,
3278
+ });
3279
+ }
3280
+ }
3281
+ }
3282
+ static create(a, b) {
3283
+ return new ZodPipeline({
3284
+ in: a,
3285
+ out: b,
3286
+ typeName: ZodFirstPartyTypeKind.ZodPipeline,
3287
+ });
3288
+ }
3289
+ }
2911
3290
  const custom = (check, params = {}, fatal) => {
2912
3291
  if (check)
2913
3292
  return ZodAny.create().superRefine((data, ctx) => {
@@ -2930,6 +3309,7 @@ var ZodFirstPartyTypeKind;
2930
3309
  ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
2931
3310
  ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
2932
3311
  ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
3312
+ ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
2933
3313
  ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
2934
3314
  ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
2935
3315
  ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
@@ -2954,16 +3334,14 @@ var ZodFirstPartyTypeKind;
2954
3334
  ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
2955
3335
  ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
2956
3336
  ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
3337
+ ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
2957
3338
  ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
2958
3339
  ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
3340
+ ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
2959
3341
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
2960
- // new approach that works for abstract classes
2961
- // but required TS 4.4+
2962
- // abstract class Class {
2963
- // constructor(..._: any[]) {}
2964
- // }
2965
- // const instanceOfType = <T extends typeof Class>(
2966
- const instanceOfType = (cls, params = {
3342
+ const instanceOfType = (
3343
+ // const instanceOfType = <T extends new (...args: any[]) => any>(
3344
+ cls, params = {
2967
3345
  message: `Input not instance of ${cls.name}`,
2968
3346
  }) => custom((data) => data instanceof cls, params, true);
2969
3347
  const stringType = ZodString.create;
@@ -2972,6 +3350,7 @@ const nanType = ZodNaN.create;
2972
3350
  const bigIntType = ZodBigInt.create;
2973
3351
  const booleanType = ZodBoolean.create;
2974
3352
  const dateType = ZodDate.create;
3353
+ const symbolType = ZodSymbol.create;
2975
3354
  const undefinedType = ZodUndefined.create;
2976
3355
  const nullType = ZodNull.create;
2977
3356
  const anyType = ZodAny.create;
@@ -2998,15 +3377,21 @@ const effectsType = ZodEffects.create;
2998
3377
  const optionalType = ZodOptional.create;
2999
3378
  const nullableType = ZodNullable.create;
3000
3379
  const preprocessType = ZodEffects.createWithPreprocess;
3380
+ const pipelineType = ZodPipeline.create;
3001
3381
  const ostring = () => stringType().optional();
3002
3382
  const onumber = () => numberType().optional();
3003
3383
  const oboolean = () => booleanType().optional();
3384
+ const coerce = {
3385
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
3386
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
3387
+ boolean: ((arg) => ZodBoolean.create({ ...arg, coerce: true })),
3388
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
3389
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true })),
3390
+ };
3004
3391
  const NEVER = INVALID;
3005
3392
 
3006
3393
  var mod = /*#__PURE__*/Object.freeze({
3007
3394
  __proto__: null,
3008
- getParsedType: getParsedType,
3009
- ZodParsedType: ZodParsedType,
3010
3395
  defaultErrorMap: errorMap,
3011
3396
  setErrorMap: setErrorMap,
3012
3397
  getErrorMap: getErrorMap,
@@ -3021,12 +3406,16 @@ var mod = /*#__PURE__*/Object.freeze({
3021
3406
  isDirty: isDirty,
3022
3407
  isValid: isValid,
3023
3408
  isAsync: isAsync,
3409
+ get util () { return util; },
3410
+ ZodParsedType: ZodParsedType,
3411
+ getParsedType: getParsedType,
3024
3412
  ZodType: ZodType,
3025
3413
  ZodString: ZodString,
3026
3414
  ZodNumber: ZodNumber,
3027
3415
  ZodBigInt: ZodBigInt,
3028
3416
  ZodBoolean: ZodBoolean,
3029
3417
  ZodDate: ZodDate,
3418
+ ZodSymbol: ZodSymbol,
3030
3419
  ZodUndefined: ZodUndefined,
3031
3420
  ZodNull: ZodNull,
3032
3421
  ZodAny: ZodAny,
@@ -3054,14 +3443,17 @@ var mod = /*#__PURE__*/Object.freeze({
3054
3443
  ZodOptional: ZodOptional,
3055
3444
  ZodNullable: ZodNullable,
3056
3445
  ZodDefault: ZodDefault,
3446
+ ZodCatch: ZodCatch,
3057
3447
  ZodNaN: ZodNaN,
3058
3448
  BRAND: BRAND,
3059
3449
  ZodBranded: ZodBranded,
3450
+ ZodPipeline: ZodPipeline,
3060
3451
  custom: custom,
3061
3452
  Schema: ZodType,
3062
3453
  ZodSchema: ZodType,
3063
3454
  late: late,
3064
3455
  get ZodFirstPartyTypeKind () { return ZodFirstPartyTypeKind; },
3456
+ coerce: coerce,
3065
3457
  any: anyType,
3066
3458
  array: arrayType,
3067
3459
  bigint: bigIntType,
@@ -3087,12 +3479,14 @@ var mod = /*#__PURE__*/Object.freeze({
3087
3479
  onumber: onumber,
3088
3480
  optional: optionalType,
3089
3481
  ostring: ostring,
3482
+ pipeline: pipelineType,
3090
3483
  preprocess: preprocessType,
3091
3484
  promise: promiseType,
3092
3485
  record: recordType,
3093
3486
  set: setType,
3094
3487
  strictObject: strictObjectType,
3095
3488
  string: stringType,
3489
+ symbol: symbolType,
3096
3490
  transformer: effectsType,
3097
3491
  tuple: tupleType,
3098
3492
  'undefined': undefinedType,
@@ -3428,69 +3822,55 @@ mod.object({
3428
3822
  });
3429
3823
  mod.object({ id: mod.string(), uri: mod.string() }).catchall(mod.any());
3430
3824
  mod.object({
3825
+ profileId: mod.string().min(3).max(40),
3826
+ displayName: mod.string().default(""),
3827
+ did: mod.string(),
3828
+ email: mod.string().optional(),
3829
+ image: mod.string().optional(),
3830
+ isServiceProfile: mod.boolean().default(false).optional()
3831
+ });
3832
+ mod.object({
3833
+ uri: mod.string(),
3834
+ to: mod.string(),
3835
+ from: mod.string(),
3836
+ sent: mod.string().datetime(),
3837
+ received: mod.string().datetime().optional()
3838
+ });
3839
+ mod.object({
3840
+ uri: mod.string(),
3841
+ name: mod.string().optional(),
3842
+ type: mod.string().optional(),
3843
+ category: mod.string().optional()
3844
+ });
3845
+ var JWKValidator = mod.object({
3431
3846
  kty: mod.string(),
3432
3847
  crv: mod.string(),
3433
3848
  x: mod.string(),
3434
3849
  y: mod.string().optional(),
3850
+ n: mod.string().optional(),
3435
3851
  d: mod.string()
3436
3852
  });
3853
+ var JWERecipientHeaderValidator = mod.object({
3854
+ alg: mod.string(),
3855
+ iv: mod.string(),
3856
+ tag: mod.string(),
3857
+ epk: JWKValidator.partial().optional(),
3858
+ kid: mod.string().optional(),
3859
+ apv: mod.string().optional(),
3860
+ apu: mod.string().optional()
3861
+ });
3862
+ var JWERecipientValidator = mod.object({
3863
+ header: JWERecipientHeaderValidator,
3864
+ encrypted_key: mod.string()
3865
+ });
3866
+ mod.object({
3867
+ protected: mod.string(),
3868
+ iv: mod.string(),
3869
+ ciphertext: mod.string(),
3870
+ tag: mod.string(),
3871
+ aad: mod.string().optional(),
3872
+ recipients: JWERecipientValidator.array().optional()
3873
+ });
3437
3874
 
3438
- const StatusToBgColor = {
3439
- [VerificationStatusEnum.Success]: "bg-emerald-500",
3440
- [VerificationStatusEnum.Failed]: "bg-yellow-400",
3441
- [VerificationStatusEnum.Error]: "bg-rose-600"
3442
- };
3443
- const StatusToTextColor = {
3444
- [VerificationStatusEnum.Success]: "text-emerald-700",
3445
- [VerificationStatusEnum.Failed]: "text-yellow-400",
3446
- [VerificationStatusEnum.Error]: "text-rose-600"
3447
- };
3448
- const StatusToIcon = {
3449
- [VerificationStatusEnum.Success]: VerificationPassedIcon,
3450
- [VerificationStatusEnum.Failed]: VerificationWarningIcon,
3451
- [VerificationStatusEnum.Error]: VerificationFailedIcon
3452
- };
3453
- const StatusToText = {
3454
- [VerificationStatusEnum.Success]: "Verification Success",
3455
- [VerificationStatusEnum.Error]: "Verification Error ",
3456
- [VerificationStatusEnum.Failed]: "Verification Failed"
3457
- };
3458
- const ValidationStateIndicator = ({ status }) => {
3459
- const bgColor = StatusToBgColor[status];
3460
- const source = StatusToIcon[status];
3461
- return /* @__PURE__ */ React.createElement("div", {
3462
- className: `relative rounded-full w-[30px] h-[30px] ${bgColor}`
3463
- }, /* @__PURE__ */ React.createElement("div", {
3464
- className: "relative w-[100%] h-[100%] flex items-center justify-center rounded-[50%] bg-white rounded-full overflow-hidden"
3465
- }, /* @__PURE__ */ React.createElement("img", {
3466
- className: "h-full w-full object-contain p-1",
3467
- src: source != null ? source : "",
3468
- alt: "Verification Status Icon"
3469
- })));
3470
- };
3471
- const VCVerificationPill = ({
3472
- message = "",
3473
- details,
3474
- status = VerificationStatusEnum.Success
3475
- }) => {
3476
- const statusColor = StatusToTextColor[status];
3477
- const statusInfoText = StatusToText[status];
3478
- return /* @__PURE__ */ React.createElement("section", {
3479
- className: "flex width-full bg-white p-2 px-5 my-3.5 justify-between items-center relative vc-verification-checklist-pill rounded-[22px]"
3480
- }, /* @__PURE__ */ React.createElement("div", {
3481
- className: "vc-pill-left"
3482
- }, /* @__PURE__ */ React.createElement("p", {
3483
- className: `text-[10px] font-bold status-text uppercase ${statusColor}`
3484
- }, statusInfoText), /* @__PURE__ */ React.createElement("p", {
3485
- className: "text-[12px] text-grayscale-900 vc-pill-text"
3486
- }, message), details && /* @__PURE__ */ React.createElement("p", {
3487
- className: "text-[12px] text-gray-600"
3488
- }, " ", details)), /* @__PURE__ */ React.createElement("div", {
3489
- className: "vc-pill-right"
3490
- }, /* @__PURE__ */ React.createElement(ValidationStateIndicator, {
3491
- status
3492
- })));
3493
- };
3494
-
3495
- export { ValidationStateIndicator as V, VCVerificationPill as a };
3496
- //# sourceMappingURL=VCVerificationPill-7a09f9fa.js.map
3875
+ export { VerificationStatusEnum as V };
3876
+ //# sourceMappingURL=types.esm-9b3b15f7.js.map