@learncard/react 2.4.0 → 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 (83) hide show
  1. package/dist/cjs/{FlippyCard-2cbe2dbe.js → FlippyCard-209549c5.js} +2 -2
  2. package/dist/cjs/FlippyCard-209549c5.js.map +1 -0
  3. package/dist/cjs/{LearnCardCreditCardFrontFace-4452fd7a.js → LearnCardCreditCardFrontFace-4ce0d049.js} +2 -2
  4. package/dist/cjs/{LearnCardCreditCardFrontFace-4452fd7a.js.map → LearnCardCreditCardFrontFace-4ce0d049.js.map} +1 -1
  5. package/dist/cjs/{Notification-10b40c07.js → Notification-88cc727a.js} +24 -8
  6. package/dist/cjs/Notification-88cc727a.js.map +1 -0
  7. package/dist/cjs/{QRCodeCard-efaa58e1.js → QRCodeCard-b60c0500.js} +2 -2
  8. package/dist/cjs/{QRCodeCard-efaa58e1.js.map → QRCodeCard-b60c0500.js.map} +1 -1
  9. package/dist/cjs/SchoolIDCard-1baf77e8.js.map +1 -1
  10. package/dist/cjs/{VCCard-32c759a8.js → VCCard-9c328aba.js} +3 -3
  11. package/dist/cjs/{VCCard-32c759a8.js.map → VCCard-9c328aba.js.map} +1 -1
  12. package/dist/cjs/{VCDisplayBackFace-128b5cb2.js → VCDisplayBackFace-f10d3acc.js} +3 -3
  13. package/dist/cjs/{VCDisplayBackFace-128b5cb2.js.map → VCDisplayBackFace-f10d3acc.js.map} +1 -1
  14. package/dist/cjs/{VCDisplayCard-77133b71.js → VCDisplayCard-641cc1de.js} +4 -4
  15. package/dist/cjs/{VCDisplayCard-77133b71.js.map → VCDisplayCard-641cc1de.js.map} +1 -1
  16. package/dist/cjs/{VCDisplayCard2-a0a66aa6.js → VCDisplayCard2-ddc332ce.js} +3 -3
  17. package/dist/cjs/{VCDisplayCard2-a0a66aa6.js.map → VCDisplayCard2-ddc332ce.js.map} +1 -1
  18. package/dist/cjs/{VCVerificationPill-66e2a90f.js → VCVerificationPill-f322ffef.js} +2 -2
  19. package/dist/cjs/{VCVerificationPill-66e2a90f.js.map → VCVerificationPill-f322ffef.js.map} +1 -1
  20. package/dist/cjs/{credential.helpers-7f7b9b02.js → credential.helpers-da5d874e.js} +2 -2
  21. package/dist/cjs/{credential.helpers-7f7b9b02.js.map → credential.helpers-da5d874e.js.map} +1 -1
  22. package/dist/cjs/{index-82de573c.js → index-c340a7f0.js} +1 -1
  23. package/dist/{esm/index-aa1098e1.js.map → cjs/index-c340a7f0.js.map} +1 -1
  24. package/dist/cjs/index.js +12 -12
  25. package/dist/cjs/index10.js +12 -12
  26. package/dist/cjs/index14.js +2 -2
  27. package/dist/cjs/index18.js +1 -1
  28. package/dist/cjs/index19.js +2 -2
  29. package/dist/cjs/index29.js +8 -8
  30. package/dist/cjs/index30.js +4 -4
  31. package/dist/cjs/index31.js +6 -6
  32. package/dist/cjs/index32.js +3 -3
  33. package/dist/cjs/index33.js +1 -1
  34. package/dist/cjs/index36.js +2 -2
  35. package/dist/cjs/index8.js +1 -1
  36. package/dist/cjs/{types.esm-034454a2.js → types.esm-c09dbd3b.js} +494 -52
  37. package/dist/cjs/types.esm-c09dbd3b.js.map +1 -0
  38. package/dist/esm/{FlippyCard-f4f0b3f8.js → FlippyCard-a2de5cf1.js} +2 -2
  39. package/dist/esm/FlippyCard-a2de5cf1.js.map +1 -0
  40. package/dist/esm/{LearnCardCreditCardFrontFace-cf793917.js → LearnCardCreditCardFrontFace-c221facc.js} +2 -2
  41. package/dist/esm/{LearnCardCreditCardFrontFace-cf793917.js.map → LearnCardCreditCardFrontFace-c221facc.js.map} +1 -1
  42. package/dist/esm/{Notification-ac50790d.js → Notification-75f2b46f.js} +25 -9
  43. package/dist/esm/Notification-75f2b46f.js.map +1 -0
  44. package/dist/esm/{QRCodeCard-c57e2067.js → QRCodeCard-d147d009.js} +2 -2
  45. package/dist/esm/{QRCodeCard-c57e2067.js.map → QRCodeCard-d147d009.js.map} +1 -1
  46. package/dist/esm/SchoolIDCard-3b746226.js.map +1 -1
  47. package/dist/esm/{VCCard-c4096573.js → VCCard-ac061e87.js} +3 -3
  48. package/dist/esm/{VCCard-c4096573.js.map → VCCard-ac061e87.js.map} +1 -1
  49. package/dist/esm/{VCDisplayBackFace-853b8fdf.js → VCDisplayBackFace-dbf68095.js} +3 -3
  50. package/dist/esm/{VCDisplayBackFace-853b8fdf.js.map → VCDisplayBackFace-dbf68095.js.map} +1 -1
  51. package/dist/esm/{VCDisplayCard-be496708.js → VCDisplayCard-ec21dfe8.js} +4 -4
  52. package/dist/esm/{VCDisplayCard-be496708.js.map → VCDisplayCard-ec21dfe8.js.map} +1 -1
  53. package/dist/esm/{VCDisplayCard2-c8e96ce8.js → VCDisplayCard2-50e1a81a.js} +3 -3
  54. package/dist/esm/{VCDisplayCard2-c8e96ce8.js.map → VCDisplayCard2-50e1a81a.js.map} +1 -1
  55. package/dist/esm/{VCVerificationPill-fc7b53d0.js → VCVerificationPill-9559507a.js} +2 -2
  56. package/dist/esm/{VCVerificationPill-fc7b53d0.js.map → VCVerificationPill-9559507a.js.map} +1 -1
  57. package/dist/esm/{credential.helpers-78d3c24a.js → credential.helpers-fbf88b8c.js} +2 -2
  58. package/dist/esm/{credential.helpers-78d3c24a.js.map → credential.helpers-fbf88b8c.js.map} +1 -1
  59. package/dist/esm/{index-aa1098e1.js → index-54ccc558.js} +1 -1
  60. package/dist/esm/index-54ccc558.js.map +1 -0
  61. package/dist/esm/index.js +12 -12
  62. package/dist/esm/index10.js +12 -12
  63. package/dist/esm/index14.js +2 -2
  64. package/dist/esm/index18.js +1 -1
  65. package/dist/esm/index19.js +2 -2
  66. package/dist/esm/index29.js +8 -8
  67. package/dist/esm/index30.js +4 -4
  68. package/dist/esm/index31.js +6 -6
  69. package/dist/esm/index32.js +3 -3
  70. package/dist/esm/index33.js +1 -1
  71. package/dist/esm/index36.js +2 -2
  72. package/dist/esm/index8.js +1 -1
  73. package/dist/esm/{types.esm-9db3d858.js → types.esm-9b3b15f7.js} +494 -52
  74. package/dist/esm/types.esm-9b3b15f7.js.map +1 -0
  75. package/dist/index.d.ts +5 -2
  76. package/package.json +4 -4
  77. package/dist/cjs/FlippyCard-2cbe2dbe.js.map +0 -1
  78. package/dist/cjs/Notification-10b40c07.js.map +0 -1
  79. package/dist/cjs/index-82de573c.js.map +0 -1
  80. package/dist/cjs/types.esm-034454a2.js.map +0 -1
  81. package/dist/esm/FlippyCard-f4f0b3f8.js.map +0 -1
  82. package/dist/esm/Notification-ac50790d.js.map +0 -1
  83. package/dist/esm/types.esm-9db3d858.js.map +0 -1
