@arrirpc/schema 0.69.2 → 0.71.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.
@@ -1,4 +1,4 @@
1
- import { TypeValues, isSchemaFormElements, isSchemaFormEnum, isSchemaFormDiscriminator, isSchemaFormValues, isSchemaFormProperties, isSchemaFormRef } from 'jtd-utils';
1
+ import { TypeValues, isSchemaFormElements, isSchemaFormEnum, isSchemaFormDiscriminator, isSchemaFormValues, isSchemaFormProperties, isSchemaFormRef } from '@arrirpc/type-defs';
2
2
 
3
3
  const int8Min = -128;
4
4
  const int8Max = 127;
@@ -31,9 +31,7 @@ function isASchema(input) {
31
31
  return "parse" in input.metadata[SCHEMA_METADATA] && typeof input.metadata[SCHEMA_METADATA] === "object";
32
32
  }
33
33
  function isAScalarSchema(input) {
34
- return isASchema(input) && "type" in input && typeof input.type === "string" && // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
35
- (TypeValues.includes(input.type) || // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
36
- NumberTypeValues.includes(input.type));
34
+ return isASchema(input) && "type" in input && typeof input.type === "string" && (TypeValues.includes(input.type) || NumberTypeValues.includes(input.type));
37
35
  }
38
36
  const NumberTypeValues = [
39
37
  "float32",
@@ -69,24 +67,70 @@ function isARefSchema(input) {
69
67
  return isASchema(input) && isSchemaFormRef(input);
70
68
  }
71
69
 
72
- function any(options = {}) {
70
+ function createStandardSchemaProperty(validate, parse) {
73
71
  return {
72
+ version: 1,
73
+ vendor: "arri",
74
+ validate(input) {
75
+ if (validate(input)) {
76
+ return {
77
+ value: input
78
+ };
79
+ }
80
+ const ctx = {
81
+ instancePath: "",
82
+ schemaPath: "",
83
+ errors: []
84
+ };
85
+ try {
86
+ const result = parse(input, ctx);
87
+ if (!result || ctx.errors.length) {
88
+ return {
89
+ issues: ctx.errors.map((err) => ({
90
+ message: err.message ?? "Unknown error",
91
+ path: err.instancePath.split("/").filter((val) => val.length > 0)
92
+ }))
93
+ };
94
+ }
95
+ return {
96
+ value: result
97
+ };
98
+ } catch (err) {
99
+ return {
100
+ issues: [
101
+ {
102
+ message: err instanceof Error ? err.message : `${err}`
103
+ }
104
+ ]
105
+ };
106
+ }
107
+ }
108
+ };
109
+ }
110
+ function hideInvalidProperties(schema) {
111
+ Object.defineProperty(schema, "~standard", { enumerable: false });
112
+ }
113
+
114
+ function any(options = {}) {
115
+ const validate = (input) => true;
116
+ const parse = (input, context) => {
117
+ if (context.instancePath.length === 0 && typeof input === "string") {
118
+ try {
119
+ return JSON.parse(input);
120
+ } catch {
121
+ return input;
122
+ }
123
+ }
124
+ return input;
125
+ };
126
+ const result = {
74
127
  metadata: {
75
128
  id: options.id,
76
129
  description: options.description,
77
130
  isDeprecated: options.isDeprecated,
78
131
  [SCHEMA_METADATA]: {
79
- output: void 0,
80
- parse: (input, context) => {
81
- if (context.instancePath.length === 0 && typeof input === "string") {
82
- try {
83
- return JSON.parse(input);
84
- } catch {
85
- return input;
86
- }
87
- }
88
- return input;
89
- },
132
+ output: undefined,
133
+ parse,
90
134
  coerce: (input, context) => {
91
135
  if (context.instancePath.length === 0 && typeof input === "string") {
92
136
  try {
@@ -97,17 +141,26 @@ function any(options = {}) {
97
141
  }
98
142
  return input;
99
143
  },
100
- validate: (input) => true,
144
+ validate,
101
145
  serialize(input) {
102
146
  return JSON.stringify(input);
103
147
  }
104
148
  }
105
- }
149
+ },
150
+ "~standard": createStandardSchemaProperty(validate, parse)
106
151
  };
152
+ hideInvalidProperties(result);
153
+ return result;
107
154
  }
108
155
 
109
156
  function array(schema, opts = {}) {
110
- return {
157
+ const validateType = (input) => {
158
+ return validate$5(schema, input);
159
+ };
160
+ const parseType = (input, context) => {
161
+ return parse$6(schema, input, context, false);
162
+ };
163
+ const result = {
111
164
  elements: schema,
112
165
  metadata: {
113
166
  id: opts.id,
@@ -115,15 +168,11 @@ function array(schema, opts = {}) {
115
168
  isDeprecated: opts.isDeprecated,
116
169
  [SCHEMA_METADATA]: {
117
170
  output: [],
118
- parse(input, context) {
119
- return parse$6(schema, input, context, false);
120
- },
171
+ parse: parseType,
121
172
  coerce(input, context) {
122
173
  return parse$6(schema, input, context, true);
123
174
  },
124
- validate(input) {
125
- return validate$5(schema, input);
126
- },
175
+ validate: validateType,
127
176
  serialize(input, context) {
128
177
  const strParts = [];
129
178
  for (let i = 0; i < input.length; i++) {
@@ -139,8 +188,11 @@ function array(schema, opts = {}) {
139
188
  return `[${strParts.join(",")}]`;
140
189
  }
141
190
  }
142
- }
191
+ },
192
+ "~standard": createStandardSchemaProperty(validateType, parseType)
143
193
  };
194
+ hideInvalidProperties(result);
195
+ return result;
144
196
  }
145
197
  function validate$5(innerSchema, input) {
146
198
  if (!Array.isArray(input)) {
@@ -165,7 +217,7 @@ function parse$6(innerSchema, input, data, coerce = false) {
165
217
  schemaPath: `${data.schemaPath}/elements`,
166
218
  message: `Error at ${data.instancePath}. Invalid JSON.`
167
219
  });
168
- return void 0;
220
+ return undefined;
169
221
  }
170
222
  }
171
223
  if (!Array.isArray(parsedInput)) {
@@ -174,7 +226,7 @@ function parse$6(innerSchema, input, data, coerce = false) {
174
226
  schemaPath: `${data.schemaPath}/elements`,
175
227
  message: `Error at ${data.instancePath}. Expected array. Got ${typeof input}.`
176
228
  });
177
- return void 0;
229
+ return undefined;
178
230
  }
179
231
  const result = [];
180
232
  for (let i = 0; i < parsedInput.length; i++) {
@@ -202,13 +254,13 @@ function parse$6(innerSchema, input, data, coerce = false) {
202
254
  }
203
255
  }
204
256
  if (data.errors.length) {
205
- return void 0;
257
+ return undefined;
206
258
  }
207
259
  return result;
208
260
  }
209
261
 
210
262
  function boolean(opts = {}) {
211
- return {
263
+ const result = {
212
264
  type: "boolean",
213
265
  metadata: {
214
266
  id: opts.id,
@@ -240,11 +292,14 @@ function boolean(opts = {}) {
240
292
  schemaPath: context.schemaPath,
241
293
  message: `Error at ${context.instancePath}. Unable to coerce ${input} to boolean.`
242
294
  });
243
- return void 0;
295
+ return undefined;
244
296
  }
245
297
  }
246
- }
298
+ },
299
+ "~standard": createStandardSchemaProperty(validate$4, parse$5)
247
300
  };
301
+ hideInvalidProperties(result);
302
+ return result;
248
303
  }
