@mattrglobal/verifier-sdk-web 1.1.1-unstable.161 → 1.1.1-unstable.162

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.
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * neverthrow -- 4.3.0
15
15
  *
16
- * valibot -- 0.38.0
16
+ * valibot -- 1.1.0
17
17
  *
18
18
  * is-mobile -- 4.0.0
19
19
  */
@@ -605,9 +605,9 @@
605
605
  abortPipeEarly: config2.abortPipeEarly
606
606
  };
607
607
  var isSchema = context.kind === "schema";
608
- var message = (_ref3 = (_ref4 = (_ref5 = (_ref6 = (_other$message = other === null || other === void 0 ? void 0 : other.message) !== null && _other$message !== void 0 ? _other$message : context.message) !== null && _ref6 !== void 0 ? _ref6 : getSpecificMessage(context.reference, issue.lang)) !== null && _ref5 !== void 0 ? _ref5 : isSchema ? getSchemaMessage(issue.lang) : null) !== null && _ref4 !== void 0 ? _ref4 : config2.message) !== null && _ref3 !== void 0 ? _ref3 : getGlobalMessage(issue.lang);
609
- if (message) {
610
- issue.message = typeof message === "function" ? message(issue) : message;
608
+ var message2 = (_ref3 = (_ref4 = (_ref5 = (_ref6 = (_other$message = other === null || other === void 0 ? void 0 : other.message) !== null && _other$message !== void 0 ? _other$message : context.message) !== null && _ref6 !== void 0 ? _ref6 : getSpecificMessage(context.reference, issue.lang)) !== null && _ref5 !== void 0 ? _ref5 : isSchema ? getSchemaMessage(issue.lang) : null) !== null && _ref4 !== void 0 ? _ref4 : config2.message) !== null && _ref3 !== void 0 ? _ref3 : getGlobalMessage(issue.lang);
609
+ if (message2 !== void 0) {
610
+ issue.message = typeof message2 === "function" ? message2(issue) : message2;
611
611
  }
612
612
  if (isSchema) {
613
613
  dataset.typed = false;
@@ -618,26 +618,37 @@
618
618
  dataset.issues = [ issue ];
619
619
  }
620
620
  }
621
+ function _getStandardProps(context) {
622
+ return {
623
+ version: 1,
624
+ vendor: "valibot",
625
+ validate: function validate(value2) {
626
+ return context["~run"]({
627
+ value: value2
628
+ }, getGlobalConfig());
629
+ }
630
+ };
631
+ }
621
632
  function _isValidObjectKey(object2, key) {
622
633
  return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
623
634
  }
