@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
@@ -100,6 +100,8 @@ const getParsedType = (data) => {
100
100
  return ZodParsedType.function;
101
101
  case "bigint":
102
102
  return ZodParsedType.bigint;
103
+ case "symbol":
104
+ return ZodParsedType.symbol;
103
105
  case "object":
104
106
  if (Array.isArray(data)) {
105
107
  return ZodParsedType.array;
@@ -144,6 +146,7 @@ const ZodIssueCode = util.arrayToEnum([
144
146
  "too_big",
145
147
  "invalid_intersection_types",
146
148
  "not_multiple_of",
149
+ "not_finite",
147
150
  ]);
148
151
  const quotelessJson = (obj) => {
149
152
  const json = JSON.stringify(obj, null, 2);
@@ -310,25 +313,41 @@ const errorMap = (issue, _ctx) => {
310
313
  break;
311
314
  case ZodIssueCode.too_small:
312
315
  if (issue.type === "array")
313
- 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)`;
314
317
  else if (issue.type === "string")
315
- 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)`;
316
319
  else if (issue.type === "number")
317
- 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}`;
318
325
  else if (issue.type === "date")
319
- 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)}`;
320
331
  else
321
332
  message = "Invalid input";
322
333
  break;
323
334
  case ZodIssueCode.too_big:
324
335
  if (issue.type === "array")
325
- 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)`;
326
337
  else if (issue.type === "string")
327
- 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)`;
328
339
  else if (issue.type === "number")
329
- 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}`;
330
345
  else if (issue.type === "date")
331
- 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)}`;
332
351
  else
333
352
  message = "Invalid input";
334
353
  break;
@@ -341,6 +360,9 @@ const errorMap = (issue, _ctx) => {
341
360
  case ZodIssueCode.not_multiple_of:
342
361
  message = `Number must be a multiple of ${issue.multipleOf}`;
343
362
  break;
363
+ case ZodIssueCode.not_finite:
364
+ message = "Number must be finite";
365
+ break;
344
366
  default:
345
367
  message = _ctx.defaultError;
346
368
  util.assertNever(issue);
@@ -387,7 +409,7 @@ function addIssueToContext(ctx, issueData) {
387
409
  ctx.common.contextualErrorMap,
388
410
  ctx.schemaErrorMap,
389
411
  getErrorMap(),
390
- errorMap,
412
+ errorMap, // then global default map
391
413
  ].filter((x) => !!x),
392
414
  });
393
415
  ctx.common.issues.push(issue);
@@ -506,7 +528,6 @@ class ZodType {
506
528
  constructor(def) {
507
529
  /** Alias of safeParseAsync */
508
530
  this.spa = this.safeParseAsync;
509
- this.superRefine = this._refinement;
510
531
  this._def = def;
511
532
  this.parse = this.parse.bind(this);
512
533
  this.safeParse = this.safeParse.bind(this);
@@ -524,8 +545,11 @@ class ZodType {
524
545
  this.or = this.or.bind(this);
525
546
  this.and = this.and.bind(this);
526
547
  this.transform = this.transform.bind(this);
548
+ this.brand = this.brand.bind(this);
527
549
  this.default = this.default.bind(this);
550
+ this.catch = this.catch.bind(this);
528
551
  this.describe = this.describe.bind(this);
552
+ this.pipe = this.pipe.bind(this);
529
553
  this.isNullable = this.isNullable.bind(this);
530
554
  this.isOptional = this.isOptional.bind(this);
531
555
  }
@@ -611,7 +635,7 @@ class ZodType {
611
635
  data,
612
636
  parsedType: getParsedType(data),
613
637
  };
614
- const maybeAsyncResult = this._parse({ data, path: [], parent: ctx });
638
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
615
639
  const result = await (isAsync(maybeAsyncResult)
616
640
  ? maybeAsyncResult
617
641
  : Promise.resolve(maybeAsyncResult));
@@ -675,6 +699,9 @@ class ZodType {
675
699
  effect: { type: "refinement", refinement },
676
700
  });
677
701
  }
702
+ superRefine(refinement) {
703
+ return this._refinement(refinement);
704
+ }
678
705
  optional() {
679
706
  return ZodOptional.create(this);
680
707
  }
@@ -718,6 +745,14 @@ class ZodType {
718
745
  ...processCreateParams(undefined),
719
746
  });