249
304
  function validate$4(input) {
250
305
  return typeof input === "boolean";
@@ -265,25 +320,19 @@ function parse$5(input, data) {
265
320
  schemaPath: `${data.schemaPath}/type`,
266
321
  message: `Error at ${data.instancePath}. Expected boolean. Got ${typeof input}.`
267
322
  });
268
- return void 0;
323
+ return undefined;
269
324
  }
270
325
  data.errors.push({
271
326
  instancePath: data.instancePath,
272
327
  schemaPath: `${data.schemaPath}/type`,
273
328
  message: `Error at ${data.instancePath}. Expected boolean. Got ${typeof input}.`
274
329
  });
275
- return void 0;
330
+ return undefined;
276
331
  }
277
332
  function serialize$2(input) {
278
333
  return `${input}`;
279
334
  }
280
335
 
281
- var __defProp = Object.defineProperty;
282
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
283
- var __publicField = (obj, key, value) => {
284
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
285
- return value;
286
- };
287
336
  function sanitizeJson(json) {
288
337
  return json.replace(/[\b]/g, "\\b").replace(/[\f]/g, "\\f").replace(/[\n]/g, "\\n").replace(/[\r]/g, "\\r").replace(/[\t]/g, "\\t");
289
338
  }
@@ -388,9 +437,9 @@ function errors(schema, input) {
388
437
  return errorList;
389
438
  }
390
439
  class ValidationError extends Error {
440
+ errors;
391
441
  constructor(options) {
392
442
  super(options.message);
393
- __publicField(this, "errors");
394
443
  this.errors = options.errors;
395
444
  }
396
445
  }
@@ -409,7 +458,13 @@ function discriminator(propA, propB, propC) {
409
458
  if (isIdShorthand) {
410
459
  opts.id = propA;
411
460
  }
412
- return {
461
+ const isType = (input) => {
462
+ return validate$2(discriminator2, mapping, input);
463
+ };
464
+ const parseType = (input, context) => {
465
+ return parse$3(discriminator2, mapping, input, context, false);
466
+ };
467
+ const result = {
413
468
  discriminator: discriminator2,
414
469
  mapping,
415
470
  metadata: {
@@ -418,12 +473,8 @@ function discriminator(propA, propB, propC) {
418
473
  isDeprecated: opts.isDeprecated,
419
474
  [SCHEMA_METADATA]: {
420
475
  output: {},
421
- validate(input) {
422
- return validate$2(discriminator2, mapping, input);
423
- },
424
- parse(input, context) {
425
- return parse$3(discriminator2, mapping, input, context, false);
426
- },
476
+ validate: isType,
477
+ parse: parseType,
427
478
  coerce: (input, context) => {
428
479
  return parse$3(discriminator2, mapping, input, context, true);
429
480
  },
@@ -436,18 +487,21 @@ function discriminator(propA, propB, propC) {
436
487
  context
437
488
  );
438
489
  }
439
- const result = targetSchema.metadata[SCHEMA_METADATA].serialize(input, {
490
+ const result2 = targetSchema.metadata[SCHEMA_METADATA].serialize(input, {
440
491
  instancePath: context.instancePath,
441
492
  schemaPath: `${context.schemaPath}/mapping/${discriminatorVal}`,
442
493
  errors: context.errors,
443
494
  discriminatorKey: discriminator2,
444
495
  discriminatorValue: discriminatorVal
445
496
  });
446
- return result;
497
+ return result2;
447
498
  }
448
499
  }
449
- }
500
+ },
501
+ "~standard": createStandardSchemaProperty(isType, parseType)
450
502
  };
503
+ hideInvalidProperties(result);
504
+ return result;
451
505
  }
452
506
  function validate$2(discriminator2, mapping, input) {
453
507
  if (!isObject(input)) {
@@ -477,7 +531,7 @@ function parse$3(discriminator2, mapping, input, data, coerce = false) {
477
531
  schemaPath: `${data.schemaPath}/discriminator`,
478
532
  message: `Error at ${data.instancePath}. Expected object. Got ${typeof parsedInput}.`
479
533
  });
480
- return void 0;
534
+ return undefined;
481
535
  }
482
536
  if (!(discriminator2 in parsedInput)) {
483
537
  data.errors.push({
@@ -485,7 +539,7 @@ function parse$3(discriminator2, mapping, input, data, coerce = false) {
485
539
  schemaPath: `${data.schemaPath}/discriminator`,
486
540
  message: `Error at ${data.instancePath}/${discriminator2}. Discriminator field "${discriminator2}" cannot be undefined`
487
541
  });
488
- return void 0;
542
+ return undefined;
489
543
  }
490
544
  const acceptedDiscriminatorVals = Object.keys(mapping);
491
545
  const discriminatorVal = parsedInput[discriminator2];
@@ -497,7 +551,7 @@ function parse$3(discriminator2, mapping, input, data, coerce = false) {
497
551
  ", "
498
552
  )}]`
499
553
  });
500
- return void 0;
554
+ return undefined;
501
555
  }
502
556
  const targetSchema = mapping[parsedInput[discriminator2]];
503
557
  if (!targetSchema) {
@@ -554,7 +608,20 @@ function enumerator(paramA, paramB) {
554
608
  }
555
609
  return false;
556
610
  };
557
- return {
611
+ const parse = (input, context) => {
612
+ if (isType(input)) {
613
+ return input;
614
+ }
615
+ context.errors.push({
616
+ instancePath: context.instancePath,
617
+ schemaPath: `${context.schemaPath}/enum`,
618
+ message: `Error at ${context.instancePath}. Invalid enum value. Expected one of the following values: [${enumVal.join(
619
+ ", "
620
+ )}]`
621
+ });
622
+ return undefined;
623
+ };
624
+ const result = {
558
625
  enum: enumVal,
559
626
  metadata: {
560
627
  id: meta?.id,
@@ -562,19 +629,7 @@ function enumerator(paramA, paramB) {
562
629
  isDeprecated: meta?.isDeprecated,
563
630
  [SCHEMA_METADATA]: {
564
631
  output: paramA[0] ?? "",
565
- parse(input, context) {
566
- if (isType(input)) {
567
- return input;
568
- }
569
- context.errors.push({
570
- instancePath: context.instancePath,
571
- schemaPath: `${context.schemaPath}/enum`,
572
- message: `Error at ${context.instancePath}. Invalid enum value. Expected one of the following values: [${enumVal.join(
573
- ", "
574
- )}]`
575
- });
576
- return void 0;
577
- },
632
+ parse,
578
633
  coerce: (input, context) => {
579
634
  if (isType(input)) {
580
635
  return input;
@@ -586,7 +641,7 @@ function enumerator(paramA, paramB) {
586
641
  ", "
587
642
  )}]`
