@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,17 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
4
- var VerificationFailedIcon = require('./RedXCircle.svg');
5
- var VerificationPassedIcon = require('./GreenCheckCircle.svg');
6
- var VerificationWarningIcon = require('./YellowWarningCircle.svg');
7
-
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
- var VerificationFailedIcon__default = /*#__PURE__*/_interopDefaultLegacy(VerificationFailedIcon);
12
- var VerificationPassedIcon__default = /*#__PURE__*/_interopDefaultLegacy(VerificationPassedIcon);
13
- var VerificationWarningIcon__default = /*#__PURE__*/_interopDefaultLegacy(VerificationWarningIcon);
14
-
15
3
  var util;
16
4
  (function (util) {
17
5
  util.assertEqual = (val) => val;
@@ -112,6 +100,8 @@ const getParsedType = (data) => {
112
100
  return ZodParsedType.function;
113
101
  case "bigint":
114
102
  return ZodParsedType.bigint;
103
+ case "symbol":
104
+ return ZodParsedType.symbol;
115
105
  case "object":
116
106
  if (Array.isArray(data)) {
117
107
  return ZodParsedType.array;
@@ -156,6 +146,7 @@ const ZodIssueCode = util.arrayToEnum([
156
146
  "too_big",
157
147
  "invalid_intersection_types",
158
148
  "not_multiple_of",
149
+ "not_finite",
159
150
  ]);
160
151
  const quotelessJson = (obj) => {
161
152
  const json = JSON.stringify(obj, null, 2);
@@ -322,25 +313,41 @@ const errorMap = (issue, _ctx) => {
322
313
  break;
323
314
  case ZodIssueCode.too_small:
324
315
  if (issue.type === "array")
325
- message = `Array must contain ${issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
316
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
326
317
  else if (issue.type === "string")
327
- message = `String must contain ${issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
318
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
328
319
  else if (issue.type === "number")
329
- message = `Number must be greater than ${issue.inclusive ? `or equal to ` : ``}${issue.minimum}`;
320
+ message = `Number must be ${issue.exact
321
+ ? `exactly equal to `
322
+ : issue.inclusive
323
+ ? `greater than or equal to `
324
+ : `greater than `}${issue.minimum}`;
330
325
  else if (issue.type === "date")
331
- message = `Date must be greater than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.minimum)}`;
326
+ message = `Date must be ${issue.exact
327
+ ? `exactly equal to `
328
+ : issue.inclusive
329
+ ? `greater than or equal to `
330
+ : `greater than `}${new Date(issue.minimum)}`;
332
331
  else
333
332
  message = "Invalid input";
334
333
  break;
335
334
  case ZodIssueCode.too_big:
336
335
  if (issue.type === "array")
337
- message = `Array must contain ${issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
336
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
338
337
  else if (issue.type === "string")
339
- message = `String must contain ${issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
338
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
340
339
  else if (issue.type === "number")
341
- message = `Number must be less than ${issue.inclusive ? `or equal to ` : ``}${issue.maximum}`;
340
+ message = `Number must be ${issue.exact
341
+ ? `exactly`
342
+ : issue.inclusive
343
+ ? `less than or equal to`
344
+ : `less than`} ${issue.maximum}`;
342
345
  else if (issue.type === "date")
343
- message = `Date must be smaller than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.maximum)}`;
346
+ message = `Date must be ${issue.exact
347
+ ? `exactly`
348
+ : issue.inclusive
349
+ ? `smaller than or equal to`
350
+ : `smaller than`} ${new Date(issue.maximum)}`;
344
351
  else
345
352
  message = "Invalid input";
346
353
  break;
@@ -353,6 +360,9 @@ const errorMap = (issue, _ctx) => {
353
360
  case ZodIssueCode.not_multiple_of:
354
361
  message = `Number must be a multiple of ${issue.multipleOf}`;
355
362
  break;
363
+ case ZodIssueCode.not_finite:
364
+ message = "Number must be finite";
365
+ break;
356
366
  default:
357
367
  message = _ctx.defaultError;
358
368
  util.assertNever(issue);
@@ -399,7 +409,7 @@ function addIssueToContext(ctx, issueData) {
399
409
  ctx.common.contextualErrorMap,
400
410
  ctx.schemaErrorMap,
401
411
  getErrorMap(),
402
- errorMap,
412
+ errorMap, // then global default map
403
413
  ].filter((x) => !!x),
404
414
  });
405
415
  ctx.common.issues.push(issue);
@@ -518,7 +528,6 @@ class ZodType {
518
528
  constructor(def) {
519
529
  /** Alias of safeParseAsync */
520
530
  this.spa = this.safeParseAsync;
521
- this.superRefine = this._refinement;
522
531
  this._def = def;
523
532
  this.parse = this.parse.bind(this);
524
533
  this.safeParse = this.safeParse.bind(this);
@@ -536,8 +545,11 @@ class ZodType {
536
545
  this.or = this.or.bind(this);
537
546
  this.and = this.and.bind(this);
538
547
  this.transform = this.transform.bind(this);
548
+ this.brand = this.brand.bind(this);
539
549
  this.default = this.default.bind(this);
550
+ this.catch = this.catch.bind(this);
540
551
  this.describe = this.describe.bind(this);
552
+ this.pipe = this.pipe.bind(this);
541
553
  this.isNullable = this.isNullable.bind(this);
542
554
  this.isOptional = this.isOptional.bind(this);
543
555
  }
@@ -623,7 +635,7 @@ class ZodType {
623
635
  data,
624
636
  parsedType: getParsedType(data),
625
637
  };
626
- const maybeAsyncResult = this._parse({ data, path: [], parent: ctx });
638
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
627
639
  const result = await (isAsync(maybeAsyncResult)
628
640
  ? maybeAsyncResult
629
641
  : Promise.resolve(maybeAsyncResult));
@@ -687,6 +699,9 @@ class ZodType {
687
699
  effect: { type: "refinement", refinement },
688
700
  });
689
701
  }
702
+ superRefine(refinement) {
703
+ return this._refinement(refinement);
704
+ }
690
705
  optional() {
691
706
  return ZodOptional.create(this);
692
707
  }
@@ -730,6 +745,14 @@ class ZodType {
730
745
  ...processCreateParams(undefined),
731
746
  });
732
747
  }
748
+ catch(def) {
749
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
750
+ return new ZodCatch({
751
+ innerType: this,
752
+ defaultValue: defaultValueFunc,
753
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
754
+ });
755
+ }
733
756
  describe(description) {
734
757
  const This = this.constructor;
735
758
  return new This({
@@ -737,6 +760,9 @@ class ZodType {
737
760
  description,
738
761
  });
739
762
  }
763
+ pipe(target) {
764
+ return ZodPipeline.create(this, target);
765
+ }
740
766
  isOptional() {
741
767
  return this.safeParse(undefined).success;
742
768
  }
@@ -751,6 +777,39 @@ const uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-
751
777
  // 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;
752
778
  // eslint-disable-next-line
753
779
  const emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
780
+ // interface IsDateStringOptions extends StringDateOptions {
781
+ /**
782
+ * Match any configuration
783
+ */
784
+ // any?: boolean;
785
+ // }
786
+ // Adapted from https://stackoverflow.com/a/3143231
787
+ const datetimeRegex = (args) => {
788
+ if (args.precision) {
789
+ if (args.offset) {
790
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}:\\d{2})|Z)$`);
791
+ }
792
+ else {
793
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
794
+ }
795
+ }
796
+ else if (args.precision === 0) {
797
+ if (args.offset) {
798
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$`);
799
+ }
800
+ else {
801
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
802
+ }
803
+ }
804
+ else {
805
+ if (args.offset) {
806
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
807
+ }
808
+ else {
809
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
810
+ }
811
+ }
812
+ };
754
813
  class ZodString extends ZodType {
755
814
  constructor() {
756
815
  super(...arguments);
@@ -770,6 +829,9 @@ class ZodString extends ZodType {
770
829
  });
771
830
  }
772
831
  _parse(input) {
832
+ if (this._def.coerce) {
833
+ input.data = String(input.data);
834
+ }
773
835
  const parsedType = this._getType(input);
774
836
  if (parsedType !== ZodParsedType.string) {
775
837
  const ctx = this._getOrReturnCtx(input);
@@ -793,6 +855,7 @@ class ZodString extends ZodType {
793
855
  minimum: check.value,
794
856
  type: "string",
795
857
  inclusive: true,
858
+ exact: false,
796
859
  message: check.message,
797
860
  });
798
861
  status.dirty();
@@ -806,11 +869,40 @@ class ZodString extends ZodType {
806
869
  maximum: check.value,
807
870
  type: "string",
808
871
  inclusive: true,
872
+ exact: false,
809
873
  message: check.message,
810
874
  });
811
875
  status.dirty();
812
876
  }
813
877
  }