@@ -98,6 +98,8 @@ const getParsedType = (data) => {
98
98
  return ZodParsedType.function;
99
99
  case "bigint":
100
100
  return ZodParsedType.bigint;
101
+ case "symbol":
102
+ return ZodParsedType.symbol;
101
103
  case "object":
102
104
  if (Array.isArray(data)) {
103
105
  return ZodParsedType.array;
@@ -142,6 +144,7 @@ const ZodIssueCode = util.arrayToEnum([
142
144
  "too_big",
143
145
  "invalid_intersection_types",
144
146
  "not_multiple_of",
147
+ "not_finite",
145
148
  ]);
146
149
  const quotelessJson = (obj) => {
147
150
  const json = JSON.stringify(obj, null, 2);
@@ -308,25 +311,41 @@ const errorMap = (issue, _ctx) => {
308
311
  break;
309
312
  case ZodIssueCode.too_small:
310
313
  if (issue.type === "array")
311
- message = `Array must contain ${issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
314
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
312
315
  else if (issue.type === "string")
313
- message = `String must contain ${issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
316
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
314
317
  else if (issue.type === "number")
315
- message = `Number must be greater than ${issue.inclusive ? `or equal to ` : ``}${issue.minimum}`;
318
+ message = `Number must be ${issue.exact
319
+ ? `exactly equal to `
320
+ : issue.inclusive
321
+ ? `greater than or equal to `
322
+ : `greater than `}${issue.minimum}`;
316
323
  else if (issue.type === "date")
317
- message = `Date must be greater than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.minimum)}`;
324
+ message = `Date must be ${issue.exact
325
+ ? `exactly equal to `
326
+ : issue.inclusive
327
+ ? `greater than or equal to `
328
+ : `greater than `}${new Date(issue.minimum)}`;
318
329
  else
319
330
  message = "Invalid input";
320
331
  break;
321
332
  case ZodIssueCode.too_big:
322
333
  if (issue.type === "array")
323
- message = `Array must contain ${issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
334
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
324
335
  else if (issue.type === "string")
325
- message = `String must contain ${issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
336
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
326
337
  else if (issue.type === "number")
327
- message = `Number must be less than ${issue.inclusive ? `or equal to ` : ``}${issue.maximum}`;
338
+ message = `Number must be ${issue.exact
339
+ ? `exactly`
340
+ : issue.inclusive
341
+ ? `less than or equal to`
342
+ : `less than`} ${issue.maximum}`;
328
343
  else if (issue.type === "date")
329
- message = `Date must be smaller than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.maximum)}`;
344
+ message = `Date must be ${issue.exact
345
+ ? `exactly`
346
+ : issue.inclusive
347
+ ? `smaller than or equal to`
348
+ : `smaller than`} ${new Date(issue.maximum)}`;
330
349
  else
331
350
  message = "Invalid input";
332
351
  break;
@@ -339,6 +358,9 @@ const errorMap = (issue, _ctx) => {
339
358
  case ZodIssueCode.not_multiple_of:
340
359
  message = `Number must be a multiple of ${issue.multipleOf}`;
341
360
  break;
361
+ case ZodIssueCode.not_finite:
362
+ message = "Number must be finite";
363
+ break;
342
364
  default:
343
365
  message = _ctx.defaultError;
344
366
  util.assertNever(issue);
@@ -385,7 +407,7 @@ function addIssueToContext(ctx, issueData) {
385
407
  ctx.common.contextualErrorMap,
386
408
  ctx.schemaErrorMap,
387
409
  getErrorMap(),
388
- errorMap,
410
+ errorMap, // then global default map
389
411
  ].filter((x) => !!x),
390
412
  });
391
413
  ctx.common.issues.push(issue);
@@ -504,7 +526,6 @@ class ZodType {
504
526
  constructor(def) {
505
527
  /** Alias of safeParseAsync */
506
528
  this.spa = this.safeParseAsync;
507
- this.superRefine = this._refinement;
508
529
  this._def = def;
509
530
  this.parse = this.parse.bind(this);
510
531
  this.safeParse = this.safeParse.bind(this);
@@ -522,8 +543,11 @@ class ZodType {
522
543
  this.or = this.or.bind(this);
523
544
  this.and = this.and.bind(this);
524
545
  this.transform = this.transform.bind(this);
546
+ this.brand = this.brand.bind(this);
525
547
  this.default = this.default.bind(this);
548
+ this.catch = this.catch.bind(this);
526
549
  this.describe = this.describe.bind(this);
550
+ this.pipe = this.pipe.bind(this);
527
551
  this.isNullable = this.isNullable.bind(this);
528
552
  this.isOptional = this.isOptional.bind(this);
529
553
  }
@@ -609,7 +633,7 @@ class ZodType {
609
633
  data,
610
634
  parsedType: getParsedType(data),
611
635
  };
612
- const maybeAsyncResult = this._parse({ data, path: [], parent: ctx });
636
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
613
637
  const result = await (isAsync(maybeAsyncResult)
614
638
  ? maybeAsyncResult
615
639
  : Promise.resolve(maybeAsyncResult));
@@ -673,6 +697,9 @@ class ZodType {
673
697
  effect: { type: "refinement", refinement },
674
698
  });
675
699
  }
700
+ superRefine(refinement) {
701
+ return this._refinement(refinement);
702
+ }
676
703
  optional() {
677
704
  return ZodOptional.create(this);
678
705
  }
@@ -716,6 +743,14 @@ class ZodType {
716
743
  ...processCreateParams(undefined),
717
744
  });
718
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
+ }
719
754
  describe(description) {
720
755
  const This = this.constructor;
721
756
  return new This({
@@ -723,6 +758,9 @@ class ZodType {
723
758
  description,
724
759
  });
725
760
  }
761
+ pipe(target) {
762
+ return ZodPipeline.create(this, target);
763
+ }
726
764
  isOptional() {
727
765
  return this.safeParse(undefined).success;
728
766
  }
@@ -737,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-
737
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;
738
776
  // eslint-disable-next-line
739
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
+ };
740
811
  class ZodString extends ZodType {
741
812
  constructor() {
742
813
  super(...arguments);
@@ -756,6 +827,9 @@ class ZodString extends ZodType {
756
827
  });
757
828
  }
758
829
  _parse(input) {
830
+ if (this._def.coerce) {
831
+ input.data = String(input.data);
832
+ }
759
833
  const parsedType = this._getType(input);
760
834
  if (parsedType !== ZodParsedType.string) {
761
835
  const ctx = this._getOrReturnCtx(input);
@@ -779,6 +853,7 @@ class ZodString extends ZodType {
779
853
  minimum: check.value,
780
854
  type: "string",
781
855
  inclusive: true,
856
+ exact: false,
782
857
  message: check.message,
783
858
  });
784
859
  status.dirty();
@@ -792,11 +867,40 @@ class ZodString extends ZodType {
792
867
  maximum: check.value,
793
868
  type: "string",
794
869
  inclusive: true,
870
+ exact: false,
795
871
  message: check.message,
796
872
  });
797
873
  status.dirty();
798
874
  }
799
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
+ }
800
904
  else if (check.kind === "email") {
801
905
  if (!emailRegex.test(input.data)) {
802
906
  ctx = this._getOrReturnCtx(input, ctx);
@@ -882,6 +986,18 @@ class ZodString extends ZodType {
882
986
  status.dirty();
883
987
  }
884
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
+ }
885
1001
  else {
886
1002
  util.assertNever(check);
887
1003
  }
@@ -906,6 +1022,23 @@ class ZodString extends ZodType {
906
1022
  cuid(message) {
907
1023
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
908
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
+ }
909
1042
  regex(regex, message) {
910
1043
  return this._addCheck({
911
1044
  kind: "regex",
@@ -942,7 +1075,14 @@ class ZodString extends ZodType {
942
1075
  });
943
1076
  }
944
1077
  length(len, message) {
945
- 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");
946
1086
  }
947
1087
  get isEmail() {
948
1088
  return !!this._def.checks.find((ch) => ch.kind === "email");
@@ -978,9 +1118,11 @@ class ZodString extends ZodType {
978
1118
  }
979
1119
  }
980
1120
  ZodString.create = (params) => {
1121
+ var _a;
981
1122
  return new ZodString({
982
1123
  checks: [],
983
1124
  typeName: ZodFirstPartyTypeKind.ZodString,
1125
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
984
1126
  ...processCreateParams(params),
985
1127
  });
986
1128
  };
@@ -1001,6 +1143,9 @@ class ZodNumber extends ZodType {
1001
1143
  this.step = this.multipleOf;
1002
1144
  }
1003
1145
  _parse(input) {
1146
+ if (this._def.coerce) {
1147
+ input.data = Number(input.data);
1148
+ }
1004
1149
  const parsedType = this._getType(input);
1005
1150
  if (parsedType !== ZodParsedType.number) {
1006
1151
  const ctx = this._getOrReturnCtx(input);
@@ -1037,6 +1182,7 @@ class ZodNumber extends ZodType {
1037
1182
  minimum: check.value,
1038
1183
  type: "number",
1039
1184
  inclusive: check.inclusive,
1185
+ exact: false,
1040
1186
  message: check.message,
1041
1187
  });
1042
1188
  status.dirty();
@@ -1053,6 +1199,7 @@ class ZodNumber extends ZodType {
1053
1199
  maximum: check.value,
1054
1200
  type: "number",
1055
1201
  inclusive: check.inclusive,
1202
+ exact: false,
1056
1203
  message: check.message,
1057
1204
  });
1058
1205
  status.dirty();
@@ -1069,6 +1216,16 @@ class ZodNumber extends ZodType {
1069
1216
  status.dirty();
1070
1217
  }
1071
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
+ }
1072
1229
  else {
1073
1230
  util.assertNever(check);
1074
1231
  }
@@ -1152,6 +1309,12 @@ class ZodNumber extends ZodType {
1152
1309
  message: errorUtil.toString(message),
1153
1310
  });
1154
1311
  }
1312
+ finite(message) {
1313
+ return this._addCheck({
1314
+ kind: "finite",
1315
+ message: errorUtil.toString(message),
1316
+ });
1317
+ }
1155
1318
  get minValue() {
1156
1319
  let min = null;
1157
1320
  for (const ch of this._def.checks) {
@@ -1180,11 +1343,15 @@ ZodNumber.create = (params) => {
1180
1343
  return new ZodNumber({
1181
1344
  checks: [],
1182
1345
  typeName: ZodFirstPartyTypeKind.ZodNumber,
1346
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1183
1347
  ...processCreateParams(params),
1184
1348
  });
1185
1349
  };
1186
1350
  class ZodBigInt extends ZodType {
1187
1351
  _parse(input) {
1352
+ if (this._def.coerce) {
1353
+ input.data = BigInt(input.data);
1354
+ }
1188
1355
  const parsedType = this._getType(input);
1189
1356
  if (parsedType !== ZodParsedType.bigint) {
1190
1357
  const ctx = this._getOrReturnCtx(input);
@@ -1199,13 +1366,18 @@ class ZodBigInt extends ZodType {
1199
1366
  }
1200
1367
  }
1201
1368
  ZodBigInt.create = (params) => {
1369
+ var _a;
1202
1370
  return new ZodBigInt({
1203
1371
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
1372
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1204
1373
  ...processCreateParams(params),
1205
1374
  });
1206
1375
  };
1207
1376
  class ZodBoolean extends ZodType {
1208
1377
  _parse(input) {
1378
+ if (this._def.coerce) {
1379
+ input.data = Boolean(input.data);
1380
+ }
1209
1381
  const parsedType = this._getType(input);
1210
1382
  if (parsedType !== ZodParsedType.boolean) {
1211
1383
  const ctx = this._getOrReturnCtx(input);
@@ -1222,11 +1394,15 @@ class ZodBoolean extends ZodType {
1222
1394
  ZodBoolean.create = (params) => {
1223
1395
  return new ZodBoolean({
1224
1396
  typeName: ZodFirstPartyTypeKind.ZodBoolean,
1397
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1225
1398
  ...processCreateParams(params),
1226
1399
  });
1227
1400
  };
1228
1401
  class ZodDate extends ZodType {
1229
1402
  _parse(input) {
1403
+ if (this._def.coerce) {
1404
+ input.data = new Date(input.data);
1405
+ }
1230
1406
  const parsedType = this._getType(input);
1231
1407
  if (parsedType !== ZodParsedType.date) {
1232
1408
  const ctx = this._getOrReturnCtx(input);
@@ -1254,6 +1430,7 @@ class ZodDate extends ZodType {
1254
1430
  code: ZodIssueCode.too_small,
1255
1431
  message: check.message,
1256
1432
  inclusive: true,
1433
+ exact: false,
1257
1434
  minimum: check.value,
1258
1435
  type: "date",
1259
1436
  });
@@ -1267,6 +1444,7 @@ class ZodDate extends ZodType {
1267
1444
  code: ZodIssueCode.too_big,
1268
1445
  message: check.message,
1269
1446
  inclusive: true,
1447
+ exact: false,
1270
1448
  maximum: check.value,
1271
1449
  type: "date",
1272
1450
  });
@@ -1326,10 +1504,32 @@ class ZodDate extends ZodType {
1326
1504
  ZodDate.create = (params) => {
1327
1505
  return new ZodDate({
1328
1506
  checks: [],
1507
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1329
1508
  typeName: ZodFirstPartyTypeKind.ZodDate,
1330
1509
  ...processCreateParams(params),
1331
1510
  });
1332
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
+ };
1333
1533
  class ZodUndefined extends ZodType {
1334
1534
  _parse(input) {
1335
1535
  const parsedType = this._getType(input);
@@ -1454,6 +1654,22 @@ class ZodArray extends ZodType {
1454
1654
  });
1455
1655
  return INVALID;
1456
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
+ }
1457
1673
  if (def.minLength !== null) {
1458
1674
  if (ctx.data.length < def.minLength.value) {
1459
1675
  addIssueToContext(ctx, {
@@ -1461,6 +1677,7 @@ class ZodArray extends ZodType {
1461
1677
  minimum: def.minLength.value,
1462
1678
  type: "array",
1463
1679
  inclusive: true,
1680
+ exact: false,
1464
1681
  message: def.minLength.message,
1465
1682
  });
1466
1683
  status.dirty();
@@ -1473,6 +1690,7 @@ class ZodArray extends ZodType {
1473
1690
  maximum: def.maxLength.value,
1474
1691
  type: "array",
1475
1692
  inclusive: true,
1693
+ exact: false,
1476
1694
  message: def.maxLength.message,
1477
1695
  });
1478
1696
  status.dirty();
@@ -1506,7 +1724,10 @@ class ZodArray extends ZodType {
1506
1724
  });
1507
1725
  }
1508
1726
  length(len, message) {
1509
- return this.min(len, message).max(len, message);
1727
+ return new ZodArray({
1728
+ ...this._def,
1729
+ exactLength: { value: len, message: errorUtil.toString(message) },
1730
+ });
1510
1731
  }
1511
1732
  nonempty(message) {
1512
1733
  return this.min(1, message);
@@ -1517,6 +1738,7 @@ ZodArray.create = (schema, params) => {
1517
1738
  type: schema,
1518
1739
  minLength: null,
1519
1740
  maxLength: null,
1741
+ exactLength: null,
1520
1742
  typeName: ZodFirstPartyTypeKind.ZodArray,
1521
1743
  ...processCreateParams(params),
1522
1744
  });
@@ -1533,7 +1755,7 @@ var objectUtil;
1533
1755
  objectUtil.mergeShapes = (first, second) => {
1534
1756
  return {
1535
1757
  ...first,
1536
- ...second,
1758
+ ...second, // second overwrites first
1537
1759
  };
1538
1760
  };
1539
1761
  })(objectUtil || (objectUtil = {}));
@@ -1802,15 +2024,32 @@ class ZodObject extends ZodType {
1802
2024
  shape: () => newShape,
1803
2025
  });
1804
2026
  }
1805
- required() {
2027
+ required(mask) {
1806
2028
  const newShape = {};
1807
- for (const key in this.shape) {
1808
- const fieldSchema = this.shape[key];
1809
- let newField = fieldSchema;
1810
- while (newField instanceof ZodOptional) {
1811
- newField = newField._def.innerType;
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;
1812
2052
  }
1813
- newShape[key] = newField;
1814
2053
  }
1815
2054
  return new ZodObject({
1816
2055
  ...this._def,
@@ -1944,6 +2183,43 @@ ZodUnion.create = (types, params) => {
1944
2183
  ...processCreateParams(params),
1945
2184
  });
1946
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
+ };
1947
2223
  class ZodDiscriminatedUnion extends ZodType {
1948
2224
  _parse(input) {
1949
2225
  const { ctx } = this._processInputParams(input);
@@ -1957,11 +2233,11 @@ class ZodDiscriminatedUnion extends ZodType {
1957
2233
  }
1958
2234
  const discriminator = this.discriminator;
1959
2235
  const discriminatorValue = ctx.data[discriminator];
1960
- const option = this.options.get(discriminatorValue);
2236
+ const option = this.optionsMap.get(discriminatorValue);
1961
2237
  if (!option) {
1962
2238
  addIssueToContext(ctx, {
1963
2239
  code: ZodIssueCode.invalid_union_discriminator,
1964
- options: this.validDiscriminatorValues,
2240
+ options: Array.from(this.optionsMap.keys()),
1965
2241
  path: [discriminator],
1966
2242
  });
1967
2243
  return INVALID;
@@ -1984,12 +2260,12 @@ class ZodDiscriminatedUnion extends ZodType {
1984
2260
  get discriminator() {
1985
2261
  return this._def.discriminator;
1986
2262
  }
1987
- get validDiscriminatorValues() {
1988
- return Array.from(this.options.keys());
1989
- }
1990
2263
  get options() {
1991
2264
  return this._def.options;
1992
2265
  }
2266
+ get optionsMap() {
2267
+ return this._def.optionsMap;
2268
+ }
1993
2269
  /**
1994
2270
  * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
1995
2271
  * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
@@ -1998,26 +2274,27 @@ class ZodDiscriminatedUnion extends ZodType {
1998
2274
  * @param types an array of object schemas
1999
2275
  * @param params
2000
2276
  */
2001
- static create(discriminator, types, params) {
2277
+ static create(discriminator, options, params) {
2002
2278
  // Get all the valid discriminator values
2003
- const options = new Map();
2004
- try {
2005
- types.forEach((type) => {
2006
- const discriminatorValue = type.shape[discriminator].value;
2007
- options.set(discriminatorValue, type);
2008
- });
2009
- }
2010
- catch (e) {
2011
- throw new Error("The discriminator value could not be extracted from all the provided schemas");
2012
- }
2013
- // Assert that all the discriminator values are unique
2014
- if (options.size !== types.length) {
2015
- throw new Error("Some of the discriminator values are not unique");
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
+ }
2016
2292
  }
2017
2293
  return new ZodDiscriminatedUnion({
2018
2294
  typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2019
2295
  discriminator,
2020
2296
  options,
2297
+ optionsMap,
2021
2298
  ...processCreateParams(params),
2022
2299
  });
2023
2300
  }
@@ -2138,6 +2415,7 @@ class ZodTuple extends ZodType {
2138
2415
  code: ZodIssueCode.too_small,
2139
2416
  minimum: this._def.items.length,
2140
2417
  inclusive: true,
2418
+ exact: false,
2141
2419
  type: "array",
2142
2420
  });
2143
2421
  return INVALID;
@@ -2148,6 +2426,7 @@ class ZodTuple extends ZodType {
2148
2426
  code: ZodIssueCode.too_big,
2149
2427
  maximum: this._def.items.length,
2150
2428
  inclusive: true,
2429
+ exact: false,
2151
2430
  type: "array",
2152
2431
  });
2153
2432
  status.dirty();
@@ -2323,6 +2602,7 @@ class ZodSet extends ZodType {
2323
2602
  minimum: def.minSize.value,
2324
2603
  type: "set",
2325
2604
  inclusive: true,
2605
+ exact: false,
2326
2606
  message: def.minSize.message,
2327
2607
  });
2328
2608
  status.dirty();
@@ -2335,6 +2615,7 @@ class ZodSet extends ZodType {
2335
2615
  maximum: def.maxSize.value,
2336
2616
  type: "set",
2337
2617
  inclusive: true,
2618
+ exact: false,
2338
2619
  message: def.maxSize.message,
2339
2620
  });
2340
2621
  status.dirty();
@@ -2675,6 +2956,11 @@ class ZodEffects extends ZodType {
2675
2956
  innerType() {
2676
2957
  return this._def.schema;
2677
2958
  }
2959
+ sourceType() {
2960
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects
2961
+ ? this._def.schema.sourceType()
2962
+ : this._def.schema;
2963
+ }
2678
2964
  _parse(input) {
2679
2965
  const { status, ctx } = this._processInputParams(input);
2680
2966
  const effect = this._def.effect || null;
@@ -2861,9 +3147,49 @@ class ZodDefault extends ZodType {
2861
3147
  }
2862
3148
  }
2863
3149
  ZodDefault.create = (type, params) => {
2864
- return new ZodOptional({
3150
+ return new ZodDefault({
2865
3151
  innerType: type,
2866
- 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,
2867
3193
  ...processCreateParams(params),
2868
3194
  });
2869
3195
  };
@@ -2903,6 +3229,64 @@ class ZodBranded extends ZodType {
2903
3229
  return this._def.type;
2904
3230
  }
2905
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
+ }
2906
3290
  const custom = (check, params = {}, fatal) => {
2907
3291
  if (check)
2908
3292
  return ZodAny.create().superRefine((data, ctx) => {
@@ -2925,6 +3309,7 @@ var ZodFirstPartyTypeKind;
2925
3309
  ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
2926
3310
  ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
2927
3311
  ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
3312
+ ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
2928
3313
  ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
2929
3314
  ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
2930
3315
  ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
@@ -2949,16 +3334,14 @@ var ZodFirstPartyTypeKind;
2949
3334
  ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
2950
3335
  ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
2951
3336
  ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
3337
+ ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
2952
3338
  ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
2953
3339
  ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
3340
+ ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
2954
3341
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
2955
- // new approach that works for abstract classes
2956
- // but required TS 4.4+
2957
- // abstract class Class {
2958
- // constructor(..._: any[]) {}
2959
- // }
2960
- // const instanceOfType = <T extends typeof Class>(
2961
- const instanceOfType = (cls, params = {
3342
+ const instanceOfType = (
3343
+ // const instanceOfType = <T extends new (...args: any[]) => any>(
3344
+ cls, params = {
2962
3345
  message: `Input not instance of ${cls.name}`,
2963
3346
  }) => custom((data) => data instanceof cls, params, true);
2964
3347
  const stringType = ZodString.create;
@@ -2967,6 +3350,7 @@ const nanType = ZodNaN.create;
2967
3350
  const bigIntType = ZodBigInt.create;
2968
3351
  const booleanType = ZodBoolean.create;
2969
3352
  const dateType = ZodDate.create;
3353
+ const symbolType = ZodSymbol.create;
2970
3354
  const undefinedType = ZodUndefined.create;
2971
3355
  const nullType = ZodNull.create;
2972
3356
  const anyType = ZodAny.create;
@@ -2993,15 +3377,21 @@ const effectsType = ZodEffects.create;
2993
3377
  const optionalType = ZodOptional.create;
2994
3378
  const nullableType = ZodNullable.create;
2995
3379
  const preprocessType = ZodEffects.createWithPreprocess;
3380
+ const pipelineType = ZodPipeline.create;
2996
3381
  const ostring = () => stringType().optional();
2997
3382
  const onumber = () => numberType().optional();
2998
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
+ };
2999
3391
  const NEVER = INVALID;
3000
3392
 
3001
3393
  var mod = /*#__PURE__*/Object.freeze({
3002
3394
  __proto__: null,
3003
- getParsedType: getParsedType,
3004
- ZodParsedType: ZodParsedType,
3005
3395
  defaultErrorMap: errorMap,
3006
3396
  setErrorMap: setErrorMap,
3007
3397
  getErrorMap: getErrorMap,
@@ -3016,12 +3406,16 @@ var mod = /*#__PURE__*/Object.freeze({
3016
3406
  isDirty: isDirty,
3017
3407
  isValid: isValid,
3018
3408
  isAsync: isAsync,
3409
+ get util () { return util; },
3410
+ ZodParsedType: ZodParsedType,
3411
+ getParsedType: getParsedType,
3019
3412
  ZodType: ZodType,
3020
3413
  ZodString: ZodString,
3021
3414
  ZodNumber: ZodNumber,
3022
3415
  ZodBigInt: ZodBigInt,
3023
3416
  ZodBoolean: ZodBoolean,
3024
3417
  ZodDate: ZodDate,
3418
+ ZodSymbol: ZodSymbol,
3025
3419
  ZodUndefined: ZodUndefined,
3026
3420
  ZodNull: ZodNull,
3027
3421
  ZodAny: ZodAny,
@@ -3049,14 +3443,17 @@ var mod = /*#__PURE__*/Object.freeze({
3049
3443
  ZodOptional: ZodOptional,
3050
3444
  ZodNullable: ZodNullable,
3051
3445
  ZodDefault: ZodDefault,
3446
+ ZodCatch: ZodCatch,
3052
3447
  ZodNaN: ZodNaN,
3053
3448
  BRAND: BRAND,
3054
3449
  ZodBranded: ZodBranded,
3450
+ ZodPipeline: ZodPipeline,
3055
3451
  custom: custom,
3056
3452
  Schema: ZodType,
3057
3453
  ZodSchema: ZodType,
3058
3454
  late: late,
3059
3455
  get ZodFirstPartyTypeKind () { return ZodFirstPartyTypeKind; },
3456
+ coerce: coerce,
3060
3457
  any: anyType,
3061
3458
  array: arrayType,
3062
3459
  bigint: bigIntType,
@@ -3082,12 +3479,14 @@ var mod = /*#__PURE__*/Object.freeze({
3082
3479
  onumber: onumber,
3083
3480
  optional: optionalType,
3084
3481
  ostring: ostring,
3482
+ pipeline: pipelineType,
3085
3483
  preprocess: preprocessType,
3086
3484
  promise: promiseType,
3087
3485
  record: recordType,
3088
3486
  set: setType,
3089
3487
  strictObject: strictObjectType,
3090
3488
  string: stringType,
3489
+ symbol: symbolType,
3091
3490
  transformer: effectsType,
3092
3491
  tuple: tupleType,
3093
3492
  'undefined': undefinedType,
@@ -3423,12 +3822,55 @@ mod.object({
3423
3822
  });
3424
3823
  mod.object({ id: mod.string(), uri: mod.string() }).catchall(mod.any());
3425
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({
3426
3846
  kty: mod.string(),
3427
3847
  crv: mod.string(),
3428
3848
  x: mod.string(),
3429
3849
  y: mod.string().optional(),
3850
+ n: mod.string().optional(),
3430
3851
  d: mod.string()
3431
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
+ });
3432
3874
 
3433
3875
  export { VerificationStatusEnum as V };
3434
- //# sourceMappingURL=types.esm-9db3d858.js.map
3876
+ //# sourceMappingURL=types.esm-9b3b15f7.js.map