588
643
  });
589
- return void 0;
644
+ return undefined;
590
645
  },
591
646
  validate: isType,
592
647
  serialize(input, context) {
@@ -596,8 +651,11 @@ function enumerator(paramA, paramB) {
596
651
  return `"${input}"`;
597
652
  }
598
653
  }
599
- }
654
+ },
655
+ "~standard": createStandardSchemaProperty(isType, parse)
600
656
  };
657
+ hideInvalidProperties(result);
658
+ return result;
601
659
  }
602
660
 
603
661
  function nullable(schema, opts = {}) {
@@ -607,7 +665,16 @@ function nullable(schema, opts = {}) {
607
665
  }
608
666
  return schema.metadata[SCHEMA_METADATA].validate(val);
609
667
  };
610
- return {
668
+ const parse = (val, data) => {
669
+ if (data.instancePath.length === 0 && typeof val === "string" && val === "null") {
670
+ return null;
671
+ }
672
+ if (val === null) {
673
+ return null;
674
+ }
675
+ return schema.metadata[SCHEMA_METADATA].parse(val, data);
676
+ };
677
+ const result = {
611
678
  ...schema,
612
679
  nullable: true,
613
680
  metadata: {
@@ -618,15 +685,7 @@ function nullable(schema, opts = {}) {
618
685
  output: null,
619
686
  optional: schema.metadata[SCHEMA_METADATA].optional,
620
687
  validate: isType,
621
- parse(val, data) {
622
- if (data.instancePath.length === 0 && typeof val === "string" && val === "null") {
623
- return null;
624
- }
625
- if (val === null) {
626
- return null;
627
- }
628
- return schema.metadata[SCHEMA_METADATA].parse(val, data);
629
- },
688
+ parse,
630
689
  coerce(val, data) {
631
690
  if (val === null) {
632
691
  return null;
@@ -648,39 +707,42 @@ function nullable(schema, opts = {}) {
648
707
  }
649
708
  }
650
709
  };
710
+ hideInvalidProperties(result);
711
+ return result;
651
712
  }
652
713
  function optional(input, opts = {}) {
653
714
  const isType = (val) => {
654
- if (val === void 0) {
715
+ if (val === undefined) {
655
716
  return true;
656
717
  }
657
718
  return input.metadata[SCHEMA_METADATA].validate(val);
658
719
  };
659
- return {
720
+ const parse = (val, context) => {
721
+ if (typeof val === "undefined") {
722
+ return undefined;
723
+ }
724
+ if (context.instancePath.length === 0 && val === "undefined") {
725
+ return undefined;
726
+ }
727
+ return input.metadata[SCHEMA_METADATA].parse(val, context);
728
+ };
729
+ const result = {
660
730
  ...input,
661
731
  metadata: {
662
732
  id: opts.id ?? input.metadata.id,
663
733
  description: opts.description ?? input.metadata.description,
664
734
  isDeprecated: opts.isDeprecated ?? input.metadata.isDeprecated,
665
735
  [SCHEMA_METADATA]: {
666
- output: void 0,
736
+ output: undefined,
667
737
  optional: true,
668
738
  validate: isType,
669
- parse: (val, data) => {
670
- if (typeof val === "undefined") {
671
- return void 0;
672
- }
673
- if (data.instancePath.length === 0 && val === "undefined") {
674
- return void 0;
675
- }
676
- return input.metadata[SCHEMA_METADATA].parse(val, data);
677
- },
739
+ parse,
678
740
  coerce: (val, data) => {
679
741
  if (typeof val === "undefined") {
680
- return void 0;
742
+ return undefined;
681
743
  }
682
744
  if (val === "undefined") {
683
- return void 0;
745
+ return undefined;
684
746
  }
685
747
  return input.metadata[SCHEMA_METADATA].coerce(val, data);
686
748
  },
@@ -691,8 +753,11 @@ function optional(input, opts = {}) {
691
753
  return input.metadata[SCHEMA_METADATA].serialize(val, data);
692
754
  }
693
755
  }
694
- }
756
+ },
757
+ "~standard": createStandardSchemaProperty(isType, parse)
695
758
  };
759
+ hideInvalidProperties(result);
760
+ return result;
696
761
  }
697
762
  function clone(input, opts = {}) {
698
763
  const schema = {
@@ -704,8 +769,10 @@ function clone(input, opts = {}) {
704
769
  [SCHEMA_METADATA]: {
705
770
  ...input.metadata[SCHEMA_METADATA]
706
771
  }
707
- }
772
+ },
773
+ "~standard": input["~standard"]
708
774
  };
775
+ hideInvalidProperties(schema);
709
776
  return schema;
710
777
  }
711
778
 
@@ -721,7 +788,7 @@ function coerceNumber(input, options) {
721
788
  schemaPath: `${options.schemaPath}/type`,
722
789
  message: `Error at ${options.instancePath}. Unable to coerce ${typeof input} into a number`
723
790
  });
724
- return void 0;
791
+ return undefined;
725
792
  }
726
793
  return parseNumber(parsedInput, options);
727
794
  }
@@ -846,7 +913,7 @@ function int64(opts = {}) {
846
913
  schemaPath: `${data.schemaPath}/type`,
847
914
  instancePath: data.instancePath
848
915
  });
849
- return void 0;
916
+ return undefined;
850
917
  }
851
918
  }
852
919
  if (isType(input)) {
@@ -857,9 +924,9 @@ function int64(opts = {}) {
857
924
  schemaPath: `${data.schemaPath}/type`,
858
925
  instancePath: data.instancePath
859
926
  });
860
- return void 0;
927
+ return undefined;
861
928
  }
862
- return {
929
+ const result = {
863
930
  type: "int64",
864
931
  metadata: {
865
932
  id: opts.id,
@@ -877,8 +944,11 @@ function int64(opts = {}) {
877
944
  return `"${input.toString()}"`;
878
945
  }
879
946
  }
880
- }
947
+ },
948
+ "~standard": createStandardSchemaProperty(isType, parse)
881
949
  };