878
+ else if (check.kind === "length") {
879
+ const tooBig = input.data.length > check.value;
880
+ const tooSmall = input.data.length < check.value;
881
+ if (tooBig || tooSmall) {
882
+ ctx = this._getOrReturnCtx(input, ctx);
883
+ if (tooBig) {
884
+ addIssueToContext(ctx, {
885
+ code: ZodIssueCode.too_big,
886
+ maximum: check.value,
887
+ type: "string",
888
+ inclusive: true,
889
+ exact: true,
890
+ message: check.message,
891
+ });
892
+ }
893
+ else if (tooSmall) {
894
+ addIssueToContext(ctx, {
895
+ code: ZodIssueCode.too_small,
896
+ minimum: check.value,
897
+ type: "string",
898
+ inclusive: true,
899
+ exact: true,
900
+ message: check.message,
901
+ });
902
+ }
903
+ status.dirty();
904
+ }
905
+ }
814
906
  else if (check.kind === "email") {
815
907
  if (!emailRegex.test(input.data)) {
816
908
  ctx = this._getOrReturnCtx(input, ctx);
@@ -896,6 +988,18 @@ class ZodString extends ZodType {
896
988
  status.dirty();
897
989
  }
898
990
  }
991
+ else if (check.kind === "datetime") {
992
+ const regex = datetimeRegex(check);
993
+ if (!regex.test(input.data)) {
994
+ ctx = this._getOrReturnCtx(input, ctx);
995
+ addIssueToContext(ctx, {
996
+ code: ZodIssueCode.invalid_string,
997
+ validation: "datetime",
998
+ message: check.message,
999
+ });
1000
+ status.dirty();
1001
+ }
1002
+ }
899
1003
  else {
900
1004
  util.assertNever(check);
901
1005
  }
@@ -920,6 +1024,23 @@ class ZodString extends ZodType {
920
1024
  cuid(message) {
921
1025
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
922
1026
  }
1027
+ datetime(options) {
1028
+ var _a;
1029
+ if (typeof options === "string") {
1030
+ return this._addCheck({
1031
+ kind: "datetime",
1032
+ precision: null,
1033
+ offset: false,
1034
+ message: options,
1035
+ });
1036
+ }
1037
+ return this._addCheck({
1038
+ kind: "datetime",
1039
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1040
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1041
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
1042
+ });
1043
+ }
923
1044
  regex(regex, message) {
924
1045
  return this._addCheck({
925
1046
  kind: "regex",
@@ -956,7 +1077,14 @@ class ZodString extends ZodType {
956
1077
  });
957
1078
  }
958
1079
  length(len, message) {
959
- return this.min(len, message).max(len, message);
1080
+ return this._addCheck({
1081
+ kind: "length",
1082
+ value: len,
1083
+ ...errorUtil.errToObj(message),
1084
+ });
1085
+ }
1086
+ get isDatetime() {
1087
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
960
1088
  }
961
1089
  get isEmail() {
962
1090
  return !!this._def.checks.find((ch) => ch.kind === "email");
@@ -992,9 +1120,11 @@ class ZodString extends ZodType {
992
1120
  }
993
1121
  }
994
1122
  ZodString.create = (params) => {
1123
+ var _a;
995
1124
  return new ZodString({
996
1125
  checks: [],
997
1126
  typeName: ZodFirstPartyTypeKind.ZodString,
1127
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
998
1128
  ...processCreateParams(params),
999
1129
  });
1000
1130
  };
@@ -1015,6 +1145,9 @@ class ZodNumber extends ZodType {
1015
1145
  this.step = this.multipleOf;
1016
1146
  }
1017
1147
  _parse(input) {
1148
+ if (this._def.coerce) {
1149
+ input.data = Number(input.data);
1150
+ }
1018
1151
  const parsedType = this._getType(input);
1019
1152
  if (parsedType !== ZodParsedType.number) {
1020
1153
  const ctx = this._getOrReturnCtx(input);
@@ -1051,6 +1184,7 @@ class ZodNumber extends ZodType {
1051
1184
  minimum: check.value,
1052
1185
  type: "number",
1053
1186
  inclusive: check.inclusive,
1187
+ exact: false,
1054
1188
  message: check.message,
1055
1189
  });
1056
1190
  status.dirty();
@@ -1067,6 +1201,7 @@ class ZodNumber extends ZodType {
1067
1201
  maximum: check.value,
1068
1202
  type: "number",
1069
1203
  inclusive: check.inclusive,
1204
+ exact: false,
1070
1205
  message: check.message,
1071
1206
  });
1072
1207
  status.dirty();
@@ -1083,6 +1218,16 @@ class ZodNumber extends ZodType {
1083
1218
  status.dirty();
1084
1219
  }
1085
1220
  }
1221
+ else if (check.kind === "finite") {
1222
+ if (!Number.isFinite(input.data)) {
1223
+ ctx = this._getOrReturnCtx(input, ctx);
1224
+ addIssueToContext(ctx, {
1225
+ code: ZodIssueCode.not_finite,
1226
+ message: check.message,
1227
+ });
1228
+ status.dirty();
1229
+ }
1230
+ }
1086
1231
  else {
1087
1232
  util.assertNever(check);
1088
1233
  }
@@ -1166,6 +1311,12 @@ class ZodNumber extends ZodType {
1166
1311
  message: errorUtil.toString(message),
1167
1312
  });
1168
1313
  }