720
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
+ }
721
756
  describe(description) {
722
757
  const This = this.constructor;
723
758
  return new This({
@@ -725,6 +760,9 @@ class ZodType {
725
760
  description,
726
761
  });
727
762
  }
763
+ pipe(target) {
764
+ return ZodPipeline.create(this, target);
765
+ }
728
766
  isOptional() {
729
767
  return this.safeParse(undefined).success;
730
768
  }
@@ -739,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-
739
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;
740
778
  // eslint-disable-next-line
741
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
+ };
742
813
  class ZodString extends ZodType {
743
814
  constructor() {
744
815
  super(...arguments);
@@ -758,6 +829,9 @@ class ZodString extends ZodType {
758
829
  });
759
830
  }
760
831
  _parse(input) {
832
+ if (this._def.coerce) {
833
+ input.data = String(input.data);
834
+ }
761
835
  const parsedType = this._getType(input);
762
836
  if (parsedType !== ZodParsedType.string) {
763
837
  const ctx = this._getOrReturnCtx(input);
@@ -781,6 +855,7 @@ class ZodString extends ZodType {
781
855
  minimum: check.value,
782
856
  type: "string",
783
857
  inclusive: true,
858
+ exact: false,
784
859
  message: check.message,
785
860
  });
786
861
  status.dirty();
@@ -794,11 +869,40 @@ class ZodString extends ZodType {
794
869
  maximum: check.value,
795
870
  type: "string",
796
871
  inclusive: true,
872
+ exact: false,
797
873
  message: check.message,
798
874
  });
799
875
  status.dirty();
800
876
  }
801
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
+ }
802
906
  else if (check.kind === "email") {
803
907
  if (!emailRegex.test(input.data)) {
804
908
  ctx = this._getOrReturnCtx(input, ctx);
@@ -884,6 +988,18 @@ class ZodString extends ZodType {
884
988
  status.dirty();
885
989
  }
886
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
+ }
887
1003
  else {
888
1004
  util.assertNever(check);
889
1005
  }
@@ -908,6 +1024,23 @@ class ZodString extends ZodType {
908
1024
  cuid(message) {
909
1025
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
910
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
+ }
911
1044
  regex(regex, message) {
912
1045
  return this._addCheck({
913
1046
  kind: "regex",
@@ -944,7 +1077,14 @@ class ZodString extends ZodType {
944
1077
  });
945
1078
  }
946
1079
  length(len, message) {
947
- 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");
948
1088
  }
949
1089
  get isEmail() {
950
1090
  return !!this._def.checks.find((ch) => ch.kind === "email");
@@ -980,9 +1120,11 @@ class ZodString extends ZodType {
980
1120
  }
981
1121
  }
982
1122
  ZodString.create = (params) => {
1123
+ var _a;
983
1124
  return new ZodString({
984
1125
  checks: [],
985
1126
  typeName: ZodFirstPartyTypeKind.ZodString,
1127
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
986
1128
  ...processCreateParams(params),
987
1129
  });
988
1130
  };
@@ -1003,6 +1145,9 @@ class ZodNumber extends ZodType {
1003
1145
  this.step = this.multipleOf;
1004
1146
  }
1005
1147
  _parse(input) {
1148
+ if (this._def.coerce) {
1149
+ input.data = Number(input.data);
1150
+ }
1006
1151
  const parsedType = this._getType(input);
1007
1152
  if (parsedType !== ZodParsedType.number) {
1008
1153
  const ctx = this._getOrReturnCtx(input);
@@ -1039,6 +1184,7 @@ class ZodNumber extends ZodType {
1039
1184
  minimum: check.value,
1040
1185
  type: "number",
1041
1186
  inclusive: check.inclusive,
1187
+ exact: false,
1042
1188
  message: check.message,
1043
1189
  });
1044
1190
  status.dirty();
@@ -1055,6 +1201,7 @@ class ZodNumber extends ZodType {
1055
1201
  maximum: check.value,
1056
1202
  type: "number",
1057
1203
  inclusive: check.inclusive,
1204
+ exact: false,
1058
1205
  message: check.message,
1059
1206
  });
1060
1207
  status.dirty();
@@ -1071,6 +1218,16 @@ class ZodNumber extends ZodType {
1071
1218
  status.dirty();
1072
1219
  }
1073
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
+ }
1074
1231
  else {
1075
1232
  util.assertNever(check);
1076
1233
  }
@@ -1154,6 +1311,12 @@ class ZodNumber extends ZodType {
1154
1311
  message: errorUtil.toString(message),
1155
1312
  });
1156
1313
  }