950
+ hideInvalidProperties(result);
951
+ return result;
882
952
  }
883
953
  function uint64(opts = {}) {
884
954
  function isType(input) {
@@ -903,7 +973,7 @@ function uint64(opts = {}) {
903
973
  schemaPath: `${data.schemaPath}/type`,
904
974
  instancePath: data.instancePath
905
975
  });
906
- return void 0;
976
+ return undefined;
907
977
  }
908
978
  }
909
979
  if (isType(input)) {
@@ -914,9 +984,9 @@ function uint64(opts = {}) {
914
984
  schemaPath: `${data.schemaPath}/type`,
915
985
  instancePath: data.instancePath
916
986
  });
917
- return void 0;
987
+ return undefined;
918
988
  }
919
- return {
989
+ const result = {
920
990
  type: "uint64",
921
991
  metadata: {
922
992
  id: opts.id,
@@ -934,11 +1004,14 @@ function uint64(opts = {}) {
934
1004
  return `"${input.toString()}"`;
935
1005
  }
936
1006
  }
937
- }
1007
+ },
1008
+ "~standard": createStandardSchemaProperty(isType, parse)
938
1009
  };
1010
+ hideInvalidProperties(result);
1011
+ return result;
939
1012
  }
940
1013
  function validateNumber(input) {
941
- return typeof input === "number" || !Number.isNaN(input);
1014
+ return typeof input === "number";
942
1015
  }
943
1016
  function validateInt(input, minVal, maxValue) {
944
1017
  return Number.isInteger(input) && input >= minVal && input <= maxValue;
@@ -955,7 +1028,7 @@ function parseNumber(input, options) {
955
1028
  schemaPath: `${options.schemaPath}/type`,
956
1029
  message: `Error at ${options.instancePath}. Invalid number.`
957
1030
  });
958
- return void 0;
1031
+ return undefined;
959
1032
  }
960
1033
  return result;
961
1034
  }
@@ -967,10 +1040,41 @@ function parseNumber(input, options) {
967
1040
  schemaPath: `${options.schemaPath}/type`,
968
1041
  message: `Error at ${options.instancePath}. Invalid number.`
969
1042
  });
970
- return void 0;
1043
+ return undefined;
971
1044
  }
972
1045
  function numberScalarType(type, opts, numTypeMatcher) {
973
- return {
1046
+ const validate = (input) => {
1047
+ const isNum = validateNumber(input);
1048
+ if (!isNum) {
1049
+ return false;
1050
+ }
1051
+ return numTypeMatcher(input).success;
1052
+ };
1053
+ const parse = (input, context) => {
1054
+ const result2 = parseNumber(input, context);
1055
+ if (context.errors.length) {
1056
+ return undefined;
1057
+ }
1058
+ if (typeof result2 !== "number") {
1059
+ context?.errors.push({
1060
+ instancePath: context.instancePath,
1061
+ schemaPath: `${context.schemaPath}/type`,
1062
+ message: `Error at ${context.instancePath}. Invalid number.`
1063
+ });
1064
+ return undefined;
1065
+ }
1066
+ const matchResult = numTypeMatcher(result2);
1067
+ if (matchResult.success) {
1068
+ return result2;
1069
+ }
1070
+ context?.errors.push({
1071
+ instancePath: context.instancePath,
1072
+ schemaPath: `${context.schemaPath}/type`,
1073
+ message: `Error at ${context.instancePath}. ${matchResult.message}`
1074
+ });
1075
+ return undefined;
1076
+ };
1077
+ const result = {
974
1078
  type,
975
1079
  metadata: {
976
1080
  id: opts.id,
@@ -978,62 +1082,36 @@ function numberScalarType(type, opts, numTypeMatcher) {
978
1082
  isDeprecated: opts.isDeprecated,
979
1083
  [SCHEMA_METADATA]: {
980
1084
  output: 0,
981
- validate(input) {
982
- const isNum = validateNumber(input);
983
- if (!isNum) {
984
- return false;
985
- }
986
- return numTypeMatcher(input).success;
987
- },
988
- parse(input, options) {
989
- const result = parseNumber(input, options);
990
- if (options.errors.length) {
991
- return void 0;
992
- }
993
- if (typeof result !== "number") {
994
- options?.errors.push({
995
- instancePath: options.instancePath,
996
- schemaPath: `${options.schemaPath}/type`,
997
- message: `Error at ${options.instancePath}. Invalid number.`
998
- });
999
- return void 0;
1000
- }
1001
- const matchResult = numTypeMatcher(result);
1002
- if (matchResult.success) {
1003
- return result;
1004
- }
1005
- options?.errors.push({
1006
- instancePath: options.instancePath,
1007
- schemaPath: `${options.schemaPath}/type`,
1008
- message: `Error at ${options.instancePath}. ${matchResult.message}`
1009
- });
1010
- return void 0;
1011
- },
1085
+ validate,
1086
+ parse,
1012
1087
  serialize: serializeNumber,
1013
1088
  coerce(input, options) {
1014
- const result = coerceNumber(input, options);
1015
- if (typeof result !== "number") {
1089
+ const result2 = coerceNumber(input, options);
1090
+ if (typeof result2 !== "number") {
1016
1091
  options.errors.push({
1017
1092
  instancePath: options.instancePath,
1018
1093
  schemaPath: `${options.schemaPath}/type`,
1019
1094
  message: `Error at ${options.instancePath}. Unable to coerce ${typeof input} to ${type}.`
1020
1095
  });
1021
- return void 0;
1096
+ return undefined;
1022
1097
  }
1023
- const matchResult = numTypeMatcher(result);
1098
+ const matchResult = numTypeMatcher(result2);
1024
1099
  if (matchResult.success) {
1025
- return result;
1100
+ return result2;
1026
1101
  }
1027
1102
  options.errors.push({
1028
1103
  instancePath: options.instancePath,
1029
1104
  schemaPath: `${options.schemaPath}/type`,
1030
1105
  message: `Error at ${options.instancePath}. ${matchResult.message}`
1031
1106
  });
1032
- return void 0;
1107
+ return undefined;
1033
1108
  }
1034
1109
  }
1035
- }
1110
+ },
1111
+ "~standard": createStandardSchemaProperty(validate, parse)
1036
1112
  };
1113
+ hideInvalidProperties(result);
1114
+ return result;
1037
1115
  }
1038
1116
 
1039
1117
  function object(propA, propB) {
@@ -1057,6 +1135,17 @@ function object(propA, propB) {
1057
1135
  }
1058
1136
  schema.properties[key] = prop;
1059
1137
  }
1138
+ const validate = (input2) => {
1139
+ return validateObjectSchema(schema, input2);
1140
+ };
1141
+ const parse = (input2, context) => {
1142
+ return parseObjectSchema(
1143
+ schema,
1144
+ input2,
1145
+ context,
1146
+ false
1147
+ );
1148
+ };
1060
1149
  const result = {
1061
1150
  ...schema,
1062
1151
  metadata: {
@@ -1065,14 +1154,7 @@ function object(propA, propB) {
1065
1154
  isDeprecated: options.isDeprecated,
1066
1155
  [SCHEMA_METADATA]: {
1067
1156
  output: {},
1068
- parse(input2, context) {
1069
- return parseObjectSchema(
1070
- schema,
1071
- input2,
1072
- context,
1073
- false
1074
- );
1075
- },
1157
+ parse,
1076
1158
  coerce(input2, context) {
1077
1159
  return parseObjectSchema(
1078
1160
  schema,
@@ -1081,9 +1163,7 @@ function object(propA, propB) {
1081
1163
  true
1082
1164
  );
1083
1165
  },
1084
- validate(input2) {
1085
- return validateObjectSchema(schema, input2);
1086
- },
1166
+ validate,
1087
1167
  serialize(input2, context) {
1088
1168
  return serializeObject(
1089
1169
  schema,
@@ -1092,8 +1172,10 @@ function object(propA, propB) {
1092
1172
  );
1093
1173
  }
1094
1174
  }
1095
- }
1175
+ },
1176
+ "~standard": createStandardSchemaProperty(validate, parse)
1096
1177
  };
1178
+ hideInvalidProperties(result);
1097
1179
  return result;
1098
1180
  }
1099
1181
  function parseObjectSchema(schema, input, data, coerce = false) {
@@ -1108,7 +1190,7 @@ function parseObjectSchema(schema, input, data, coerce = false) {
1108
1190
  schemaPath: `${data.schemaPath}/properties`,
1109
1191
  message: `Error at ${data.instancePath}. Invalid JSON.`
1110
1192
  });
1111
- return void 0;
1193
+ return undefined;
1112
1194
  }
1113
1195
  }
1114
1196
  if (!isObject(parsedInput)) {
@@ -1117,7 +1199,7 @@ function parseObjectSchema(schema, input, data, coerce = false) {
1117
1199
  schemaPath: `${data.schemaPath}/properties`,
1118
1200
  message: `Error at ${data.instancePath}. Expected object`
1119
1201
  });
1120
- return void 0;
1202
+ return undefined;
1121
1203
  }