1314
+ finite(message) {
1315
+ return this._addCheck({
1316
+ kind: "finite",
1317
+ message: errorUtil.toString(message),
1318
+ });
1319
+ }
1169
1320
  get minValue() {
1170
1321
  let min = null;
1171
1322
  for (const ch of this._def.checks) {
@@ -1194,11 +1345,15 @@ ZodNumber.create = (params) => {
1194
1345
  return new ZodNumber({
1195
1346
  checks: [],
1196
1347
  typeName: ZodFirstPartyTypeKind.ZodNumber,
1348
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1197
1349
  ...processCreateParams(params),
1198
1350
  });
1199
1351
  };
1200
1352
  class ZodBigInt extends ZodType {
1201
1353
  _parse(input) {
1354
+ if (this._def.coerce) {
1355
+ input.data = BigInt(input.data);
1356
+ }
1202
1357
  const parsedType = this._getType(input);
1203
1358
  if (parsedType !== ZodParsedType.bigint) {
1204
1359
  const ctx = this._getOrReturnCtx(input);
@@ -1213,13 +1368,18 @@ class ZodBigInt extends ZodType {
1213
1368
  }
1214
1369
  }
1215
1370
  ZodBigInt.create = (params) => {
1371
+ var _a;
1216
1372
  return new ZodBigInt({
1217
1373
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
1374
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1218
1375
  ...processCreateParams(params),
1219
1376
  });
1220
1377
  };
1221
1378
  class ZodBoolean extends ZodType {
1222
1379
  _parse(input) {
1380
+ if (this._def.coerce) {
1381
+ input.data = Boolean(input.data);
1382
+ }
1223
1383
  const parsedType = this._getType(input);
1224
1384
  if (parsedType !== ZodParsedType.boolean) {
1225
1385
  const ctx = this._getOrReturnCtx(input);
@@ -1236,11 +1396,15 @@ class ZodBoolean extends ZodType {
1236
1396
  ZodBoolean.create = (params) => {
1237
1397
  return new ZodBoolean({
1238
1398
  typeName: ZodFirstPartyTypeKind.ZodBoolean,
1399
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1239
1400
  ...processCreateParams(params),
1240
1401
  });
1241
1402
  };
1242
1403
  class ZodDate extends ZodType {
1243
1404
  _parse(input) {
1405
+ if (this._def.coerce) {
1406
+ input.data = new Date(input.data);
1407
+ }
1244
1408
  const parsedType = this._getType(input);
1245
1409
  if (parsedType !== ZodParsedType.date) {
1246
1410
  const ctx = this._getOrReturnCtx(input);
@@ -1268,6 +1432,7 @@ class ZodDate extends ZodType {
1268
1432
  code: ZodIssueCode.too_small,
1269
1433
  message: check.message,
1270
1434
  inclusive: true,
1435
+ exact: false,
1271
1436
  minimum: check.value,
1272
1437
  type: "date",
1273
1438
  });
@@ -1281,6 +1446,7 @@ class ZodDate extends ZodType {
1281
1446
  code: ZodIssueCode.too_big,
1282
1447
  message: check.message,
1283
1448
  inclusive: true,
1449
+ exact: false,
1284
1450
  maximum: check.value,
1285
1451
  type: "date",
1286
1452
  });
@@ -1340,10 +1506,32 @@ class ZodDate extends ZodType {
1340
1506
  ZodDate.create = (params) => {
1341
1507
  return new ZodDate({
1342
1508
  checks: [],
1509
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1343
1510
  typeName: ZodFirstPartyTypeKind.ZodDate,
1344
1511
  ...processCreateParams(params),
1345
1512
  });
1346
1513
  };
1514
+ class ZodSymbol extends ZodType {
1515
+ _parse(input) {
1516
+ const parsedType = this._getType(input);
1517
+ if (parsedType !== ZodParsedType.symbol) {
1518
+ const ctx = this._getOrReturnCtx(input);
1519
+ addIssueToContext(ctx, {
1520
+ code: ZodIssueCode.invalid_type,
1521
+ expected: ZodParsedType.symbol,
1522
+ received: ctx.parsedType,
1523
+ });
1524
+ return INVALID;
1525
+ }
1526
+ return OK(input.data);
1527
+ }
1528
+ }
1529
+ ZodSymbol.create = (params) => {
1530
+ return new ZodSymbol({
1531
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
1532
+ ...processCreateParams(params),
1533
+ });
1534
+ };
1347
1535
  class ZodUndefined extends ZodType {
1348
1536
  _parse(input) {
1349
1537
  const parsedType = this._getType(input);
@@ -1468,6 +1656,22 @@ class ZodArray extends ZodType {
1468
1656
  });
1469
1657
  return INVALID;
1470
1658
  }
1659
+ if (def.exactLength !== null) {
1660
+ const tooBig = ctx.data.length > def.exactLength.value;
1661
+ const tooSmall = ctx.data.length < def.exactLength.value;
1662
+ if (tooBig || tooSmall) {
1663
+ addIssueToContext(ctx, {
1664
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
1665
+ minimum: (tooSmall ? def.exactLength.value : undefined),
1666
+ maximum: (tooBig ? def.exactLength.value : undefined),
1667
+ type: "array",
1668
+ inclusive: true,
1669
+ exact: true,
1670
+ message: def.exactLength.message,
1671
+ });
1672
+ status.dirty();
1673
+ }
1674
+ }
1471
1675
  if (def.minLength !== null) {
1472
1676
  if (ctx.data.length < def.minLength.value) {
1473
1677
  addIssueToContext(ctx, {
@@ -1475,6 +1679,7 @@ class ZodArray extends ZodType {
1475
1679
  minimum: def.minLength.value,
1476
1680
  type: "array",
1477
1681
  inclusive: true,
1682
+ exact: false,
1478
1683
  message: def.minLength.message,
1479
1684
  });
1480
1685
  status.dirty();
@@ -1487,6 +1692,7 @@ class ZodArray extends ZodType {
1487
1692
  maximum: def.maxLength.value,
1488
1693
  type: "array",
1489
1694
  inclusive: true,
1695
+ exact: false,
1490
1696
  message: def.maxLength.message,
1491
1697
  });
1492
1698
  status.dirty();
@@ -1520,7 +1726,10 @@ class ZodArray extends ZodType {
1520
1726
  });
1521
1727
  }
1522
1728
  length(len, message) {
1523
- return this.min(len, message).max(len, message);
1729
+ return new ZodArray({
1730
+ ...this._def,
1731
+ exactLength: { value: len, message: errorUtil.toString(message) },
1732
+ });
1524
1733
  }
1525
1734
  nonempty(message) {
1526
1735
  return this.min(1, message);
@@ -1531,6 +1740,7 @@ ZodArray.create = (schema, params) => {
1531
1740
  type: schema,
1532
1741
  minLength: null,
1533
1742
  maxLength: null,
1743
+ exactLength: null,
1534
1744
  typeName: ZodFirstPartyTypeKind.ZodArray,
1535
1745
  ...processCreateParams(params),
1536
1746
  });
@@ -1547,7 +1757,7 @@ var objectUtil;
1547
1757
  objectUtil.mergeShapes = (first, second) => {
1548
1758
  return {
1549
1759
  ...first,
1550
- ...second,
1760
+ ...second, // second overwrites first
1551
1761
  };
1552
1762
  };
1553
1763
  })(objectUtil || (objectUtil = {}));
@@ -1816,15 +2026,32 @@ class ZodObject extends ZodType {
1816
2026
  shape: () => newShape,
1817
2027
  });
1818
2028
  }
1819
- required() {
2029
+ required(mask) {
1820
2030
  const newShape = {};
1821
- for (const key in this.shape) {
1822
- const fieldSchema = this.shape[key];
1823
- let newField = fieldSchema;
1824
- while (newField instanceof ZodOptional) {
1825
- newField = newField._def.innerType;
2031
+ if (mask) {
2032
+ util.objectKeys(this.shape).map((key) => {
2033
+ if (util.objectKeys(mask).indexOf(key) === -1) {
2034
+ newShape[key] = this.shape[key];
2035
+ }
2036
+ else {
2037
+ const fieldSchema = this.shape[key];
2038
+ let newField = fieldSchema;
2039
+ while (newField instanceof ZodOptional) {
2040
+ newField = newField._def.innerType;
2041
+ }
2042
+ newShape[key] = newField;
2043
+ }
2044
+ });
2045
+ }
2046
+ else {
2047
+ for (const key in this.shape) {
2048
+ const fieldSchema = this.shape[key];
2049
+ let newField = fieldSchema;
2050
+ while (newField instanceof ZodOptional) {
2051
+ newField = newField._def.innerType;
2052
+ }
2053
+ newShape[key] = newField;
1826
2054
  }
1827
- newShape[key] = newField;
1828
2055
  }
1829
2056
  return new ZodObject({
1830
2057
  ...this._def,
@@ -1958,6 +2185,43 @@ ZodUnion.create = (types, params) => {
1958
2185
  ...processCreateParams(params),
1959
2186
  });
1960
2187
  };
2188
+ /////////////////////////////////////////////////////
2189
+ /////////////////////////////////////////////////////
2190
+ ////////// //////////
2191
+ ////////// ZodDiscriminatedUnion //////////
2192
+ ////////// //////////
2193
+ /////////////////////////////////////////////////////
2194
+ /////////////////////////////////////////////////////
2195
+ const getDiscriminator = (type) => {
2196
+ if (type instanceof ZodLazy) {
2197
+ return getDiscriminator(type.schema);
2198
+ }
2199
+ else if (type instanceof ZodEffects) {
2200
+ return getDiscriminator(type.innerType());
2201
+ }
2202
+ else if (type instanceof ZodLiteral) {
2203
+ return [type.value];
2204
+ }
2205
+ else if (type instanceof ZodEnum) {
2206
+ return type.options;
2207
+ }
2208
+ else if (type instanceof ZodNativeEnum) {
2209
+ // eslint-disable-next-line ban/ban
2210
+ return Object.keys(type.enum);
2211
+ }
2212
+ else if (type instanceof ZodDefault) {
2213
+ return getDiscriminator(type._def.innerType);
2214
+ }
2215
+ else if (type instanceof ZodUndefined) {
2216
+ return [undefined];
2217
+ }
2218
+ else if (type instanceof ZodNull) {
2219
+ return [null];
2220
+ }
2221
+ else {
2222
+ return null;
2223
+ }
2224
+ };
1961
2225
  class ZodDiscriminatedUnion extends ZodType {
1962
2226
  _parse(input) {
1963
2227
  const { ctx } = this._processInputParams(input);
@@ -1971,11 +2235,11 @@ class ZodDiscriminatedUnion extends ZodType {
1971
2235
  }
1972
2236
  const discriminator = this.discriminator;
1973
2237
  const discriminatorValue = ctx.data[discriminator];
1974
- const option = this.options.get(discriminatorValue);
2238
+ const option = this.optionsMap.get(discriminatorValue);
1975
2239
  if (!option) {
1976
2240
  addIssueToContext(ctx, {
1977
2241
  code: ZodIssueCode.invalid_union_discriminator,
1978
- options: this.validDiscriminatorValues,
2242
+ options: Array.from(this.optionsMap.keys()),
1979
2243
  path: [discriminator],
1980
2244
  });
1981
2245
  return INVALID;
@@ -1998,12 +2262,12 @@ class ZodDiscriminatedUnion extends ZodType {
1998
2262
  get discriminator() {
1999
2263
  return this._def.discriminator;
2000
2264
  }
2001
- get validDiscriminatorValues() {
2002
- return Array.from(this.options.keys());
2003
- }
2004
2265
  get options() {
2005
2266
  return this._def.options;
2006
2267
  }
2268
+ get optionsMap() {
2269
+ return this._def.optionsMap;
2270
+ }
2007
2271
  /**
2008
2272
  * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2009
2273
  * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
@@ -2012,26 +2276,27 @@ class ZodDiscriminatedUnion extends ZodType {
2012
2276
  * @param types an array of object schemas
2013
2277
  * @param params
2014
2278
  */
2015
- static create(discriminator, types, params) {
2279
+ static create(discriminator, options, params) {
2016
2280
  // Get all the valid discriminator values
2017
- const options = new Map();
2018
- try {
2019
- types.forEach((type) => {
2020
- const discriminatorValue = type.shape[discriminator].value;
2021
- options.set(discriminatorValue, type);
2022
- });
2023
- }
2024
- catch (e) {
2025
- throw new Error("The discriminator value could not be extracted from all the provided schemas");
2026
- }
2027
- // Assert that all the discriminator values are unique
2028
- if (options.size !== types.length) {
2029
- throw new Error("Some of the discriminator values are not unique");
2281
+ const optionsMap = new Map();
2282
+ // try {
2283
+ for (const type of options) {
2284
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2285
+ if (!discriminatorValues) {
2286
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2287
+ }
2288
+ for (const value of discriminatorValues) {
2289
+ if (optionsMap.has(value)) {
2290
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2291
+ }
2292
+ optionsMap.set(value, type);
2293
+ }
2030
2294
  }
2031
2295
  return new ZodDiscriminatedUnion({
2032
2296
  typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2033
2297
  discriminator,
2034
2298
  options,
2299
+ optionsMap,
2035
2300
  ...processCreateParams(params),
2036
2301
  });
2037
2302
  }
@@ -2152,6 +2417,7 @@ class ZodTuple extends ZodType {
2152
2417
  code: ZodIssueCode.too_small,
2153
2418
  minimum: this._def.items.length,
2154
2419
  inclusive: true,
2420
+ exact: false,
2155
2421
  type: "array",
2156
2422
  });
2157
2423
  return INVALID;
@@ -2162,6 +2428,7 @@ class ZodTuple extends ZodType {
2162
2428
  code: ZodIssueCode.too_big,
2163
2429
  maximum: this._def.items.length,
2164
2430
  inclusive: true,
2431
+ exact: false,
2165
2432
  type: "array",
2166
2433
  });
2167
2434
  status.dirty();
@@ -2337,6 +2604,7 @@ class ZodSet extends ZodType {
2337
2604
  minimum: def.minSize.value,
2338
2605
  type: "set",
2339
2606
  inclusive: true,
2607
+ exact: false,
2340
2608
  message: def.minSize.message,
2341
2609
  });
2342
2610
  status.dirty();
@@ -2349,6 +2617,7 @@ class ZodSet extends ZodType {
2349
2617
  maximum: def.maxSize.value,
2350
2618
  type: "set",
2351
2619
  inclusive: true,
2620
+ exact: false,
2352
2621
  message: def.maxSize.message,
2353
2622
  });
2354
2623
  status.dirty();
@@ -2689,6 +2958,11 @@ class ZodEffects extends ZodType {
2689
2958
  innerType() {
2690
2959
  return this._def.schema;
2691
2960
  }
2961
+ sourceType() {
2962
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects
2963
+ ? this._def.schema.sourceType()
2964
+ : this._def.schema;
2965
+ }
2692
2966
  _parse(input) {
2693
2967
  const { status, ctx } = this._processInputParams(input);
2694
2968
  const effect = this._def.effect || null;
@@ -2875,9 +3149,49 @@ class ZodDefault extends ZodType {
2875
3149
  }
2876
3150
  }
2877
3151
  ZodDefault.create = (type, params) => {
2878
- return new ZodOptional({
3152
+ return new ZodDefault({
2879
3153
  innerType: type,
2880
- typeName: ZodFirstPartyTypeKind.ZodOptional,
3154
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3155
+ defaultValue: typeof params.default === "function"
3156
+ ? params.default
3157
+ : () => params.default,
3158
+ ...processCreateParams(params),
3159
+ });
3160
+ };
3161
+ class ZodCatch extends ZodType {
3162
+ _parse(input) {
3163
+ const { ctx } = this._processInputParams(input);
3164
+ const result = this._def.innerType._parse({
3165
+ data: ctx.data,
3166
+ path: ctx.path,
3167
+ parent: ctx,
3168
+ });
3169
+ if (isAsync(result)) {
3170
+ return result.then((result) => {
3171
+ return {
3172
+ status: "valid",
3173
+ value: result.status === "valid" ? result.value : this._def.defaultValue(),
3174
+ };
3175
+ });
3176
+ }
3177
+ else {
3178
+ return {
3179
+ status: "valid",
3180
+ value: result.status === "valid" ? result.value : this._def.defaultValue(),
3181
+ };
3182
+ }
3183
+ }
3184
+ removeDefault() {
3185
+ return this._def.innerType;
3186
+ }
3187
+ }
3188
+ ZodCatch.create = (type, params) => {
3189
+ return new ZodCatch({
3190
+ innerType: type,
3191
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3192
+ defaultValue: typeof params.default === "function"
3193
+ ? params.default
3194
+ : () => params.default,
2881
3195
  ...processCreateParams(params),
2882
3196
  });
2883
3197
  };
@@ -2917,6 +3231,64 @@ class ZodBranded extends ZodType {
2917
3231
  return this._def.type;
2918
3232
  }
2919
3233
  }
3234
+ class ZodPipeline extends ZodType {
3235
+ _parse(input) {
3236
+ const { status, ctx } = this._processInputParams(input);
3237
+ if (ctx.common.async) {
3238
+ const handleAsync = async () => {
3239
+ const inResult = await this._def.in._parseAsync({
3240
+ data: ctx.data,
3241
+ path: ctx.path,
3242
+ parent: ctx,
3243
+ });
3244
+ if (inResult.status === "aborted")
3245
+ return INVALID;
3246
+ if (inResult.status === "dirty") {
3247
+ status.dirty();
3248
+ return DIRTY(inResult.value);
3249
+ }
3250
+ else {
3251
+ return this._def.out._parseAsync({
3252
+ data: inResult.value,
3253
+ path: ctx.path,
3254
+ parent: ctx,
3255
+ });
3256
+ }
3257
+ };
3258
+ return handleAsync();
3259
+ }
3260
+ else {
3261
+ const inResult = this._def.in._parseSync({
3262
+ data: ctx.data,
3263
+ path: ctx.path,
3264
+ parent: ctx,
3265
+ });
3266
+ if (inResult.status === "aborted")
3267
+ return INVALID;
3268
+ if (inResult.status === "dirty") {
3269
+ status.dirty();
3270
+ return {
3271
+ status: "dirty",
3272
+ value: inResult.value,
3273
+ };
3274
+ }
3275
+ else {
3276
+ return this._def.out._parseSync({
3277
+ data: inResult.value,
3278
+ path: ctx.path,
3279
+ parent: ctx,
3280
+ });
3281
+ }
3282
+ }
3283
+ }
3284
+ static create(a, b) {
3285
+ return new ZodPipeline({
3286
+ in: a,
3287
+ out: b,
3288
+ typeName: ZodFirstPartyTypeKind.ZodPipeline,
3289
+ });
3290
+ }
3291
+ }
2920
3292
  const custom = (check, params = {}, fatal) => {
2921
3293
  if (check)
2922
3294
  return ZodAny.create().superRefine((data, ctx) => {
@@ -2939,6 +3311,7 @@ var ZodFirstPartyTypeKind;
2939
3311
  ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
2940
3312
  ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
2941
3313
  ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
3314
+ ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
2942
3315
  ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
2943
3316
  ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
2944
3317
  ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
@@ -2963,16 +3336,14 @@ var ZodFirstPartyTypeKind;
2963
3336
  ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
2964
3337
  ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
2965
3338
  ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
3339
+ ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
2966
3340
  ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
2967
3341
  ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
3342
+ ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
2968
3343
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
2969
- // new approach that works for abstract classes
2970
- // but required TS 4.4+
2971
- // abstract class Class {
2972
- // constructor(..._: any[]) {}
2973
- // }
2974
- // const instanceOfType = <T extends typeof Class>(
2975
- const instanceOfType = (cls, params = {
3344
+ const instanceOfType = (
3345
+ // const instanceOfType = <T extends new (...args: any[]) => any>(
3346
+ cls, params = {
2976
3347
  message: `Input not instance of ${cls.name}`,
2977
3348
  }) => custom((data) => data instanceof cls, params, true);
2978
3349
  const stringType = ZodString.create;
@@ -2981,6 +3352,7 @@ const nanType = ZodNaN.create;
2981
3352
  const bigIntType = ZodBigInt.create;
2982
3353
  const booleanType = ZodBoolean.create;
2983
3354
  const dateType = ZodDate.create;
3355
+ const symbolType = ZodSymbol.create;
2984
3356
  const undefinedType = ZodUndefined.create;
2985
3357
  const nullType = ZodNull.create;
2986
3358
  const anyType = ZodAny.create;
@@ -3007,15 +3379,21 @@ const effectsType = ZodEffects.create;
3007
3379
  const optionalType = ZodOptional.create;
3008
3380
  const nullableType = ZodNullable.create;
3009
3381
  const preprocessType = ZodEffects.createWithPreprocess;
3382
+ const pipelineType = ZodPipeline.create;
3010
3383
  const ostring = () => stringType().optional();
3011
3384
  const onumber = () => numberType().optional();
3012
3385
  const oboolean = () => booleanType().optional();
3386
+ const coerce = {
3387
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
3388
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
3389
+ boolean: ((arg) => ZodBoolean.create({ ...arg, coerce: true })),
3390
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
3391
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true })),
3392
+ };
3013
3393
  const NEVER = INVALID;
3014
3394
 
3015
3395
  var mod = /*#__PURE__*/Object.freeze({
3016
3396
  __proto__: null,
3017
- getParsedType: getParsedType,
3018
- ZodParsedType: ZodParsedType,
3019
3397
  defaultErrorMap: errorMap,
3020
3398
  setErrorMap: setErrorMap,
3021
3399
  getErrorMap: getErrorMap,
@@ -3030,12 +3408,16 @@ var mod = /*#__PURE__*/Object.freeze({
3030
3408
  isDirty: isDirty,
3031
3409
  isValid: isValid,
3032
3410
  isAsync: isAsync,
3411
+ get util () { return util; },
3412
+ ZodParsedType: ZodParsedType,
3413
+ getParsedType: getParsedType,
3033
3414
  ZodType: ZodType,
3034
3415
  ZodString: ZodString,
3035
3416
  ZodNumber: ZodNumber,
3036
3417
  ZodBigInt: ZodBigInt,
3037
3418
  ZodBoolean: ZodBoolean,
3038
3419
  ZodDate: ZodDate,
3420
+ ZodSymbol: ZodSymbol,
3039
3421
  ZodUndefined: ZodUndefined,
3040
3422
  ZodNull: ZodNull,
3041
3423
  ZodAny: ZodAny,
@@ -3063,14 +3445,17 @@ var mod = /*#__PURE__*/Object.freeze({
3063
3445
  ZodOptional: ZodOptional,
3064
3446
  ZodNullable: ZodNullable,
3065
3447
  ZodDefault: ZodDefault,
3448
+ ZodCatch: ZodCatch,
3066
3449
  ZodNaN: ZodNaN,
3067
3450
  BRAND: BRAND,
3068
3451
  ZodBranded: ZodBranded,
3452
+ ZodPipeline: ZodPipeline,
3069
3453
  custom: custom,
3070
3454
  Schema: ZodType,
3071
3455
  ZodSchema: ZodType,
3072
3456
  late: late,
3073
3457
  get ZodFirstPartyTypeKind () { return ZodFirstPartyTypeKind; },
3458
+ coerce: coerce,
3074
3459
  any: anyType,
3075
3460
  array: arrayType,
3076
3461
  bigint: bigIntType,
@@ -3096,12 +3481,14 @@ var mod = /*#__PURE__*/Object.freeze({
3096
3481
  onumber: onumber,
3097
3482
  optional: optionalType,
3098
3483
  ostring: ostring,
3484
+ pipeline: pipelineType,
3099
3485
  preprocess: preprocessType,
3100
3486
  promise: promiseType,
3101
3487
  record: recordType,
3102
3488
  set: setType,
3103
3489
  strictObject: strictObjectType,
3104
3490
  string: stringType,
3491
+ symbol: symbolType,
3105
3492
  transformer: effectsType,
3106
3493
  tuple: tupleType,
3107
3494
  'undefined': undefinedType,
@@ -3437,70 +3824,55 @@ mod.object({
3437
3824
  });
3438
3825
  mod.object({ id: mod.string(), uri: mod.string() }).catchall(mod.any());
3439
3826
  mod.object({
3827
+ profileId: mod.string().min(3).max(40),
3828
+ displayName: mod.string().default(""),
3829
+ did: mod.string(),
3830
+ email: mod.string().optional(),
3831
+ image: mod.string().optional(),
3832
+ isServiceProfile: mod.boolean().default(false).optional()
3833
+ });
3834
+ mod.object({
3835
+ uri: mod.string(),
3836
+ to: mod.string(),
3837
+ from: mod.string(),
3838
+ sent: mod.string().datetime(),
3839
+ received: mod.string().datetime().optional()
3840
+ });
3841
+ mod.object({
3842
+ uri: mod.string(),
3843
+ name: mod.string().optional(),
3844
+ type: mod.string().optional(),
3845
+ category: mod.string().optional()
3846
+ });
3847
+ var JWKValidator = mod.object({
3440
3848
  kty: mod.string(),
3441
3849
  crv: mod.string(),
3442
3850
  x: mod.string(),
3443
3851
  y: mod.string().optional(),
3852
+ n: mod.string().optional(),
3444
3853
  d: mod.string()
3445
3854
  });
3855
+ var JWERecipientHeaderValidator = mod.object({
3856
+ alg: mod.string(),
3857
+ iv: mod.string(),
3858
+ tag: mod.string(),
3859
+ epk: JWKValidator.partial().optional(),
3860
+ kid: mod.string().optional(),
3861
+ apv: mod.string().optional(),
3862
+ apu: mod.string().optional()
3863
+ });
3864
+ var JWERecipientValidator = mod.object({
3865
+ header: JWERecipientHeaderValidator,
3866
+ encrypted_key: mod.string()
3867
+ });
3868
+ mod.object({
3869
+ protected: mod.string(),
3870
+ iv: mod.string(),
3871
+ ciphertext: mod.string(),
3872
+ tag: mod.string(),
3873
+ aad: mod.string().optional(),
3874
+ recipients: JWERecipientValidator.array().optional()
3875
+ });
3446
3876
 
3447
- const StatusToBgColor = {
3448
- [VerificationStatusEnum.Success]: "bg-emerald-500",
3449
- [VerificationStatusEnum.Failed]: "bg-yellow-400",
3450
- [VerificationStatusEnum.Error]: "bg-rose-600"
3451
- };
3452
- const StatusToTextColor = {
3453
- [VerificationStatusEnum.Success]: "text-emerald-700",
3454
- [VerificationStatusEnum.Failed]: "text-yellow-400",
3455
- [VerificationStatusEnum.Error]: "text-rose-600"
3456
- };
3457
- const StatusToIcon = {
3458
- [VerificationStatusEnum.Success]: VerificationPassedIcon__default["default"],
3459
- [VerificationStatusEnum.Failed]: VerificationWarningIcon__default["default"],
3460
- [VerificationStatusEnum.Error]: VerificationFailedIcon__default["default"]
3461
- };
3462
- const StatusToText = {
3463
- [VerificationStatusEnum.Success]: "Verification Success",
3464
- [VerificationStatusEnum.Error]: "Verification Error ",
3465
- [VerificationStatusEnum.Failed]: "Verification Failed"
3466
- };
3467
- const ValidationStateIndicator = ({ status }) => {
3468
- const bgColor = StatusToBgColor[status];
3469
- const source = StatusToIcon[status];
3470
- return /* @__PURE__ */ React__default["default"].createElement("div", {
3471
- className: `relative rounded-full w-[30px] h-[30px] ${bgColor}`
3472
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3473
- className: "relative w-[100%] h-[100%] flex items-center justify-center rounded-[50%] bg-white rounded-full overflow-hidden"
3474
- }, /* @__PURE__ */ React__default["default"].createElement("img", {
3475
- className: "h-full w-full object-contain p-1",
3476
- src: source != null ? source : "",
3477
- alt: "Verification Status Icon"
3478
- })));
3479
- };
3480
- const VCVerificationPill = ({
3481
- message = "",
3482
- details,
3483
- status = VerificationStatusEnum.Success
3484
- }) => {
3485
- const statusColor = StatusToTextColor[status];
3486
- const statusInfoText = StatusToText[status];
3487
- return /* @__PURE__ */ React__default["default"].createElement("section", {
3488
- className: "flex width-full bg-white p-2 px-5 my-3.5 justify-between items-center relative vc-verification-checklist-pill rounded-[22px]"
3489
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
3490
- className: "vc-pill-left"
3491
- }, /* @__PURE__ */ React__default["default"].createElement("p", {
3492
- className: `text-[10px] font-bold status-text uppercase ${statusColor}`
3493
- }, statusInfoText), /* @__PURE__ */ React__default["default"].createElement("p", {
3494
- className: "text-[12px] text-grayscale-900 vc-pill-text"
3495
- }, message), details && /* @__PURE__ */ React__default["default"].createElement("p", {
3496
- className: "text-[12px] text-gray-600"
3497
- }, " ", details)), /* @__PURE__ */ React__default["default"].createElement("div", {
3498
- className: "vc-pill-right"
3499
- }, /* @__PURE__ */ React__default["default"].createElement(ValidationStateIndicator, {
3500
- status
3501
- })));
3502
- };
3503
-
3504
- exports.VCVerificationPill = VCVerificationPill;
3505
- exports.ValidationStateIndicator = ValidationStateIndicator;
3506
- //# sourceMappingURL=VCVerificationPill-9e8e4264.js.map
3877
+ exports.VerificationStatusEnum = VerificationStatusEnum;
3878
+ //# sourceMappingURL=types.esm-c09dbd3b.js.map