1314
+ finite(message) {
1315
+ return this._addCheck({
1316
+ kind: "finite",
1317
+ message: errorUtil.toString(message),
1318
+ });
1319
+ }
1157
1320
  get minValue() {
1158
1321
  let min = null;
1159
1322
  for (const ch of this._def.checks) {
@@ -1182,11 +1345,15 @@ ZodNumber.create = (params) => {
1182
1345
  return new ZodNumber({
1183
1346
  checks: [],
1184
1347
  typeName: ZodFirstPartyTypeKind.ZodNumber,
1348
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1185
1349
  ...processCreateParams(params),
1186
1350
  });
1187
1351
  };
1188
1352
  class ZodBigInt extends ZodType {
1189
1353
  _parse(input) {
1354
+ if (this._def.coerce) {
1355
+ input.data = BigInt(input.data);
1356
+ }
1190
1357
  const parsedType = this._getType(input);
1191
1358
  if (parsedType !== ZodParsedType.bigint) {
1192
1359
  const ctx = this._getOrReturnCtx(input);
@@ -1201,13 +1368,18 @@ class ZodBigInt extends ZodType {
1201
1368
  }
1202
1369
  }
1203
1370
  ZodBigInt.create = (params) => {
1371
+ var _a;
1204
1372
  return new ZodBigInt({
1205
1373
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
1374
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1206
1375
  ...processCreateParams(params),
1207
1376
  });
1208
1377
  };
1209
1378
  class ZodBoolean extends ZodType {
1210
1379
  _parse(input) {
1380
+ if (this._def.coerce) {
1381
+ input.data = Boolean(input.data);
1382
+ }
1211
1383
  const parsedType = this._getType(input);
1212
1384
  if (parsedType !== ZodParsedType.boolean) {
1213
1385
  const ctx = this._getOrReturnCtx(input);
@@ -1224,11 +1396,15 @@ class ZodBoolean extends ZodType {
1224
1396
  ZodBoolean.create = (params) => {
1225
1397
  return new ZodBoolean({
1226
1398
  typeName: ZodFirstPartyTypeKind.ZodBoolean,
1399
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1227
1400
  ...processCreateParams(params),
1228
1401
  });
1229
1402
  };
1230
1403
  class ZodDate extends ZodType {
1231
1404
  _parse(input) {
1405
+ if (this._def.coerce) {
1406
+ input.data = new Date(input.data);
1407
+ }
1232
1408
  const parsedType = this._getType(input);
1233
1409
  if (parsedType !== ZodParsedType.date) {
1234
1410
  const ctx = this._getOrReturnCtx(input);
@@ -1256,6 +1432,7 @@ class ZodDate extends ZodType {
1256
1432
  code: ZodIssueCode.too_small,
1257
1433
  message: check.message,
1258
1434
  inclusive: true,
1435
+ exact: false,
1259
1436
  minimum: check.value,
1260
1437
  type: "date",
1261
1438
  });
@@ -1269,6 +1446,7 @@ class ZodDate extends ZodType {
1269
1446
  code: ZodIssueCode.too_big,
1270
1447
  message: check.message,
1271
1448
  inclusive: true,
1449
+ exact: false,
1272
1450
  maximum: check.value,
1273
1451
  type: "date",
1274
1452
  });
@@ -1328,10 +1506,32 @@ class ZodDate extends ZodType {
1328
1506
  ZodDate.create = (params) => {
1329
1507
  return new ZodDate({
1330
1508
  checks: [],
1509
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1331
1510
  typeName: ZodFirstPartyTypeKind.ZodDate,
1332
1511
  ...processCreateParams(params),
1333
1512
  });
1334
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
+ };
1335
1535
  class ZodUndefined extends ZodType {
1336
1536
  _parse(input) {
1337
1537
  const parsedType = this._getType(input);
@@ -1456,6 +1656,22 @@ class ZodArray extends ZodType {
1456
1656
  });
1457
1657
  return INVALID;
1458
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
+ }
1459
1675
  if (def.minLength !== null) {
1460
1676
  if (ctx.data.length < def.minLength.value) {
1461
1677
  addIssueToContext(ctx, {
@@ -1463,6 +1679,7 @@ class ZodArray extends ZodType {
1463
1679
  minimum: def.minLength.value,
1464
1680
  type: "array",
1465
1681
  inclusive: true,
1682
+ exact: false,
1466
1683
  message: def.minLength.message,
1467
1684
  });
1468
1685
  status.dirty();
@@ -1475,6 +1692,7 @@ class ZodArray extends ZodType {
1475
1692
  maximum: def.maxLength.value,
1476
1693
  type: "array",
1477
1694
  inclusive: true,
1695
+ exact: false,
1478
1696
  message: def.maxLength.message,
1479
1697
  });
1480
1698
  status.dirty();
@@ -1508,7 +1726,10 @@ class ZodArray extends ZodType {
1508
1726
  });
1509
1727
  }
1510
1728
  length(len, message) {
1511
- return this.min(len, message).max(len, message);
1729
+ return new ZodArray({
1730
+ ...this._def,
1731
+ exactLength: { value: len, message: errorUtil.toString(message) },
1732
+ });
1512
1733
  }
1513
1734
  nonempty(message) {
1514
1735
  return this.min(1, message);
@@ -1519,6 +1740,7 @@ ZodArray.create = (schema, params) => {
1519
1740
  type: schema,
1520
1741
  minLength: null,
1521
1742
  maxLength: null,
1743
+ exactLength: null,
1522
1744
  typeName: ZodFirstPartyTypeKind.ZodArray,
1523
1745
  ...processCreateParams(params),
1524
1746
  });
@@ -1535,7 +1757,7 @@ var objectUtil;
1535
1757
  objectUtil.mergeShapes = (first, second) => {
1536
1758
  return {
1537
1759
  ...first,
1538
- ...second,
1760
+ ...second, // second overwrites first
1539
1761
  };
1540
1762
  };
1541
1763
  })(objectUtil || (objectUtil = {}));
@@ -1804,15 +2026,32 @@ class ZodObject extends ZodType {
1804
2026
  shape: () => newShape,
1805
2027
  });
1806
2028
  }
1807
- required() {
2029
+ required(mask) {
1808
2030
  const newShape = {};
1809
- for (const key in this.shape) {
1810
- const fieldSchema = this.shape[key];
1811
- let newField = fieldSchema;
1812
- while (newField instanceof ZodOptional) {
1813
- 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;
1814
2054
  }
1815
- newShape[key] = newField;
1816
2055
  }
1817
2056
  return new ZodObject({
1818
2057
  ...this._def,
@@ -1946,6 +2185,43 @@ ZodUnion.create = (types, params) => {
1946
2185
  ...processCreateParams(params),
1947
2186
  });
1948
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
+ };
1949
2225
  class ZodDiscriminatedUnion extends ZodType {
1950
2226
  _parse(input) {
1951
2227
  const { ctx } = this._processInputParams(input);
@@ -1959,11 +2235,11 @@ class ZodDiscriminatedUnion extends ZodType {
1959
2235
  }
1960
2236
  const discriminator = this.discriminator;
1961
2237
  const discriminatorValue = ctx.data[discriminator];
1962
- const option = this.options.get(discriminatorValue);
2238
+ const option = this.optionsMap.get(discriminatorValue);
1963
2239
  if (!option) {
1964
2240
  addIssueToContext(ctx, {
1965
2241
  code: ZodIssueCode.invalid_union_discriminator,
1966
- options: this.validDiscriminatorValues,
2242
+ options: Array.from(this.optionsMap.keys()),
1967
2243
  path: [discriminator],
1968
2244
  });
1969
2245
  return INVALID;
@@ -1986,12 +2262,12 @@ class ZodDiscriminatedUnion extends ZodType {
1986
2262
  get discriminator() {
1987
2263
  return this._def.discriminator;
1988
2264
  }
1989
- get validDiscriminatorValues() {
1990
- return Array.from(this.options.keys());
1991
- }
1992
2265
  get options() {
1993
2266
  return this._def.options;
1994
2267
  }
2268
+ get optionsMap() {
2269
+ return this._def.optionsMap;
2270
+ }
1995
2271
  /**
1996
2272
  * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
1997
2273
  * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
@@ -2000,26 +2276,27 @@ class ZodDiscriminatedUnion extends ZodType {
2000
2276
  * @param types an array of object schemas
2001
2277
  * @param params
2002
2278
  */
2003
- static create(discriminator, types, params) {
2279
+ static create(discriminator, options, params) {
2004
2280
  // Get all the valid discriminator values
2005
- const options = new Map();
2006
- try {
2007
- types.forEach((type) => {
2008
- const discriminatorValue = type.shape[discriminator].value;
2009
- options.set(discriminatorValue, type);
2010
- });
2011
- }
2012
- catch (e) {
2013
- throw new Error("The discriminator value could not be extracted from all the provided schemas");
2014
- }
2015
- // Assert that all the discriminator values are unique
2016
- if (options.size !== types.length) {
2017
- 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
+ }
2018
2294
  }
2019
2295
  return new ZodDiscriminatedUnion({
2020
2296
  typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2021
2297
  discriminator,
2022
2298
  options,
2299
+ optionsMap,
2023
2300
  ...processCreateParams(params),
2024
2301
  });
2025
2302
  }
@@ -2140,6 +2417,7 @@ class ZodTuple extends ZodType {
2140
2417
  code: ZodIssueCode.too_small,
2141
2418
  minimum: this._def.items.length,
2142
2419
  inclusive: true,
2420
+ exact: false,
2143
2421
  type: "array",
2144
2422
  });
2145
2423
  return INVALID;
@@ -2150,6 +2428,7 @@ class ZodTuple extends ZodType {
2150
2428
  code: ZodIssueCode.too_big,
2151
2429
  maximum: this._def.items.length,
2152
2430
  inclusive: true,
2431
+ exact: false,
2153
2432
  type: "array",
2154
2433
  });
2155
2434
  status.dirty();
@@ -2325,6 +2604,7 @@ class ZodSet extends ZodType {
2325
2604
  minimum: def.minSize.value,
2326
2605
  type: "set",
2327
2606
  inclusive: true,
2607
+ exact: false,
2328
2608
  message: def.minSize.message,
2329
2609
  });
2330
2610
  status.dirty();
@@ -2337,6 +2617,7 @@ class ZodSet extends ZodType {
2337
2617
  maximum: def.maxSize.value,
2338
2618
  type: "set",
2339
2619
  inclusive: true,
2620
+ exact: false,
2340
2621
  message: def.maxSize.message,
2341
2622
  });
2342
2623
  status.dirty();
@@ -2677,6 +2958,11 @@ class ZodEffects extends ZodType {
2677
2958
  innerType() {
2678
2959
  return this._def.schema;
2679
2960
  }
2961
+ sourceType() {
2962
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects
2963
+ ? this._def.schema.sourceType()
2964
+ : this._def.schema;
2965
+ }
2680
2966
  _parse(input) {
2681
2967
  const { status, ctx } = this._processInputParams(input);
2682
2968
  const effect = this._def.effect || null;
@@ -2863,9 +3149,49 @@ class ZodDefault extends ZodType {
2863
3149
  }
2864
3150
  }
2865
3151
  ZodDefault.create = (type, params) => {
2866
- return new ZodOptional({
3152
+ return new ZodDefault({
2867
3153
  innerType: type,
2868
- 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,
2869
3195
  ...processCreateParams(params),
2870
3196
  });
2871
3197
  };
@@ -2905,6 +3231,64 @@ class ZodBranded extends ZodType {
2905
3231
  return this._def.type;
2906
3232
  }
2907
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
+ }
2908
3292
  const custom = (check, params = {}, fatal) => {
2909
3293
  if (check)
2910
3294
  return ZodAny.create().superRefine((data, ctx) => {
@@ -2927,6 +3311,7 @@ var ZodFirstPartyTypeKind;
2927
3311
  ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
2928
3312
  ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
2929
3313
  ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
3314
+ ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
2930
3315
  ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
2931
3316
  ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
2932
3317
  ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
@@ -2951,16 +3336,14 @@ var ZodFirstPartyTypeKind;
2951
3336
  ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
2952
3337
  ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
2953
3338
  ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
3339
+ ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
2954
3340
  ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
2955
3341
  ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
3342
+ ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
2956
3343
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
2957
- // new approach that works for abstract classes
2958
- // but required TS 4.4+
2959
- // abstract class Class {
2960
- // constructor(..._: any[]) {}
2961
- // }
2962
- // const instanceOfType = <T extends typeof Class>(
2963
- const instanceOfType = (cls, params = {
3344
+ const instanceOfType = (
3345
+ // const instanceOfType = <T extends new (...args: any[]) => any>(
3346
+ cls, params = {
2964
3347
  message: `Input not instance of ${cls.name}`,
2965
3348
  }) => custom((data) => data instanceof cls, params, true);
2966
3349
  const stringType = ZodString.create;
@@ -2969,6 +3352,7 @@ const nanType = ZodNaN.create;
2969
3352
  const bigIntType = ZodBigInt.create;
2970
3353
  const booleanType = ZodBoolean.create;
2971
3354
  const dateType = ZodDate.create;
3355
+ const symbolType = ZodSymbol.create;
2972
3356
  const undefinedType = ZodUndefined.create;
2973
3357
  const nullType = ZodNull.create;
2974
3358
  const anyType = ZodAny.create;
@@ -2995,15 +3379,21 @@ const effectsType = ZodEffects.create;
2995
3379
  const optionalType = ZodOptional.create;
2996
3380
  const nullableType = ZodNullable.create;
2997
3381
  const preprocessType = ZodEffects.createWithPreprocess;
3382
+ const pipelineType = ZodPipeline.create;
2998
3383
  const ostring = () => stringType().optional();
2999
3384
  const onumber = () => numberType().optional();
3000
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
+ };
3001
3393
  const NEVER = INVALID;
3002
3394
 
3003
3395
  var mod = /*#__PURE__*/Object.freeze({
3004
3396
  __proto__: null,
3005
- getParsedType: getParsedType,
3006
- ZodParsedType: ZodParsedType,
3007
3397
  defaultErrorMap: errorMap,
3008
3398
  setErrorMap: setErrorMap,
3009
3399
  getErrorMap: getErrorMap,
@@ -3018,12 +3408,16 @@ var mod = /*#__PURE__*/Object.freeze({
3018
3408
  isDirty: isDirty,
3019
3409
  isValid: isValid,
3020
3410
  isAsync: isAsync,
3411
+ get util () { return util; },
3412
+ ZodParsedType: ZodParsedType,
3413
+ getParsedType: getParsedType,
3021
3414
  ZodType: ZodType,
3022
3415
  ZodString: ZodString,
3023
3416
  ZodNumber: ZodNumber,
3024
3417
  ZodBigInt: ZodBigInt,
3025
3418
  ZodBoolean: ZodBoolean,
3026
3419
  ZodDate: ZodDate,
3420
+ ZodSymbol: ZodSymbol,
3027
3421
  ZodUndefined: ZodUndefined,
3028
3422
  ZodNull: ZodNull,
3029
3423
  ZodAny: ZodAny,
@@ -3051,14 +3445,17 @@ var mod = /*#__PURE__*/Object.freeze({
3051
3445
  ZodOptional: ZodOptional,
3052
3446
  ZodNullable: ZodNullable,
3053
3447
  ZodDefault: ZodDefault,
3448
+ ZodCatch: ZodCatch,
3054
3449
  ZodNaN: ZodNaN,
3055
3450
  BRAND: BRAND,
3056
3451
  ZodBranded: ZodBranded,
3452
+ ZodPipeline: ZodPipeline,
3057
3453
  custom: custom,
3058
3454
  Schema: ZodType,
3059
3455
  ZodSchema: ZodType,
3060
3456
  late: late,
3061
3457
  get ZodFirstPartyTypeKind () { return ZodFirstPartyTypeKind; },
3458
+ coerce: coerce,
3062
3459
  any: anyType,
3063
3460
  array: arrayType,
3064
3461
  bigint: bigIntType,
@@ -3084,12 +3481,14 @@ var mod = /*#__PURE__*/Object.freeze({
3084
3481
  onumber: onumber,
3085
3482
  optional: optionalType,
3086
3483
  ostring: ostring,
3484
+ pipeline: pipelineType,
3087
3485
  preprocess: preprocessType,
3088
3486
  promise: promiseType,
3089
3487
  record: recordType,
3090
3488
  set: setType,
3091
3489
  strictObject: strictObjectType,
3092
3490
  string: stringType,
3491
+ symbol: symbolType,
3093
3492
  transformer: effectsType,
3094
3493
  tuple: tupleType,
3095
3494
  'undefined': undefinedType,
@@ -3425,12 +3824,55 @@ mod.object({
3425
3824
  });
3426
3825
  mod.object({ id: mod.string(), uri: mod.string() }).catchall(mod.any());
3427
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({
3428
3848
  kty: mod.string(),
3429
3849
  crv: mod.string(),
3430
3850
  x: mod.string(),
3431
3851
  y: mod.string().optional(),
3852
+ n: mod.string().optional(),
3432
3853
  d: mod.string()
3433
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
+ });
3434
3876
 
3435
3877
  exports.VerificationStatusEnum = VerificationStatusEnum;
3436
- //# sourceMappingURL=types.esm-034454a2.js.map
3878
+ //# sourceMappingURL=types.esm-c09dbd3b.js.map