624
- function _joinExpects(values, separator) {
635
+ function _joinExpects(values2, separator) {
625
636
  var _list$;
626
- var list = _toConsumableArray(new Set(values));
637
+ var list = _toConsumableArray(new Set(values2));
627
638
  if (list.length > 1) {
628
639
  return "(".concat(list.join(" ".concat(separator, " ")), ")");
629
640
  }
630
641
  return (_list$ = list[0]) !== null && _list$ !== void 0 ? _list$ : "never";
631
642
  }
632
- function nonEmpty(message) {
643
+ function nonEmpty(message2) {
633
644
  return {
634
645
  kind: "validation",
635
646
  type: "non_empty",
636
647
  reference: nonEmpty,
637
648
  async: false,
638
649
  expects: "!0",
639
- message: message,
640
- _run: function _run(dataset, config2) {
650
+ message: message2,
651
+ "~run": function run(dataset, config2) {
641
652
  if (dataset.typed && dataset.value.length === 0) {
642
653
  _addIssue(this, "length", dataset, config2, {
643
654
  received: "0"
@@ -647,6 +658,9 @@
647
658
  }
648
659
  };
649
660
  }
661
+ function getFallback(schema, dataset, config2) {
662
+ return typeof schema.fallback === "function" ? schema.fallback(dataset, config2) : schema.fallback;
663
+ }
650
664
  function getDefault(schema, dataset, config2) {
651
665
  return typeof schema["default"] === "function" ? schema["default"](dataset, config2) : schema["default"];
652
666
  }
@@ -657,13 +671,16 @@
657
671
  reference: any,
658
672
  expects: "any",
659
673
  async: false,
660
- _run: function _run(dataset) {
674
+ get "~standard"() {
675
+ return _getStandardProps(this);
676
+ },
677
+ "~run": function run(dataset) {
661
678
  dataset.typed = true;
662
679
  return dataset;
663
680
  }
664
681
  };
665
682
  }
666
- function array(item, message) {
683
+ function array(item, message2) {
667
684
  return {
668
685
  kind: "schema",
669
686
  type: "array",
@@ -671,16 +688,18 @@
671
688
  expects: "Array",
672
689
  async: false,
673
690
  item: item,
674
- message: message,
675
- _run: function _run(dataset, config2) {
691
+ message: message2,
692
+ get "~standard"() {
693
+ return _getStandardProps(this);
694
+ },
695
+ "~run": function run(dataset, config2) {
676
696
  var input = dataset.value;
677
697
  if (Array.isArray(input)) {
678
698
  dataset.typed = true;
679
699
  dataset.value = [];
680
700
  for (var key = 0; key < input.length; key++) {
681
701
  var value2 = input[key];
682
- var itemDataset = this.item._run({
683
- typed: false,
702
+ var itemDataset = this.item["~run"]({
684
703
  value: value2
685
704
  }, config2);
686
705
  if (itemDataset.issues) {
@@ -691,11 +710,11 @@
691
710
  key: key,
692
711
  value: value2
693
712
  };
694
- var _iterator10 = _createForOfIteratorHelper(itemDataset.issues), _step10;
713
+ var _iterator14 = _createForOfIteratorHelper(itemDataset.issues), _step14;
695
714
  try {
696
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done; ) {
715
+ for (_iterator14.s(); !(_step14 = _iterator14.n()).done; ) {
697
716
  var _dataset$issues;
698
- var issue = _step10.value;
717
+ var issue = _step14.value;
699
718
  if (issue.path) {
700
719
  issue.path.unshift(pathItem);
701
720
  } else {
@@ -704,9 +723,9 @@
704
723
  (_dataset$issues = dataset.issues) === null || _dataset$issues === void 0 || _dataset$issues.push(issue);
705
724
  }
706
725
  } catch (err) {
707
- _iterator10.e(err);
726
+ _iterator14.e(err);
708
727
  } finally {
709
- _iterator10.f();
728
+ _iterator14.f();
710
729
  }
711
730
  if (!dataset.issues) {
712
731
  dataset.issues = itemDataset.issues;
@@ -728,15 +747,18 @@
728
747
  }
729
748
  };
730
749
  }
731
- function _boolean(message) {
750
+ function _boolean(message2) {
732
751
  return {
733
752
  kind: "schema",
734
753
  type: "boolean",
735
754
  reference: _boolean,
736
755
  expects: "boolean",
737
756
  async: false,
738
- message: message,
739
- _run: function _run(dataset, config2) {
757
+ message: message2,
758
+ get "~standard"() {
759
+ return _getStandardProps(this);
760
+ },
761
+ "~run": function run(dataset, config2) {
740
762
  if (typeof dataset.value === "boolean") {
741
763
  dataset.typed = true;
742
764
  } else {
@@ -746,7 +768,7 @@
746
768
  }
747
769
  };
748
770
  }
749
- function literal(literal_, message) {
771
+ function literal(literal_, message2) {
750
772
  return {
751
773
  kind: "schema",
752
774
  type: "literal",
@@ -754,8 +776,11 @@
754
776
  expects: _stringify(literal_),
755
777
  async: false,
756
778
  literal: literal_,
757
- message: message,
758
- _run: function _run(dataset, config2) {
779
+ message: message2,
780
+ get "~standard"() {
781
+ return _getStandardProps(this);
782
+ },
783
+ "~run": function run(dataset, config2) {
759
784
  if (dataset.value === this.literal) {
760
785
  dataset.typed = true;
761
786
  } else {
@@ -765,15 +790,18 @@
765
790
  }
766
791
  };
767
792
  }
768
- function number(message) {
793
+ function number(message2) {
769
794
  return {
770
795
  kind: "schema",
771
796
  type: "number",
772
797
  reference: number,
773
798
  expects: "number",
774
799
  async: false,
775
- message: message,
776
- _run: function _run(dataset, config2) {
800
+ message: message2,
801
+ get "~standard"() {
802
+ return _getStandardProps(this);
803
+ },
804
+ "~run": function run(dataset, config2) {
777
805
  if (typeof dataset.value === "number" && !isNaN(dataset.value)) {
778
806
  dataset.typed = true;
779
807
  } else {
@@ -783,65 +811,85 @@
783
811
  }
784
812
  };
785
813
  }
786
- function object(entries, message) {
814
+ function object(entries2, message2) {
787
815
  return {
788
816
  kind: "schema",
789
817
  type: "object",
790
818
  reference: object,
791
819
  expects: "Object",
792
820
  async: false,
793
- entries: entries,
794
- message: message,
795
- _run: function _run(dataset, config2) {
821
+ entries: entries2,
822
+ message: message2,
823
+ get "~standard"() {
824
+ return _getStandardProps(this);
825
+ },
826
+ "~run": function run(dataset, config2) {
796
827
  var input = dataset.value;
797
828
  if (input && _typeof(input) === "object") {
798
829
  dataset.typed = true;
799
830
  dataset.value = {};
800
831
  for (var key in this.entries) {
801
- var value2 = input[key];
802
- var valueDataset = this.entries[key]._run({
803
- typed: false,
804
- value: value2
805
- }, config2);
806
- if (valueDataset.issues) {
807
- var pathItem = {
808
- type: "object",
809
- origin: "value",
810
- input: input,
811
- key: key,
832
+ var valueSchema = this.entries[key];
833
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema["default"] !== void 0) {
834
+ var value2 = key in input ? input[key] : getDefault(valueSchema);
835
+ var valueDataset = valueSchema["~run"]({
812
836
  value: value2
813
- };
814
- var _iterator26 = _createForOfIteratorHelper(valueDataset.issues), _step26;
815
- try {
816
- for (_iterator26.s(); !(_step26 = _iterator26.n()).done; ) {
817
- var _dataset$issues13;
818
- var issue = _step26.value;
819
- if (issue.path) {
820
- issue.path.unshift(pathItem);
821
- } else {
822
- issue.path = [ pathItem ];
837
+ }, config2);
838
+ if (valueDataset.issues) {
839
+ var pathItem = {
840
+ type: "object",
841
+ origin: "value",
842
+ input: input,
843
+ key: key,
844
+ value: value2
845
+ };
846
+ var _iterator30 = _createForOfIteratorHelper(valueDataset.issues), _step30;
847
+ try {
848
+ for (_iterator30.s(); !(_step30 = _iterator30.n()).done; ) {
849
+ var _dataset$issues13;
850
+ var issue = _step30.value;
851
+ if (issue.path) {
852
+ issue.path.unshift(pathItem);
853
+ } else {
854
+ issue.path = [ pathItem ];
855
+ }
856
+ (_dataset$issues13 = dataset.issues) === null || _dataset$issues13 === void 0 || _dataset$issues13.push(issue);
823
857
  }
824
- (_dataset$issues13 = dataset.issues) === null || _dataset$issues13 === void 0 || _dataset$issues13.push(issue);
858
+ } catch (err) {
859
+ _iterator30.e(err);
860
+ } finally {
861
+ _iterator30.f();
862
+ }
863
+ if (!dataset.issues) {
864
+ dataset.issues = valueDataset.issues;
865
+ }
866
+ if (config2.abortEarly) {
867
+ dataset.typed = false;
868
+ break;
825
869
  }
826
- } catch (err) {
827
- _iterator26.e(err);
828
- } finally {
829
- _iterator26.f();
830
870
  }
831
- if (!dataset.issues) {
832
- dataset.issues = valueDataset.issues;
871
+ if (!valueDataset.typed) {
872
+ dataset.typed = false;
833
873
  }
874
+ dataset.value[key] = valueDataset.value;
875
+ } else if (valueSchema.fallback !== void 0) {
876
+ dataset.value[key] = getFallback(valueSchema);
877
+ } else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
878
+ _addIssue(this, "key", dataset, config2, {
879
+ input: void 0,
880
+ expected: '"'.concat(key, '"'),
881
+ path: [ {
882
+ type: "object",
883
+ origin: "key",
884
+ input: input,
885
+ key: key,
886
+ value: input[key]
887
+ } ]
888
+ });
834
889
  if (config2.abortEarly) {
835
- dataset.typed = false;
836
890
  break;
837
891
  }
838
892
  }
839
- if (!valueDataset.typed) {
840
- dataset.typed = false;
841
- }
842
- if (valueDataset.value !== void 0 || key in input) {
843
- dataset.value[key] = valueDataset.value;
844
- }
845
893
  }
846
894
  } else {
847
895
  _addIssue(this, "type", dataset, config2);
@@ -850,17 +898,21 @@
850
898
  }
851
899
  };
852
900
  }
853
- function optional(wrapped) {
854
- var schema = {
901
+ function optional(wrapped, default_) {
902
+ return {
855
903
  kind: "schema",
856
904
  type: "optional",
857
905
  reference: optional,
858
906
  expects: "(".concat(wrapped.expects, " | undefined)"),
859
907
  async: false,
860
908
  wrapped: wrapped,
861
- _run: function _run(dataset, config2) {
909
+ default: default_,
910
+ get "~standard"() {
911
+ return _getStandardProps(this);
912
+ },
913
+ "~run": function run(dataset, config2) {
862
914
  if (dataset.value === void 0) {
863
- if ("default" in this) {
915
+ if (this["default"] !== void 0) {
864
916
  dataset.value = getDefault(this, dataset, config2);
865
917
  }
866
918
  if (dataset.value === void 0) {
@@ -868,18 +920,11 @@
868
920
  return dataset;
869
921
  }
870
922
  }
871
- return this.wrapped._run(dataset, config2);
923
+ return this.wrapped["~run"](dataset, config2);
872
924
  }
873
925
  };
874
- for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key11 = 1; _key11 < _len5; _key11++) {
875
- args[_key11 - 1] = arguments[_key11];
876
- }
877
- if (0 in args) {
878
- schema["default"] = args[0];
879
- }
880
- return schema;
881
926
  }
882
- function picklist(options, message) {
927
+ function picklist(options, message2) {
883
928
  return {
884
929
  kind: "schema",
885
930
  type: "picklist",
@@ -887,8 +932,11 @@
887
932
  expects: _joinExpects(options.map(_stringify), "|"),
888
933
  async: false,
889
934
  options: options,
890
- message: message,
891
- _run: function _run(dataset, config2) {
935
+ message: message2,
936
+ get "~standard"() {
937
+ return _getStandardProps(this);
938
+ },
939
+ "~run": function run(dataset, config2) {
892
940
  if (this.options.includes(dataset.value)) {
893
941
  dataset.typed = true;
894
942
  } else {
@@ -898,7 +946,7 @@
898
946
  }
899
947
  };
900
948
  }
901
- function record(key, value2, message) {
949
+ function record(key, value2, message2) {
902
950
  return {
903
951
  kind: "schema",
904
952
  type: "record",
@@ -907,8 +955,11 @@
907
955
  async: false,
908
956
  key: key,
909
957
  value: value2,
910
- message: message,
911
- _run: function _run(dataset, config2) {
958
+ message: message2,
959
+ get "~standard"() {
960
+ return _getStandardProps(this);
961
+ },
962
+ "~run": function run(dataset, config2) {
912
963
  var input = dataset.value;
913
964
  if (input && _typeof(input) === "object") {
914
965
  dataset.typed = true;
@@ -916,8 +967,7 @@
916
967
  for (var entryKey in input) {
917
968
  if (_isValidObjectKey(input, entryKey)) {
918
969
  var entryValue = input[entryKey];
919
- var keyDataset = this.key._run({
920
- typed: false,
970
+ var keyDataset = this.key["~run"]({
921
971
  value: entryKey
922
972
  }, config2);
923
973
  if (keyDataset.issues) {
@@ -928,18 +978,18 @@
928
978
  key: entryKey,
929
979
  value: entryValue
930
980
  };
931
- var _iterator35 = _createForOfIteratorHelper(keyDataset.issues), _step35;
981
+ var _iterator39 = _createForOfIteratorHelper(keyDataset.issues), _step39;
932
982
  try {
933
- for (_iterator35.s(); !(_step35 = _iterator35.n()).done; ) {
983
+ for (_iterator39.s(); !(_step39 = _iterator39.n()).done; ) {
934
984
  var _dataset$issues19;
935
- var issue = _step35.value;
985
+ var issue = _step39.value;
936
986
  issue.path = [ pathItem ];
937
987
  (_dataset$issues19 = dataset.issues) === null || _dataset$issues19 === void 0 || _dataset$issues19.push(issue);
938
988
  }
939
989
  } catch (err) {
940
- _iterator35.e(err);
990
+ _iterator39.e(err);
941
991
  } finally {
942
- _iterator35.f();
992
+ _iterator39.f();
943
993
  }
944
994
  if (!dataset.issues) {
945
995
  dataset.issues = keyDataset.issues;
@@ -949,8 +999,7 @@
949
999
  break;
950
1000
  }
951
1001
  }
952
- var valueDataset = this.value._run({
953
- typed: false,
1002
+ var valueDataset = this.value["~run"]({
954
1003
  value: entryValue
955
1004
  }, config2);
956
1005
  if (valueDataset.issues) {
@@ -961,11 +1010,11 @@
961
1010
  key: entryKey,
962
1011
  value: entryValue
963
1012
  };
964
- var _iterator36 = _createForOfIteratorHelper(valueDataset.issues), _step36;
1013
+ var _iterator40 = _createForOfIteratorHelper(valueDataset.issues), _step40;
965
1014
  try {
966
- for (_iterator36.s(); !(_step36 = _iterator36.n()).done; ) {
1015
+ for (_iterator40.s(); !(_step40 = _iterator40.n()).done; ) {
967
1016
  var _dataset$issues20;
968
- var _issue5 = _step36.value;
1017
+ var _issue5 = _step40.value;
969
1018
  if (_issue5.path) {
970
1019
  _issue5.path.unshift(_pathItem5);
971
1020
  } else {
@@ -974,9 +1023,9 @@
974
1023
  (_dataset$issues20 = dataset.issues) === null || _dataset$issues20 === void 0 || _dataset$issues20.push(_issue5);
975
1024
  }
976
1025
  } catch (err) {
977
- _iterator36.e(err);
1026
+ _iterator40.e(err);
978
1027
  } finally {
979
- _iterator36.f();
1028
+ _iterator40.f();
980
1029
  }
981
1030
  if (!dataset.issues) {
982
1031
  dataset.issues = valueDataset.issues;
@@ -1001,79 +1050,98 @@
1001
1050
  }
1002
1051
  };
1003
1052
  }
1004
- function strictObject(entries, message) {
1053
+ function strictObject(entries2, message2) {
1005
1054
  return {
1006
1055
  kind: "schema",
1007
1056
  type: "strict_object",
1008
1057
  reference: strictObject,
1009
1058
  expects: "Object",
1010
1059
  async: false,
1011
- entries: entries,
1012
- message: message,
1013
- _run: function _run(dataset, config2) {
1060
+ entries: entries2,
1061
+ message: message2,
1062
+ get "~standard"() {
1063
+ return _getStandardProps(this);
1064
+ },
1065
+ "~run": function run(dataset, config2) {
1014
1066
  var input = dataset.value;
1015
1067
  if (input && _typeof(input) === "object") {
1016
1068
  dataset.typed = true;
1017
1069
  dataset.value = {};
1018
1070
  for (var key in this.entries) {
1019
- var value2 = input[key];
1020
- var valueDataset = this.entries[key]._run({
1021
- typed: false,
1022
- value: value2
1023
- }, config2);
1024
- if (valueDataset.issues) {
1025
- var pathItem = {
1026
- type: "object",
1027
- origin: "value",
1028
- input: input,
1029
- key: key,
1071
+ var valueSchema = this.entries[key];
1072
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema["default"] !== void 0) {
1073
+ var value2 = key in input ? input[key] : getDefault(valueSchema);
1074
+ var valueDataset = valueSchema["~run"]({
1030
1075
  value: value2
1031
- };
1032
- var _iterator44 = _createForOfIteratorHelper(valueDataset.issues), _step44;
1033
- try {
1034
- for (_iterator44.s(); !(_step44 = _iterator44.n()).done; ) {
1035
- var _dataset$issues25;
1036
- var issue = _step44.value;
1037
- if (issue.path) {
1038
- issue.path.unshift(pathItem);
1039
- } else {
1040
- issue.path = [ pathItem ];
1076
+ }, config2);
1077
+ if (valueDataset.issues) {
1078
+ var pathItem = {
1079
+ type: "object",
1080
+ origin: "value",
1081
+ input: input,
1082
+ key: key,
1083
+ value: value2
1084
+ };
1085
+ var _iterator48 = _createForOfIteratorHelper(valueDataset.issues), _step48;
1086
+ try {
1087
+ for (_iterator48.s(); !(_step48 = _iterator48.n()).done; ) {
1088
+ var _dataset$issues25;
1089
+ var issue = _step48.value;
1090
+ if (issue.path) {
1091
+ issue.path.unshift(pathItem);
1092
+ } else {
1093
+ issue.path = [ pathItem ];
1094
+ }
1095
+ (_dataset$issues25 = dataset.issues) === null || _dataset$issues25 === void 0 || _dataset$issues25.push(issue);
1041
1096
  }
1042
- (_dataset$issues25 = dataset.issues) === null || _dataset$issues25 === void 0 || _dataset$issues25.push(issue);
1097
+ } catch (err) {
1098
+ _iterator48.e(err);
1099
+ } finally {
1100
+ _iterator48.f();
1101
+ }
1102
+ if (!dataset.issues) {
1103
+ dataset.issues = valueDataset.issues;
1104
+ }
1105
+ if (config2.abortEarly) {
1106
+ dataset.typed = false;
1107
+ break;
1043
1108
  }
1044
- } catch (err) {
1045
- _iterator44.e(err);
1046
- } finally {
1047
- _iterator44.f();
1048
1109
  }
1049
- if (!dataset.issues) {
1050
- dataset.issues = valueDataset.issues;
1110
+ if (!valueDataset.typed) {
1111
+ dataset.typed = false;
1051
1112
  }
1113
+ dataset.value[key] = valueDataset.value;
1114
+ } else if (valueSchema.fallback !== void 0) {
1115
+ dataset.value[key] = getFallback(valueSchema);
1116
+ } else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
1117
+ _addIssue(this, "key", dataset, config2, {
1118
+ input: void 0,
1119
+ expected: '"'.concat(key, '"'),
1120
+ path: [ {
1121
+ type: "object",
1122
+ origin: "key",
1123
+ input: input,
1124
+ key: key,
1125
+ value: input[key]
1126
+ } ]
1127
+ });
1052
1128
  if (config2.abortEarly) {
1053
- dataset.typed = false;
1054
1129
  break;
1055
1130
  }
1056
1131
  }
1057
- if (!valueDataset.typed) {
1058
- dataset.typed = false;
1059
- }
1060
- if (valueDataset.value !== void 0 || key in input) {
1061
- dataset.value[key] = valueDataset.value;
1062
- }
1063
1132
  }
1064
1133
  if (!dataset.issues || !config2.abortEarly) {
1065
- for (var _key13 in input) {
1066
- if (!(_key13 in this.entries)) {
1067
- var _value3 = input[_key13];
1068
- _addIssue(this, "type", dataset, config2, {
1069
- input: _value3,
1134
+ for (var _key9 in input) {
1135
+ if (!(_key9 in this.entries)) {
1136
+ _addIssue(this, "key", dataset, config2, {
1137
+ input: _key9,
1070
1138
  expected: "never",
1071
1139
  path: [ {
1072
1140
  type: "object",
1073
- origin: "value",
1141
+ origin: "key",
1074
1142
  input: input,
1075
- key: _key13,
1076
- value: _value3
1143
+ key: _key9,
1144
+ value: input[_key9]
1077
1145
  } ]
1078
1146
  });
1079
1147
  break;
@@ -1087,15 +1155,18 @@
1087
1155
  }
1088
1156
  };
1089
1157
  }
1090
- function string(message) {
1158
+ function string(message2) {
1091
1159
  return {
1092
1160
  kind: "schema",
1093
1161
  type: "string",
1094
1162
  reference: string,
1095
1163
  expects: "string",
1096
1164
  async: false,
1097
- message: message,
1098
- _run: function _run(dataset, config2) {
1165
+ message: message2,
1166
+ get "~standard"() {
1167
+ return _getStandardProps(this);
1168
+ },
1169
+ "~run": function run(dataset, config2) {
1099
1170
  if (typeof dataset.value === "string") {
1100
1171
  dataset.typed = true;
1101
1172
  } else {
@@ -1108,10 +1179,10 @@
1108
1179
  function _subIssues(datasets) {
1109
1180
  var issues;
1110
1181
  if (datasets) {
1111
- var _iterator59 = _createForOfIteratorHelper(datasets), _step59;
1182
+ var _iterator63 = _createForOfIteratorHelper(datasets), _step63;
1112
1183
  try {
1113
- for (_iterator59.s(); !(_step59 = _iterator59.n()).done; ) {
1114
- var dataset = _step59.value;
1184
+ for (_iterator63.s(); !(_step63 = _iterator63.n()).done; ) {
1185
+ var dataset = _step63.value;
1115
1186
  if (issues) {
1116
1187
  var _issues;
1117
1188
  (_issues = issues).push.apply(_issues, _toConsumableArray(dataset.issues));
@@ -1120,14 +1191,14 @@
1120
1191
  }
1121
1192
  }
1122
1193
  } catch (err) {
1123
- _iterator59.e(err);
1194
+ _iterator63.e(err);
1124
1195
  } finally {
1125
- _iterator59.f();
1196
+ _iterator63.f();
1126
1197
  }
1127
1198
  }
1128
1199
  return issues;
1129
1200
  }
1130
- function union(options, message) {
1201
+ function union(options, message2) {
1131
1202
  return {
1132
1203
  kind: "schema",
1133
1204
  type: "union",
@@ -1137,18 +1208,20 @@
1137
1208
  })), "|"),
1138
1209
  async: false,
1139
1210
  options: options,
1140
- message: message,
1141
- _run: function _run(dataset, config2) {
1211
+ message: message2,
1212
+ get "~standard"() {
1213
+ return _getStandardProps(this);
1214
+ },
1215
+ "~run": function run(dataset, config2) {
1142
1216
  var _untypedDatasets;
1143
1217
  var validDataset;
1144
1218
  var typedDatasets;
1145
1219
  var untypedDatasets;
1146
- var _iterator60 = _createForOfIteratorHelper(this.options), _step60;
1220
+ var _iterator64 = _createForOfIteratorHelper(this.options), _step64;
1147
1221
  try {
1148
- for (_iterator60.s(); !(_step60 = _iterator60.n()).done; ) {
1149
- var schema = _step60.value;
1150
- var optionDataset = schema._run({
1151
- typed: false,
1222
+ for (_iterator64.s(); !(_step64 = _iterator64.n()).done; ) {
1223
+ var schema = _step64.value;
1224
+ var optionDataset = schema["~run"]({
1152
1225
  value: dataset.value
1153
1226
  }, config2);
1154
1227
  if (optionDataset.typed) {
@@ -1171,9 +1244,9 @@
1171
1244
  }
1172
1245
  }
1173
1246
  } catch (err) {
1174
- _iterator60.e(err);
1247
+ _iterator64.e(err);
1175
1248
  } finally {
1176
- _iterator60.f();
1249
+ _iterator64.f();
1177
1250
  }
1178
1251
  if (validDataset) {
1179
1252
  return validDataset;
@@ -1204,28 +1277,34 @@
1204
1277
  reference: unknown,
1205
1278
  expects: "unknown",
1206
1279
  async: false,
1207
- _run: function _run(dataset) {
1280
+ get "~standard"() {
1281
+ return _getStandardProps(this);
1282
+ },
1283
+ "~run": function run(dataset) {
1208
1284
  dataset.typed = true;
1209
1285
  return dataset;
1210
1286
  }
1211
1287
  };
1212
1288
  }
1213
1289
  function pipe() {
1214
- for (var _len7 = arguments.length, pipe2 = new Array(_len7), _key17 = 0; _key17 < _len7; _key17++) {
1215
- pipe2[_key17] = arguments[_key17];
1290
+ for (var _len3 = arguments.length, pipe2 = new Array(_len3), _key13 = 0; _key13 < _len3; _key13++) {
1291
+ pipe2[_key13] = arguments[_key13];
1216
1292
  }
1217
1293
  return _objectSpread2(_objectSpread2({}, pipe2[0]), {}, {
1218
1294
  pipe: pipe2,
1219
- _run: function _run(dataset, config2) {
1220
- for (var _i = 0, _pipe = pipe2; _i < _pipe.length; _i++) {
1221
- var item = _pipe[_i];
1295
+ get "~standard"() {
1296
+ return _getStandardProps(this);
1297
+ },
1298
+ "~run": function run(dataset, config2) {
1299
+ for (var _i2 = 0, _pipe = pipe2; _i2 < _pipe.length; _i2++) {
1300
+ var item = _pipe[_i2];
1222
1301
  if (item.kind !== "metadata") {
1223
1302
  if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
1224
1303
  dataset.typed = false;
1225
1304
  break;
1226
1305
  }
1227
1306
  if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) {
1228
- dataset = item._run(dataset, config2);
1307
+ dataset = item["~run"](dataset, config2);
1229
1308
  }
1230
1309
  }
1231
1310
  }
@@ -1234,8 +1313,7 @@
1234
1313
  });
1235
1314
  }
1236
1315
  function safeParse(schema, input, config2) {
1237
- var dataset = schema._run({
1238
- typed: false,
1316
+ var dataset = schema["~run"]({
1239
1317
  value: input
1240
1318
  }, getGlobalConfig(config2));
1241
1319
  return {
@@ -1246,10 +1324,20 @@
1246
1324
  };
1247
1325
  }
1248
1326
  const isType = validator => value => safeParse(validator, value).success;
1249
- const getValidationErrors = issues => issues.map((({message: message, path: path}) => ({
1250
- message: message,
1251
- path: path === null || path === void 0 ? void 0 : path.map((path => path.key))
1252
- })));
1327
+ const getValidationErrors = issues => {
1328
+ const formatIssue = ({message: message, path: path}) => ({
1329
+ message: message,
1330
+ path: path === null || path === void 0 ? void 0 : path.map((p => p.key))
1331
+ });
1332
+ const uniqueErrors = new Map;
1333
+ issues.flatMap((issue => issue.type === "union" && issue.issues ? issue.issues.map(formatIssue) : [ formatIssue(issue) ])).forEach((error => {
1334
+ const key = `${error.message}-${JSON.stringify(error.path)}`;
1335
+ if (!uniqueErrors.has(key)) {
1336
+ uniqueErrors.set(key, error);
1337
+ }
1338
+ }));
1339
+ return Array.from(uniqueErrors.values());
1340
+ };
1253
1341
  const validateType = (value, validator) => {
1254
1342
  const result = safeParse(validator, value);
1255
1343
  return result.success ? ok(result.output) : err(getValidationErrors(result.issues));