1122
1204
  const result = {};
1123
1205
  const optionalProps = schema.optionalProperties ?? {};
@@ -1136,7 +1218,7 @@ function parseObjectSchema(schema, input, data, coerce = false) {
1136
1218
  }
1137
1219
  }
1138
1220
  if (data.errors.length) {
1139
- return void 0;
1221
+ return undefined;
1140
1222
  }
1141
1223
  if (data.discriminatorKey) {
1142
1224
  result[data.discriminatorKey] = data.discriminatorValue;
@@ -1161,7 +1243,7 @@ function parseObjectSchema(schema, input, data, coerce = false) {
1161
1243
  for (const key of optionalKeys) {
1162
1244
  const val = parsedInput[key];
1163
1245
  const prop = optionalProps[key];
1164
- if (val === void 0) {
1246
+ if (val === undefined) {
1165
1247
  continue;
1166
1248
  }
1167
1249
  if (coerce) {
@@ -1181,7 +1263,7 @@ function parseObjectSchema(schema, input, data, coerce = false) {
1181
1263
  }
1182
1264
  }
1183
1265
  if (data.errors.length) {
1184
- return void 0;
1266
+ return undefined;
1185
1267
  }
1186
1268
  return result;
1187
1269
  }
@@ -1189,17 +1271,28 @@ function validateObjectSchema(schema, input) {
1189
1271
  if (!isObject(input)) {
1190
1272
  return false;
1191
1273
  }
1192
- const optionalProps = schema.optionalProperties ?? {};
1193
- for (const key of Object.keys(input)) {
1194
- const prop = schema.properties[key] ?? optionalProps[key];
1195
- if (!prop && schema.strict) {
1196
- return false;
1274
+ const allowedKeys = schema.strict ? [] : undefined;
1275
+ for (const key of Object.keys(schema.properties)) {
1276
+ const propSchema = schema.properties[key];
1277
+ const isValid = propSchema.metadata[SCHEMA_METADATA].validate(
1278
+ input[key]
1279
+ );
1280
+ if (!isValid) return false;
1281
+ allowedKeys?.push(key);
1282
+ }
1283
+ if (schema.optionalProperties) {
1284
+ for (const key of Object.keys(schema.optionalProperties)) {
1285
+ const propsSchema = schema.optionalProperties[key];
1286
+ const isValid = propsSchema.metadata[SCHEMA_METADATA].validate(
1287
+ input[key]
1288
+ );
1289
+ if (!isValid) return false;
1290
+ allowedKeys?.push(key);
1197
1291
  }
1198
- if (prop) {
1199
- const isValid = prop.metadata[SCHEMA_METADATA].validate(input[key]);
1200
- if (!isValid) {
1201
- return false;
1202
- }
1292
+ }
1293
+ if (allowedKeys) {
1294
+ for (const key of Object.keys(input)) {
1295
+ if (!allowedKeys.includes(key)) return false;
1203
1296
  }
1204
1297
  }
1205
1298
  return true;
@@ -1231,7 +1324,13 @@ function pick(inputSchema, keys, options = {}) {
1231
1324
  }
1232
1325
  });
1233
1326
  }
1234
- return {
1327
+ const parse = (input, context) => {
1328
+ return parseObjectSchema(schema, input, context, false);
1329
+ };
1330
+ const validate = (input) => {
1331
+ return validateObjectSchema(schema, input);
1332
+ };
1333
+ const result = {
1235
1334
  ...schema,
1236
1335
  metadata: {
1237
1336
  id: options.id,
@@ -1239,14 +1338,7 @@ function pick(inputSchema, keys, options = {}) {
1239
1338
  isDeprecated: options.isDeprecated,
1240
1339
  [SCHEMA_METADATA]: {
1241
1340
  output: {},
1242
- parse: (input, context) => {
1243
- return parseObjectSchema(
1244
- schema,
1245
- input,
1246
- context,
1247
- true
1248
- );
1249
- },
1341
+ parse,
1250
1342
  coerce(input, context) {
1251
1343
  return parseObjectSchema(
1252
1344
  schema,
@@ -1255,15 +1347,16 @@ function pick(inputSchema, keys, options = {}) {
1255
1347
  false
1256
1348
  );
1257
1349
  },
1258
- validate(input) {
1259
- return validateObjectSchema(schema, input);
1260
- },
1350
+ validate,
1261
1351
  serialize(input, context) {
1262
1352
  return serializeObject(schema, input, context);
1263
1353
  }
1264
1354
  }
1265
- }
1355
+ },
1356
+ "~standard": createStandardSchemaProperty(validate, parse)
1266
1357
  };
1358
+ hideInvalidProperties(result);
1359
+ return result;
1267
1360
  }
1268
1361
  function omit(inputSchema, keys, options = {}) {
1269
1362
  const schema = {
@@ -1293,7 +1386,9 @@ function omit(inputSchema, keys, options = {}) {
1293
1386
  }
1294
1387
  });
1295
1388
  }
1296
- return {
1389
+ const validate = (input) => validateObjectSchema(schema, input);
1390
+ const parse = (input, context) => parseObjectSchema(schema, input, context, false);
1391
+ const result = {
1297
1392
  ...schema,
1298
1393
  metadata: {
1299
1394
  id: options.id,
@@ -1301,12 +1396,8 @@ function omit(inputSchema, keys, options = {}) {
1301
1396
  isDeprecated: options.isDeprecated,
1302
1397
  [SCHEMA_METADATA]: {
1303
1398
  output: {},
1304
- validate(input) {
1305
- return validateObjectSchema(schema, input);
1306
- },
1307
- parse(input, data) {
1308
- return parseObjectSchema(schema, input, data, false);
1309
- },
1399
+ validate,
1400
+ parse,
1310
1401
  serialize(input, context) {
1311
1402
  return serializeObject(schema, input, context);
1312
1403
  },
@@ -1319,8 +1410,11 @@ function omit(inputSchema, keys, options = {}) {
1319
1410
  );
1320
1411
  }
1321
1412
  }
1322
- }
1413
+ },
1414
+ "~standard": createStandardSchemaProperty(validate, parse)
1323
1415
  };
1416
+ hideInvalidProperties(result);
1417
+ return result;
1324
1418
  }
1325
1419
  function serializeObject(schema, input, data) {
1326
1420
  const strParts = [];
@@ -1417,23 +1511,20 @@ function partial(schema, options = {}) {
1417
1511
  }
1418
1512
  }
1419
1513
  }
1514
+ const validate = (input) => {
1515
+ return validateObjectSchema(newSchema, input);
1516
+ };
1517
+ const parse = (input, context) => {
1518
+ return parseObjectSchema(newSchema, input, context, false);
1519
+ };
1420
1520
  const meta = {
1421
1521
  id: options.id,
1422
1522
  description: options.description,
1423
1523
  [SCHEMA_METADATA]: {
1424
1524
  output: {},
1425
1525
  optional: schema.metadata[SCHEMA_METADATA].optional,
1426
- validate(input) {
1427
- return validateObjectSchema(newSchema, input);
1428
- },
1429
- parse(input, context) {
1430
- return parseObjectSchema(
1431
- newSchema,
1432
- input,
1433
- context,
1434
- false
1435
- );
1436
- },
1526
+ validate,
1527
+ parse,
1437
1528
  coerce(input, context) {
1438
1529
  return parseObjectSchema(
1439
1530
  newSchema,
@@ -1448,11 +1539,118 @@ function partial(schema, options = {}) {
1448
1539
  }
1449
1540
  };
1450
1541
  newSchema.metadata = meta;
1542
+ newSchema["~standard"] = createStandardSchemaProperty(
1543
+ validate,
1544
+ parse
1545
+ );
1546
+ hideInvalidProperties(newSchema);
1451
1547
  return newSchema;
1452
1548
  }
1453
1549
 
1550
+ function string(opts = {}) {
1551
+ const result = {
1552
+ type: "string",
1553
+ metadata: {
1554
+ id: opts.id,
1555
+ description: opts.description,
1556
+ isDeprecated: opts.isDeprecated,
1557
+ [SCHEMA_METADATA]: {
1558
+ output: "",
1559
+ parse: parse$2,
1560
+ coerce: coerce$1,
1561
+ validate: validate$1,
1562
+ serialize(input, context) {
1563
+ if (context.instancePath.length === 0) {
1564
+ return input;
1565
+ }
1566
+ if (input.length < 42) {
1567
+ return serializeSmallString(input);
1568
+ }
1569
+ if (input.length < 5e3 && !STR_ESCAPE.test(input)) {
1570
+ return `"${input}"`;
1571
+ }
1572
+ return JSON.stringify(input);
1573
+ }
1574
+ }
1575
+ },
1576
+ "~standard": createStandardSchemaProperty(validate$1, parse$2)
1577
+ };
1578
+ hideInvalidProperties(result);
1579
+ return result;
1580
+ }
1581
+ function serializeString(input) {
1582
+ if (input.length < 42) {
1583
+ return serializeSmallString(input);
1584
+ }
1585
+ if (input.length < 5e3 && !STR_ESCAPE.test(input)) {
1586
+ return `"${input}"`;
1587
+ }
1588
+ return JSON.stringify(input);
1589
+ }
1590
+ function validate$1(input) {
1591
+ return typeof input === "string";
1592
+ }
1593
+ function parse$2(input, context) {
1594
+ if (validate$1(input)) {
1595
+ return input;
1596
+ }
1597
+ context.errors.push({
1598
+ instancePath: context.instancePath,
1599
+ schemaPath: `${context.schemaPath}/type`,
1600
+ message: `Error at ${context.instancePath}. Expected 'string' got ${typeof input}.`
1601
+ });
1602
+ return undefined;
1603
+ }
1604
+ function coerce$1(input, context) {
1605
+ return parse$2(input, context);
1606
+ }
1607
+ const STR_ESCAPE = (
1608
+ // eslint-disable-next-line no-control-regex
1609
+ /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/
1610
+ );
1611
+ function serializeSmallString(input) {
1612
+ const len = input.length;
1613
+ let result = "";
1614
+ let last = -1;
1615
+ let point = 255;
1616
+ for (let i = 0; i < len; i++) {
1617
+ point = input.charCodeAt(i);
1618
+ if (point < 32 || point >= 55296 && point <= 57343) {
1619
+ return JSON.stringify(input);
1620
+ }
1621
+ if (point === 34 || // '"'
1622
+ point === 92) {
1623
+ if (last === -1) {
1624
+ last = 0;
1625
+ }
1626
+ result += input.slice(last, i) + "\\";
1627
+ last = i;
1628
+ }
1629
+ }
1630
+ if (last === -1) {
1631
+ return `"${input}"`;
1632
+ }
1633
+ return `"${result}${input.slice(last)}"`;
1634
+ }
1635
+
1454
1636
  function record(schema, opts = {}) {
1455
- return {
1637
+ const validateFn = (input) => {
1638
+ if (!isObject(input)) {
1639
+ return false;
1640
+ }
1641
+ for (const key of Object.keys(input)) {
1642
+ const val = input[key];
1643
+ const isValid = schema.metadata[SCHEMA_METADATA].validate(val);
1644
+ if (!isValid) {
1645
+ return false;
1646
+ }
1647
+ }
1648
+ return true;
1649
+ };
1650
+ const parseFn = (input, ctx) => {
1651
+ return parse$1(schema, input, ctx, false);
1652
+ };
1653
+ const result = {
1456
1654
  values: schema,
1457
1655
  metadata: {
1458
1656
  id: opts.id,
@@ -1460,48 +1658,40 @@ function record(schema, opts = {}) {
1460
1658
  isDeprecated: opts.isDeprecated,
1461
1659
  [SCHEMA_METADATA]: {
1462
1660
  output: {},
1463
- validate(input) {
1464
- if (!isObject(input)) {
1465
- return false;
1466
- }
1467
- for (const key of Object.keys(input)) {
1468
- const val = input[key];
1469
- const isValid = schema.metadata[SCHEMA_METADATA].validate(val);
1470
- if (!isValid) {
1471
- return false;
1472
- }
1473
- }
1474
- return true;
1475
- },
1476
- parse(input, context) {
1477
- return parse$2(schema, input, context, false);
1478
- },
1661
+ validate: validateFn,
1662
+ parse: parseFn,
1479
1663
  coerce(input, data) {
1480
- return parse$2(schema, input, data, true);
1664
+ return parse$1(schema, input, data, true);
1481
1665
  },
1482
1666
  serialize(input, context) {
1483
- const strParts = [];
1484
- for (const key of Object.keys(input)) {
1667
+ let result2 = "{";
1668
+ const keys = Object.keys(input);
1669
+ for (let i = 0; i < keys.length; i++) {
1670
+ const key = keys[i];
1485
1671
  const val = input[key];
1486
- strParts.push(
1487
- `${JSON.stringify(key)}:${schema.metadata[SCHEMA_METADATA].serialize(val, {
1672
+ if (i > 0) result2 += ",";
1673
+ result2 += serializeString(key);
1674
+ result2 += ":";
1675
+ result2 += schema.metadata[SCHEMA_METADATA].serialize(
1676
+ val,
1677
+ {
1488
1678
  instancePath: `${context.instancePath}/${key}`,
1489
1679
  schemaPath: `${context.schemaPath}/values`,
1490
1680
  errors: context.errors
1491
- })}`
1681
+ }
1492
1682
  );
1493
1683
  }
1494
- const result = `{${strParts.join(",")}}`;
1495
- if (context.instancePath.length === 0) {
1496
- return sanitizeJson(result);
1497
- }
1498
- return result;
1684
+ result2 += "}";
1685
+ return result2;
1499
1686
  }
1500
1687
  }
1501
- }
1688
+ },
1689
+ "~standard": createStandardSchemaProperty(validateFn, parseFn)
1502
1690
  };
1691
+ hideInvalidProperties(result);
1692
+ return result;
1503
1693
  }
1504
- function parse$2(schema, input, data, coerce = false) {
1694
+ function parse$1(schema, input, data, coerce = false) {
1505
1695
  let parsedInput = input;
1506
1696
  if (data.instancePath.length === 0 && typeof input === "string") {
1507
1697
  parsedInput = JSON.parse(input);
@@ -1512,7 +1702,7 @@ function parse$2(schema, input, data, coerce = false) {
1512
1702
  schemaPath: `${data.schemaPath}/values`,
1513
1703
  message: `Error at ${data.instancePath} Expected object`
1514
1704
  });
1515
- return void 0;
1705
+ return undefined;
1516
1706
  }
1517
1707
  const result = {};
1518
1708
  for (const key of Object.keys(parsedInput)) {
@@ -1532,7 +1722,7 @@ function parse$2(schema, input, data, coerce = false) {
1532
1722
  }
1533
1723
  }
1534
1724
  if (data.errors.length) {
1535
- return void 0;
1725
+ return undefined;
1536
1726
  }
1537
1727
  return result;
1538
1728
  }
@@ -1550,36 +1740,43 @@ function recursive(propA, propB) {
1550
1740
  );
1551
1741
  }
1552
1742
  const id = options.id ?? `TypeRef${recursiveTypeCount}`;
1553
- const mainSchema = callback({
1554
- ref: id,
1555
- metadata: {
1556
- [SCHEMA_METADATA]: {
1557
- output: "",
1558
- parse(input, context) {
1559
- if (recursiveFns[id]) {
1560
- return recursiveFns[id].parse(input, context);
1561
- }
1562
- },
1563
- serialize(input, context) {
1564
- if (recursiveFns[id]) {
1565
- return recursiveFns[id].serialize(input, context);
1566
- }
1567
- return "";
1568
- },
1569
- validate(input) {
1570
- if (recursiveFns[id]) {
1571
- return recursiveFns[id].validate(input);
1572
- }
1573
- return false;
1574
- },
1575
- coerce(input, context) {
1576
- if (recursiveFns[id]) {
1577
- return recursiveFns[id].coerce(input, context);
1578
- }
1743
+ const metadata = {
1744
+ [SCHEMA_METADATA]: {
1745
+ output: "",
1746
+ parse(input, context) {
1747
+ if (recursiveFns[id]) {
1748
+ return recursiveFns[id].parse(input, context);
1749
+ }
1750
+ },
1751
+ serialize(input, context) {
1752
+ if (recursiveFns[id]) {
1753
+ return recursiveFns[id].serialize(input, context);
1754
+ }
1755
+ return "";
1756
+ },
1757
+ validate(input) {
1758
+ if (recursiveFns[id]) {
1759
+ return recursiveFns[id].validate(input);
1760
+ }
1761
+ return false;
1762
+ },
1763
+ coerce(input, context) {
1764
+ if (recursiveFns[id]) {
1765
+ return recursiveFns[id].coerce(input, context);
1579
1766
  }
1580
1767
  }
1581
1768
  }
1582
- });
1769
+ };
1770
+ const schema = {
1771
+ ref: id,
1772
+ metadata,
1773
+ "~standard": createStandardSchemaProperty(
1774
+ metadata[SCHEMA_METADATA].validate,
1775
+ metadata[SCHEMA_METADATA].parse
1776
+ )
1777
+ };
1778
+ hideInvalidProperties(schema);
1779
+ const mainSchema = callback(schema);
1583
1780
  mainSchema.metadata.id = id;
1584
1781
  mainSchema.metadata.description = options?.description ?? mainSchema.metadata.description;
1585
1782
  mainSchema.metadata.isDeprecated = options?.isDeprecated ?? mainSchema.metadata.isDeprecated;
@@ -1592,82 +1789,8 @@ function recursive(propA, propB) {
1592
1789
  return mainSchema;
1593
1790
  }
1594
1791
 
1595
- function string(opts = {}) {
1596
- return {
1597
- type: "string",
1598
- metadata: {
1599
- id: opts.id,
1600
- description: opts.description,
1601
- isDeprecated: opts.isDeprecated,
1602
- [SCHEMA_METADATA]: {
1603
- output: "",
1604
- parse: parse$1,
1605
- coerce: coerce$1,
1606
- validate: validate$1,
1607
- serialize(input, context) {
1608
- if (context.instancePath.length === 0) {
1609
- return input;
1610
- }
1611
- if (input.length < 42) {
1612
- return serializeSmallString(input);
1613
- }
1614
- if (input.length < 5e3 && !STR_ESCAPE.test(input)) {
1615
- return `"${input}"`;
1616
- }
1617
- return JSON.stringify(input);
1618
- }
1619
- }
1620
- }
1621
- };
1622
- }
1623
- function validate$1(input) {
1624
- return typeof input === "string";
1625
- }
1626
- function parse$1(input, context) {
1627
- if (validate$1(input)) {
1628
- return input;
1629
- }
1630
- context.errors.push({
1631
- instancePath: context.instancePath,
1632
- schemaPath: `${context.schemaPath}/type`,
1633
- message: `Error at ${context.instancePath}. Expected 'string' got ${typeof input}.`
1634
- });
1635
- return void 0;
1636
- }
1637
- function coerce$1(input, context) {
1638
- return parse$1(input, context);
1639
- }
1640
- const STR_ESCAPE = (
1641
- // eslint-disable-next-line no-control-regex
1642
- /[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/
1643
- );
1644
- function serializeSmallString(input) {
1645
- const len = input.length;
1646
- let result = "";
1647
- let last = -1;
1648
- let point = 255;
1649
- for (let i = 0; i < len; i++) {
1650
- point = input.charCodeAt(i);
1651
- if (point < 32 || point >= 55296 && point <= 57343) {
1652
- return JSON.stringify(input);
1653
- }
1654
- if (point === 34 || // '"'
1655
- point === 92) {
1656
- if (last === -1) {
1657
- last = 0;
1658
- }
1659
- result += input.slice(last, i) + "\\";
1660
- last = i;
1661
- }
1662
- }
1663
- if (last === -1) {
1664
- return `"${input}"`;
1665
- }
1666
- return `"${result}${input.slice(last)}"`;
1667
- }
1668
-
1669
1792
  function timestamp(opts = {}) {
1670
- return {
1793
+ const result = {
1671
1794
  type: "timestamp",
1672
1795
  metadata: {
1673
1796
  id: opts.id,
@@ -1680,8 +1803,11 @@ function timestamp(opts = {}) {
1680
1803
  coerce,
1681
1804
  serialize
1682
1805
  }
1683
- }
1806
+ },
1807
+ "~standard": createStandardSchemaProperty(validate, parse)
1684
1808
  };
1809
+ hideInvalidProperties(result);
1810
+ return result;
1685
1811
  }
1686
1812
  function validate(input) {
1687
1813
  return typeof input === "object" && input instanceof Date;
@@ -1698,7 +1824,7 @@ function parse(input, data) {
1698
1824
  instancePath: data.instancePath,
1699
1825
  schemaPath: `${data.schemaPath}/type`
1700
1826
  });
1701
- return void 0;
1827
+ return undefined;
1702
1828
  }
1703
1829
  return new Date(result);
1704
1830
  }
@@ -1707,7 +1833,7 @@ function parse(input, data) {
1707
1833
  instancePath: data.instancePath,
1708
1834
  schemaPath: `${data.schemaPath}/type`
1709
1835
  });
1710
- return void 0;
1836
+ return undefined;
1711
1837
  }
1712
1838
  function coerce(input, options) {
1713
1839
  if (typeof input === "number") {
@@ -1722,4 +1848,4 @@ function serialize(input, data) {
1722
1848
  return `"${input.toISOString()}"`;
1723
1849
  }
1724
1850
 
1725
- export { uint64 as $, enumerator as A, extend as B, float32 as C, float64 as D, int16 as E, int32 as F, int64 as G, int8 as H, nullable as I, number as J, object as K, omit as L, optional as M, parse$4 as N, partial as O, pick as P, record as Q, recursive as R, safeCoerce as S, safeParse as T, serialize$1 as U, ValidationError as V, string as W, stringEnum as X, timestamp as Y, uint16 as Z, uint32 as _, uint8Min as a, uint8 as a0, validate$3 as a1, SCHEMA_METADATA as a2, int64Min as a3, int64Max as a4, uint64Min as a5, uint64Max as a6, parseObjectSchema as a7, validateObjectSchema as a8, serializeObject as a9, serializeSmallString as aa, sanitizeJson as ab, isValidationError as ac, isASchema as ad, NumberTypeValues as ae, isObject as af, uint16Max as b, uint16Min as c, uint32Max as d, uint32Min as e, int8Min as f, int16Max as g, int16Min as h, int8Max as i, int32Max as j, int32Min as k, isAScalarSchema as l, isAObjectSchema as m, isAStringEnumSchema as n, isAAraySchema as o, isARecordSchema as p, isADiscriminatorSchema as q, isARefSchema as r, errors as s, any as t, uint8Max as u, array as v, boolean as w, clone as x, coerce$2 as y, discriminator as z };
1851
+ export { uint32 as $, discriminator as A, enumerator as B, extend as C, float32 as D, float64 as E, int16 as F, int32 as G, int64 as H, int8 as I, nullable as J, number as K, object as L, omit as M, optional as N, parse$4 as O, partial as P, pick as Q, record as R, recursive as S, safeCoerce as T, safeParse as U, ValidationError as V, serialize$1 as W, string as X, stringEnum as Y, timestamp as Z, uint16 as _, uint8Min as a, uint64 as a0, uint8 as a1, validate$3 as a2, SCHEMA_METADATA as a3, int64Min as a4, int64Max as a5, uint64Min as a6, uint64Max as a7, parseObjectSchema as a8, validateObjectSchema as a9, serializeObject as aa, serializeString as ab, STR_ESCAPE as ac, serializeSmallString as ad, sanitizeJson as ae, isValidationError as af, isASchema as ag, NumberTypeValues as ah, isObject as ai, hideInvalidProperties as aj, uint16Max as b, uint16Min as c, uint32Max as d, uint32Min as e, int8Min as f, int16Max as g, int16Min as h, int8Max as i, int32Max as j, int32Min as k, isAScalarSchema as l, isAObjectSchema as m, isAStringEnumSchema as n, isAAraySchema as o, isARecordSchema as p, isADiscriminatorSchema as q, isARefSchema as r, errors as s, createStandardSchemaProperty as t, uint8Max as u, any as v, array as w, boolean as x, clone as y, coerce$2 as z };