@arrirpc/schema 0.74.0 → 0.75.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.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isSchemaFormProperties, isSchemaFormValues, isSchemaFormElements, isSchemaFormDiscriminator, isSchemaFormEmpty, isSchemaFormType, isSchemaFormEnum, isSchemaFormRef } from '@arrirpc/type-defs';
2
- import { i as isAScalarSchema, a as isAObjectSchema, b as isAStringEnumSchema, c as isAAraySchema, d as isARecordSchema, e as isADiscriminatorSchema, f as isARefSchema, g as createStandardSchemaProperty, n as newValidationContext, V as VALIDATOR_KEY, h as hideInvalidProperties, j as isObject } from './shared/schema.CZrExOkx.mjs';
2
+ import { i as isAScalarSchema, a as isAObjectSchema, b as isAStringEnumSchema, c as isAAraySchema, d as isARecordSchema, e as isADiscriminatorSchema, f as isARefSchema, g as createStandardSchemaProperty, n as newValidationContext, h as hideInvalidProperties, V as VALIDATOR_KEY, j as isObject } from './shared/schema.CZrExOkx.mjs';
3
3
  export { N as NumberTypeValues, k as isASchema } from './shared/schema.CZrExOkx.mjs';
4
4
  import { camelCase } from 'scule';
5
5
 
@@ -676,9 +676,7 @@ function createSerializationV2Template(inputName, schema) {
676
676
  instancePath: "",
677
677
  outputPrefix: "",
678
678
  needsSanitization: [],
679
- subFunctions,
680
- shouldCoerce: undefined
681
- };
679
+ subFunctions};
682
680
  const result = template(context);
683
681
  if (isSchemaFormType(schema) || isSchemaFormEnum(schema)) {
684
682
  return result;
@@ -916,9 +914,7 @@ function objectTemplate$1(input) {
916
914
  schemaPath: `${input.schemaPath}/properties/${key}`,
917
915
  outputPrefix: includeComma ? `,"${key}":` : `"${key}":`,
918
916
  needsSanitization: input.needsSanitization,
919
- subFunctions: input.subFunctions,
920
- shouldCoerce: undefined
921
- });
917
+ subFunctions: input.subFunctions});
922
918
  templateParts.push(innerTemplate);
923
919
  }
924
920
  if (isAllOptionalKeys) {
@@ -941,9 +937,7 @@ function objectTemplate$1(input) {
941
937
  targetVal: input.targetVal,
942
938
  outputPrefix: `"${key}":`,
943
939
  needsSanitization: input.needsSanitization,
944
- subFunctions: input.subFunctions,
945
- shouldCoerce: undefined
946
- });
940
+ subFunctions: input.subFunctions});
947
941
  const innerTemplateWithComma = template({
948
942
  schema: optionalPropSchema,
949
943
  schemaPath: `${input.schemaPath}/optionalProperties/${key}`,
@@ -952,9 +946,7 @@ function objectTemplate$1(input) {
952
946
  targetVal: input.targetVal,
953
947
  outputPrefix: `,"${key}":`,
954
948
  needsSanitization: input.needsSanitization,
955
- subFunctions: input.subFunctions,
956
- shouldCoerce: undefined
957
- });
949
+ subFunctions: input.subFunctions});
958
950
  templateParts.push(`if (typeof ${innerVal} !== 'undefined') {
959
951
  if (${hasFieldsVar}) {
960
952
  ${innerTemplateWithComma}
@@ -980,9 +972,7 @@ function objectTemplate$1(input) {
980
972
  targetVal: "json",
981
973
  outputPrefix: `,"${key}":`,
982
974
  needsSanitization: input.needsSanitization,
983
- subFunctions: input.subFunctions,
984
- shouldCoerce: undefined
985
- });
975
+ subFunctions: input.subFunctions});
986
976
  const completeInnerTemplate = `if (typeof ${innerVal} !== 'undefined') {
987
977
  ${innerTemplate}
988
978
  }`;
@@ -1031,9 +1021,7 @@ function arrayTemplate$1(input) {
1031
1021
  targetVal: input.targetVal,
1032
1022
  outputPrefix: "",
1033
1023
  needsSanitization: input.needsSanitization,
1034
- subFunctions: input.subFunctions,
1035
- shouldCoerce: undefined
1036
- });
1024
+ subFunctions: input.subFunctions});
1037
1025
  templateParts.push(`for (let i = 0; i < ${input.val}.length; i++) {
1038
1026
  const ${itemVarName} = ${input.val}[i];
1039
1027
  if (i !== 0) {
@@ -1066,9 +1054,7 @@ function recordTemplate$1(input) {
1066
1054
  targetVal: input.targetVal,
1067
1055
  outputPrefix: "",
1068
1056
  needsSanitization: input.needsSanitization,
1069
- subFunctions: input.subFunctions,
1070
- shouldCoerce: undefined
1071
- });
1057
+ subFunctions: input.subFunctions});
1072
1058
  templateParts.push(`for (let i = 0; i < ${keysVarName}.length; i++) {
1073
1059
  const key = ${keysVarName}[i];
1074
1060
  const innerVal = ${input.val}[key];
@@ -1136,9 +1122,7 @@ function discriminatorTemplate$1(input) {
1136
1122
  discriminatorValue: val,
1137
1123
  outputPrefix: input.outputPrefix,
1138
1124
  needsSanitization: input.needsSanitization,
1139
- subFunctions: input.subFunctions,
1140
- shouldCoerce: undefined
1141
- });
1125
+ subFunctions: input.subFunctions});
1142
1126
  templateParts.push(`case '${val}': {
1143
1127
  ${innerTemplate}
1144
1128
  break;
@@ -1206,13 +1190,10 @@ function createValidationTemplate(inputName, schema) {
1206
1190
  const subFunctions = {};
1207
1191
  const template = schemaTemplate({
1208
1192
  val: inputName,
1209
- targetVal: "",
1210
1193
  schema,
1211
1194
  schemaPath: ``,
1212
1195
  instancePath: "",
1213
- subFunctions,
1214
- shouldCoerce: undefined
1215
- });
1196
+ subFunctions});
1216
1197
  const subFunctionBodies = Object.keys(subFunctions).map(
1217
1198
  (key) => subFunctions[key]
1218
1199
  );
@@ -1332,10 +1313,7 @@ function objectTemplate(input) {
1332
1313
  schemaPath: `${input.schemaPath}/properties/${key}`,
1333
1314
  instancePath: `${input.instancePath}/${key}`,
1334
1315
  val: `${input.val}.${key}`,
1335
- targetVal: "",
1336
- subFunctions: input.subFunctions,
1337
- shouldCoerce: undefined
1338
- })
1316
+ subFunctions: input.subFunctions})
1339
1317
  );
1340
1318
  }
1341
1319
  if (input.schema.optionalProperties) {
@@ -1346,10 +1324,7 @@ function objectTemplate(input) {
1346
1324
  schemaPath: `${input.schemaPath}/optionalProperties/${key}`,
1347
1325
  instancePath: `${input.instancePath}/${key}`,
1348
1326
  val: `${input.val}.${key}`,
1349
- targetVal: "",
1350
- subFunctions: input.subFunctions,
1351
- shouldCoerce: undefined
1352
- });
1327
+ subFunctions: input.subFunctions});
1353
1328
  parts.push(
1354
1329
  `(typeof ${input.val}.${key} === 'undefined' || (${template}))`
1355
1330
  );
@@ -1383,10 +1358,7 @@ function arrayTemplate(input) {
1383
1358
  instancePath: `${input.instancePath}/item`,
1384
1359
  schemaPath: `${input.schemaPath}/elements`,
1385
1360
  schema: input.schema.elements,
1386
- targetVal: "",
1387
- subFunctions: input.subFunctions,
1388
- shouldCoerce: undefined
1389
- });
1361
+ subFunctions: input.subFunctions});
1390
1362
  if (input.schema.nullable) {
1391
1363
  return `((Array.isArray(${input.val}) && ${input.val}.every((item) => ${innerTemplate})) || ${input.val} === null)`;
1392
1364
  }
@@ -1398,10 +1370,7 @@ function recordTemplate(input) {
1398
1370
  instancePath: `${input.instancePath}`,
1399
1371
  schemaPath: `${input.schemaPath}/values`,
1400
1372
  val: `${input.val}[key]`,
1401
- targetVal: "",
1402
- subFunctions: input.subFunctions,
1403
- shouldCoerce: undefined
1404
- });
1373
+ subFunctions: input.subFunctions});
1405
1374
  const mainTemplate = `typeof ${input.val} === 'object' && ${input.val} !== null && Object.keys(${input.val}).every((key) => ${subTemplate})`;
1406
1375
  if (input.schema.nullable) {
1407
1376
  return `((${mainTemplate}) || ${input.val} === null)`;
@@ -1418,15 +1387,12 @@ function discriminatorTemplate(input) {
1418
1387
  parts.push(
1419
1388
  objectTemplate({
1420
1389
  val: input.val,
1421
- targetVal: "",
1422
1390
  schema: subSchema,
1423
1391
  schemaPath: `${input.schemaPath}/mapping/${discriminatorVal}`,
1424
1392
  instancePath: input.instancePath,
1425
1393
  discriminatorKey: input.schema.discriminator,
1426
1394
  discriminatorValue: discriminatorVal,
1427
- subFunctions: input.subFunctions,
1428
- shouldCoerce: undefined
1429
- })
1395
+ subFunctions: input.subFunctions})
1430
1396
  );
1431
1397
  }
1432
1398
  let mainTemplate = `typeof ${input.val} === 'object' && ${input.val} !== null && (${parts.join(" || ")})`;
@@ -1620,7 +1586,7 @@ function compile(schema) {
1620
1586
  const result2 = parse(input);
1621
1587
  if (!result2.success) {
1622
1588
  ctx.errors = result2.errors;
1623
- return undefined;
1589
+ return void 0;
1624
1590
  }
1625
1591
  return result2.value;
1626
1592
  })
@@ -1817,7 +1783,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1817
1783
  schemaPath: "/type",
1818
1784
  message: `Unable to coerce ${input2} into boolean`
1819
1785
  });
1820
- return undefined;
1786
+ return void 0;
1821
1787
  }
1822
1788
  }
1823
1789
  };
@@ -1846,7 +1812,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1846
1812
  schemaPath: "/type",
1847
1813
  message: `Unable to coerce ${input2} into boolean`
1848
1814
  });
1849
- return undefined;
1815
+ return void 0;
1850
1816
  }
1851
1817
  }
1852
1818
  };
@@ -1877,7 +1843,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1877
1843
  schemaPath: "/type",
1878
1844
  message: `Expected boolean. Got ${typeof input2}`
1879
1845
  });
1880
- return undefined;
1846
+ return void 0;
1881
1847
  }
1882
1848
  };
1883
1849
  }
@@ -1899,7 +1865,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1899
1865
  schemaPath: "/type",
1900
1866
  message: `Expected boolean. Got ${typeof input2}`
1901
1867
  });
1902
- return undefined;
1868
+ return void 0;
1903
1869
  },
1904
1870
  code
1905
1871
  };
@@ -1921,7 +1887,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1921
1887
  schemaPath: "/type",
1922
1888
  message: `Expected string or null. Got ${typeof input2}.`
1923
1889
  });
1924
- return undefined;
1890
+ return void 0;
1925
1891
  },
1926
1892
  code
1927
1893
  };
@@ -1936,7 +1902,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1936
1902
  instancePath: "/",
1937
1903
  schemaPath: "/type"
1938
1904
  });
1939
- return undefined;
1905
+ return void 0;
1940
1906
  },
1941
1907
  code
1942
1908
  };
@@ -1971,7 +1937,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1971
1937
  schemaPath: "/type",
1972
1938
  message: `Expected instanceof Date, ISO Date string, or null. Got ${typeof input2}.`
1973
1939
  });
1974
- return undefined;
1940
+ return void 0;
1975
1941
  },
1976
1942
  code
1977
1943
  };
@@ -1998,7 +1964,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1998
1964
  schemaPath: "/type",
1999
1965
  message: `Expected instanceof Date or ISO Date string. Got ${typeof input2}.`
2000
1966
  });
2001
- return undefined;
1967
+ return void 0;
2002
1968
  },
2003
1969
  code
2004
1970
  };
@@ -2026,7 +1992,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
2026
1992
  schemaPath: "/type",
2027
1993
  message: `Expected instanceof Date, ISO Date string, or null. Got ${typeof input2}.`
2028
1994
  });
2029
- return undefined;
1995
+ return void 0;
2030
1996
  },
2031
1997
  code
2032
1998
  };
@@ -2047,7 +2013,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
2047
2013
  schemaPath: "/type",
2048
2014
  message: `Expected instance of Date or ISO date string. Got ${typeof input2}.`
2049
2015
  });
2050
- return undefined;
2016
+ return void 0;
2051
2017
  },
2052
2018
  code
2053
2019
  };
@@ -2077,7 +2043,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
2077
2043
  ", "
2078
2044
  )}] or null. Got ${typeof input2}.`
2079
2045
  });
2080
- return undefined;
2046
+ return void 0;
2081
2047
  },
2082
2048
  code
2083
2049
  };
@@ -2098,7 +2064,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
2098
2064
  ", "
2099
2065
  )}]. Got ${typeof input2}.`
2100
2066
  });
2101
- return undefined;
2067
+ return void 0;
2102
2068
  },
2103
2069
  code
2104
2070
  };
@@ -2116,7 +2082,7 @@ function compiledFloatDecoder(input, context) {
2116
2082
  schemaPath: "/type",
2117
2083
  message: `Unable to decode number from ${input}`
2118
2084
  });
2119
- return undefined;
2085
+ return void 0;
2120
2086
  }
2121
2087
  if (typeof input === "number" && !Number.isNaN(input)) {
2122
2088
  return input;
@@ -2126,7 +2092,7 @@ function compiledFloatDecoder(input, context) {
2126
2092
  schemaPath: "/type",
2127
2093
  message: `Expected number. Got ${typeof input}`
2128
2094
  });
2129
- return undefined;
2095
+ return void 0;
2130
2096
  }
2131
2097
  function nullableFloatDecoder(input, context) {
2132
2098
  if (typeof input === "string") {
@@ -2142,7 +2108,7 @@ function nullableFloatDecoder(input, context) {
2142
2108
  schemaPath: "/type",
2143
2109
  message: `Unable to decode number from ${input}`
2144
2110
  });
2145
- return undefined;
2111
+ return void 0;
2146
2112
  }
2147
2113
  if (typeof input === "number" && !Number.isNaN(input)) {
2148
2114
  return input;
@@ -2155,7 +2121,7 @@ function nullableFloatDecoder(input, context) {
2155
2121
  schemaPath: "/type",
2156
2122
  message: `Expected number or null. Got ${typeof input}`
2157
2123
  });
2158
- return undefined;
2124
+ return void 0;
2159
2125
  }
2160
2126
  function bigIntDecoder(input, isUnsigned, isNullable, context) {
2161
2127
  if (typeof input === "string" || typeof input === "number") {
@@ -2191,7 +2157,7 @@ function bigIntDecoder(input, isUnsigned, isNullable, context) {
2191
2157
  data: err,
2192
2158
  message: `Error transforming ${input} to BigInt`
2193
2159
  });
2194
- return undefined;
2160
+ return void 0;
2195
2161
  }
2196
2162
  }
2197
2163
  if (typeof input === "bigint") {
@@ -2213,7 +2179,7 @@ function bigIntDecoder(input, isUnsigned, isNullable, context) {
2213
2179
  instancePath: "/",
2214
2180
  message: `int64 must be an integer between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807`
2215
2181
  });
2216
- return undefined;
2182
+ return void 0;
2217
2183
  }
2218
2184
  if (isNullable && input === null) {
2219
2185
  return null;
@@ -2223,7 +2189,7 @@ function bigIntDecoder(input, isUnsigned, isNullable, context) {
2223
2189
  instancePath: "/",
2224
2190
  message: "Expected BigInt or Integer string"
2225
2191
  });
2226
- return undefined;
2192
+ return void 0;
2227
2193
  }
2228
2194
  function nullableIntDecoder(input, minNum, maxNum, context) {
2229
2195
  if (typeof input === "string") {
@@ -2246,7 +2212,7 @@ function nullableIntDecoder(input, minNum, maxNum, context) {
2246
2212
  schemaPath: "/type",
2247
2213
  message: `Expected valid integer between ${minNum} & ${maxNum} or null. Got ${typeof input}.`
2248
2214
  });
2249
- return undefined;
2215
+ return void 0;
2250
2216
  }
2251
2217
  function intDecoder(input, minNum, maxNum, context) {
2252
2218
  if (typeof input === "string") {
@@ -2263,7 +2229,7 @@ function intDecoder(input, minNum, maxNum, context) {
2263
2229
  schemaPath: "/type",
2264
2230
  message: `Expected valid integer between ${minNum} & ${maxNum}`
2265
2231
  });
2266
- return undefined;
2232
+ return void 0;
2267
2233
  }
2268
2234
  function getCompiledSerializer(schema) {
2269
2235
  const code = createSerializationV2Template("input", schema);
@@ -2408,7 +2374,7 @@ function any(options = {}) {
2408
2374
  return input;
2409
2375
  };
2410
2376
  const validator = {
2411
- output: undefined,
2377
+ output: void 0,
2412
2378
  parse,
2413
2379
  coerce: (input, context) => {
2414
2380
  if (context.instancePath.length === 0 && typeof input === "string") {
@@ -2465,7 +2431,7 @@ function array(schema, opts = {}) {
2465
2431
  exitOnFirstError: context.exitOnFirstError
2466
2432
  });
2467
2433
  if (!part) {
2468
- return undefined;
2434
+ return void 0;
2469
2435
  }
2470
2436
  strParts.push(part);
2471
2437
  }
@@ -2508,7 +2474,7 @@ function parse$5(innerSchema, input, context, coerce = false) {
2508
2474
  schemaPath: `${context.schemaPath}/elements`,
2509
2475
  message: `Error at ${context.instancePath}. Invalid JSON.`
2510
2476
  });
2511
- return undefined;
2477
+ return void 0;
2512
2478
  }
2513
2479
  }
2514
2480
  if (!Array.isArray(parsedInput)) {
@@ -2517,7 +2483,7 @@ function parse$5(innerSchema, input, context, coerce = false) {
2517
2483
  schemaPath: `${context.schemaPath}/elements`,
2518
2484
  message: `Error at ${context.instancePath}. Expected array. Got ${typeof input}.`
2519
2485
  });
2520
- return undefined;
2486
+ return void 0;
2521
2487
  }
2522
2488
  const result = [];
2523
2489
  for (let i = 0; i < parsedInput.length; i++) {
@@ -2545,7 +2511,7 @@ function parse$5(innerSchema, input, context, coerce = false) {
2545
2511
  }
2546
2512
  }
2547
2513
  if (context.errors.length) {
2548
- return undefined;
2514
+ return void 0;
2549
2515
  }
2550
2516
  return result;
2551
2517
  }
@@ -2577,7 +2543,7 @@ function boolean(opts = {}) {
2577
2543
  schemaPath: context.schemaPath,
2578
2544
  message: `Error at ${context.instancePath}. Unable to coerce ${input} to boolean.`
2579
2545
  });
2580
- return undefined;
2546
+ return void 0;
2581
2547
  }
2582
2548
  };
2583
2549
  const result = {
@@ -2612,14 +2578,14 @@ function parse$4(input, data) {
2612
2578
  schemaPath: `${data.schemaPath}/type`,
2613
2579
  message: `Error at ${data.instancePath}. Expected boolean. Got ${typeof input}.`
2614
2580
  });
2615
- return undefined;
2581
+ return void 0;
2616
2582
  }
2617
2583
  data.errors.push({
2618
2584
  instancePath: data.instancePath,
2619
2585
  schemaPath: `${data.schemaPath}/type`,
2620
2586
  message: `Error at ${data.instancePath}. Expected boolean. Got ${typeof input}.`
2621
2587
  });
2622
- return undefined;
2588
+ return void 0;
2623
2589
  }
2624
2590
  function serialize$2(input) {
2625
2591
  return `${input}`;
@@ -2653,7 +2619,7 @@ function discriminator(propA, propB, propC) {
2653
2619
  context.errors.push(
2654
2620
  discriminatorMappingError(discriminatorVal, context)
2655
2621
  );
2656
- return undefined;
2622
+ return void 0;
2657
2623
  }
2658
2624
  const result2 = targetSchema[VALIDATOR_KEY].serialize(input, {
2659
2625
  instancePath: context.instancePath,
@@ -2711,7 +2677,7 @@ function parse$3(discriminator2, mapping, input, context, coerce = false) {
2711
2677
  instancePath: context.instancePath,
2712
2678
  schemaPath: context.schemaPath
2713
2679
  });
2714
- return undefined;
2680
+ return void 0;
2715
2681
  }
2716
2682
  }
2717
2683
  if (!isObject(parsedInput)) {
@@ -2720,7 +2686,7 @@ function parse$3(discriminator2, mapping, input, context, coerce = false) {
2720
2686
  schemaPath: `${context.schemaPath}/discriminator`,
2721
2687
  message: `Error at ${context.instancePath}. Expected object. Got ${typeof parsedInput}.`
2722
2688
  });
2723
- return undefined;
2689
+ return void 0;
2724
2690
  }
2725
2691
  if (!(discriminator2 in parsedInput)) {
2726
2692
  context.errors.push({
@@ -2728,7 +2694,7 @@ function parse$3(discriminator2, mapping, input, context, coerce = false) {
2728
2694
  schemaPath: `${context.schemaPath}/discriminator`,
2729
2695
  message: `Error at ${context.instancePath}/${discriminator2}. Discriminator field "${discriminator2}" cannot be undefined`
2730
2696
  });
2731
- return undefined;
2697
+ return void 0;
2732
2698
  }
2733
2699
  const acceptedDiscriminatorVals = Object.keys(mapping);
2734
2700
  const discriminatorVal = parsedInput[discriminator2];
@@ -2740,11 +2706,11 @@ function parse$3(discriminator2, mapping, input, context, coerce = false) {
2740
2706
  ", "
2741
2707
  )}]`
2742
2708
  });
2743
- return undefined;
2709
+ return void 0;
2744
2710
  }
2745
2711
  const targetSchema = mapping[parsedInput[discriminator2]];
2746
2712
  if (!targetSchema) {
2747
- return undefined;
2713
+ return void 0;
2748
2714
  }
2749
2715
  if (coerce) {
2750
2716
  const result2 = targetSchema[VALIDATOR_KEY].coerce(parsedInput, {
@@ -2806,7 +2772,7 @@ function enumerator(paramA, paramB) {
2806
2772
  ", "
2807
2773
  )}]`
2808
2774
  });
2809
- return undefined;
2775
+ return void 0;
2810
2776
  };
2811
2777
  const validator = {
2812
2778
  output: paramA[0] ?? "",
@@ -2822,7 +2788,7 @@ function enumerator(paramA, paramB) {
2822
2788
  ", "
2823
2789
  )}]`
2824
2790
  });
2825
- return undefined;
2791
+ return void 0;
2826
2792
  },
2827
2793
  validate: isType,
2828
2794
  serialize(input, context) {
@@ -2902,31 +2868,31 @@ function nullable(schema, opts = {}) {
2902
2868
  }
2903
2869
  function optional(input, opts = {}) {
2904
2870
  const isType = (val) => {
2905
- if (val === undefined) {
2871
+ if (val === void 0) {
2906
2872
  return true;
2907
2873
  }
2908
2874
  return input[VALIDATOR_KEY].validate(val);
2909
2875
  };
2910
2876
  const parse = (val, context) => {
2911
2877
  if (typeof val === "undefined") {
2912
- return undefined;
2878
+ return void 0;
2913
2879
  }
2914
2880
  if (context.instancePath.length === 0 && val === "undefined") {
2915
- return undefined;
2881
+ return void 0;
2916
2882
  }
2917
2883
  return input[VALIDATOR_KEY].parse(val, context);
2918
2884
  };
2919
2885
  const validator = {
2920
- output: undefined,
2886
+ output: void 0,
2921
2887
  optional: true,
2922
2888
  validate: isType,
2923
2889
  parse,
2924
2890
  coerce: (val, data) => {
2925
2891
  if (typeof val === "undefined") {
2926
- return undefined;
2892
+ return void 0;
2927
2893
  }
2928
2894
  if (val === "undefined") {
2929
- return undefined;
2895
+ return void 0;
2930
2896
  }
2931
2897
  return input[VALIDATOR_KEY].coerce(val, data);
2932
2898
  },
@@ -2983,7 +2949,7 @@ function coerceNumber(input, options) {
2983
2949
  schemaPath: `${options.schemaPath}/type`,
2984
2950
  message: `Error at ${options.instancePath}. Unable to coerce ${typeof input} into a number`
2985
2951
  });
2986
- return undefined;
2952
+ return void 0;
2987
2953
  }
2988
2954
  return decodeNumber(decodedInput, options);
2989
2955
  }
@@ -3108,7 +3074,7 @@ function int64(opts = {}) {
3108
3074
  schemaPath: `${context.schemaPath}/type`,
3109
3075
  instancePath: context.instancePath
3110
3076
  });
3111
- return undefined;
3077
+ return void 0;
3112
3078
  }
3113
3079
  }
3114
3080
  if (isType(input)) {
@@ -3119,7 +3085,7 @@ function int64(opts = {}) {
3119
3085
  schemaPath: `${context.schemaPath}/type`,
3120
3086
  instancePath: context.instancePath
3121
3087
  });
3122
- return undefined;
3088
+ return void 0;
3123
3089
  }
3124
3090
  const validator = {
3125
3091
  output: BigInt("0"),
@@ -3169,7 +3135,7 @@ function uint64(opts = {}) {
3169
3135
  schemaPath: `${context.schemaPath}/type`,
3170
3136
  instancePath: context.instancePath
3171
3137
  });
3172
- return undefined;
3138
+ return void 0;
3173
3139
  }
3174
3140
  }
3175
3141
  if (isType(input)) {
@@ -3180,7 +3146,7 @@ function uint64(opts = {}) {
3180
3146
  schemaPath: `${context.schemaPath}/type`,
3181
3147
  instancePath: context.instancePath
3182
3148
  });
3183
- return undefined;
3149
+ return void 0;
3184
3150
  }
3185
3151
  const validator = {
3186
3152
  output: BigInt("0"),
@@ -3225,7 +3191,7 @@ function decodeNumber(input, context) {
3225
3191
  schemaPath: `${context.schemaPath}/type`,
3226
3192
  message: `Error at ${context.instancePath}. Invalid number.`
3227
3193
  });
3228
- return undefined;
3194
+ return void 0;
3229
3195
  }
3230
3196
  return result;
3231
3197
  }
@@ -3237,7 +3203,7 @@ function decodeNumber(input, context) {
3237
3203
  schemaPath: `${context.schemaPath}/type`,
3238
3204
  message: `Error at ${context.instancePath}. Invalid number.`
3239
3205
  });
3240
- return undefined;
3206
+ return void 0;
3241
3207
  }
3242
3208
  function numberScalarType(type, opts, numTypeMatcher) {
3243
3209
  const validate = (input) => {
@@ -3250,7 +3216,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
3250
3216
  const parse = (input, context) => {
3251
3217
  const result2 = decodeNumber(input, context);
3252
3218
  if (context.errors.length) {
3253
- return undefined;
3219
+ return void 0;
3254
3220
  }
3255
3221
  if (typeof result2 !== "number") {
3256
3222
  context?.errors.push({
@@ -3258,7 +3224,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
3258
3224
  schemaPath: `${context.schemaPath}/type`,
3259
3225
  message: `Error at ${context.instancePath}. Invalid number.`
3260
3226
  });
3261
- return undefined;
3227
+ return void 0;
3262
3228
  }
3263
3229
  const matchResult = numTypeMatcher(result2);
3264
3230
  if (matchResult.success) {
@@ -3269,7 +3235,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
3269
3235
  schemaPath: `${context.schemaPath}/type`,
3270
3236
  message: `Error at ${context.instancePath}. ${matchResult.message}`
3271
3237
  });
3272
- return undefined;
3238
+ return void 0;
3273
3239
  };
3274
3240
  const validator = {
3275
3241
  output: 0,
@@ -3284,7 +3250,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
3284
3250
  schemaPath: `${options.schemaPath}/type`,
3285
3251
  message: `Error at ${options.instancePath}. Unable to coerce ${typeof input} to ${type}.`
3286
3252
  });
3287
- return undefined;
3253
+ return void 0;
3288
3254
  }
3289
3255
  const matchResult = numTypeMatcher(result2);
3290
3256
  if (matchResult.success) {
@@ -3295,7 +3261,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
3295
3261
  schemaPath: `${options.schemaPath}/type`,
3296
3262
  message: `Error at ${options.instancePath}. ${matchResult.message}`
3297
3263
  });
3298
- return undefined;
3264
+ return void 0;
3299
3265
  }
3300
3266
  };
3301
3267
  const result = {
@@ -3389,7 +3355,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
3389
3355
  schemaPath: `${context.schemaPath}/properties`,
3390
3356
  message: `Error at ${context.instancePath}. Invalid JSON.`
3391
3357
  });
3392
- return undefined;
3358
+ return void 0;
3393
3359
  }
3394
3360
  }
3395
3361
  if (!isObject(parsedInput)) {
@@ -3398,7 +3364,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
3398
3364
  schemaPath: `${context.schemaPath}/properties`,
3399
3365
  message: `Error at ${context.instancePath}. Expected object`
3400
3366
  });
3401
- return undefined;
3367
+ return void 0;
3402
3368
  }
3403
3369
  const result = {};
3404
3370
  const optionalProps = schema.optionalProperties ?? {};
@@ -3417,7 +3383,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
3417
3383
  }
3418
3384
  }
3419
3385
  if (context.errors.length) {
3420
- return undefined;
3386
+ return void 0;
3421
3387
  }
3422
3388
  if (context.discriminatorKey) {
3423
3389
  result[context.discriminatorKey] = context.discriminatorValue;
@@ -3435,7 +3401,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
3435
3401
  exitOnFirstError: context.exitOnFirstError
3436
3402
  });
3437
3403
  if (context.errors.length && context.exitOnFirstError) {
3438
- return undefined;
3404
+ return void 0;
3439
3405
  }
3440
3406
  continue;
3441
3407
  }
@@ -3448,13 +3414,13 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
3448
3414
  exitOnFirstError: context.exitOnFirstError
3449
3415
  });
3450
3416
  if (context.errors.length && context.exitOnFirstError) {
3451
- return undefined;
3417
+ return void 0;
3452
3418
  }
3453
3419
  }
3454
3420
  for (const key of optionalKeys) {
3455
3421
  const val = parsedInput[key];
3456
3422
  const prop = optionalProps[key];
3457
- if (val === undefined) {
3423
+ if (val === void 0) {
3458
3424
  continue;
3459
3425
  }
3460
3426
  if (coerce) {
@@ -3467,7 +3433,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
3467
3433
  exitOnFirstError: context.exitOnFirstError
3468
3434
  });
3469
3435
  if (context.errors.length && context.exitOnFirstError) {
3470
- return undefined;
3436
+ return void 0;
3471
3437
  }
3472
3438
  continue;
3473
3439
  }
@@ -3481,12 +3447,12 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
3481
3447
  exitOnFirstError: context.exitOnFirstError
3482
3448
  });
3483
3449
  if (context.errors.length && context.exitOnFirstError) {
3484
- return undefined;
3450
+ return void 0;
3485
3451
  }
3486
3452
  }
3487
3453
  }
3488
3454
  if (context.errors.length) {
3489
- return undefined;
3455
+ return void 0;
3490
3456
  }
3491
3457
  return result;
3492
3458
  }
@@ -3494,7 +3460,7 @@ function validateObjectSchema(schema, input) {
3494
3460
  if (!isObject(input)) {
3495
3461
  return false;
3496
3462
  }
3497
- const allowedKeys = schema.strict ? [] : undefined;
3463
+ const allowedKeys = schema.strict ? [] : void 0;
3498
3464
  for (const key of Object.keys(schema.properties)) {
3499
3465
  const propSchema = schema.properties[key];
3500
3466
  const isValid = propSchema[VALIDATOR_KEY].validate(input[key]);
@@ -3821,7 +3787,7 @@ function decode(input, context) {
3821
3787
  schemaPath: `${context.schemaPath}/type`,
3822
3788
  message: `Error at ${context.instancePath}. Expected 'string' got ${typeof input}.`
3823
3789
  });
3824
- return undefined;
3790
+ return void 0;
3825
3791
  }
3826
3792
  function coerce$2(input, context) {
3827
3793
  return decode(input, context);
@@ -3886,7 +3852,7 @@ function record(schema, opts = {}) {
3886
3852
  schemaPath: context.schemaPath,
3887
3853
  message: "Max depth reached"
3888
3854
  });
3889
- return undefined;
3855
+ return void 0;
3890
3856
  }
3891
3857
  let result2 = "{";
3892
3858
  const keys = Object.keys(input);
@@ -3929,7 +3895,7 @@ function parse$2(schema, input, data, coerce = false) {
3929
3895
  schemaPath: data.schemaPath,
3930
3896
  message: "Max depth reached"
3931
3897
  });
3932
- return undefined;
3898
+ return void 0;
3933
3899
  }
3934
3900
  let parsedInput = input;
3935
3901
  if (data.instancePath.length === 0 && typeof input === "string" && input.length > 0) {
@@ -3942,7 +3908,7 @@ function parse$2(schema, input, data, coerce = false) {
3942
3908
  schemaPath: data.schemaPath,
3943
3909
  data: err
3944
3910
  });
3945
- return undefined;
3911
+ return void 0;
3946
3912
  }
3947
3913
  }
3948
3914
  if (!isObject(parsedInput)) {
@@ -3951,7 +3917,7 @@ function parse$2(schema, input, data, coerce = false) {
3951
3917
  schemaPath: `${data.schemaPath}/values`,
3952
3918
  message: `Error at ${data.instancePath} Expected object`
3953
3919
  });
3954
- return undefined;
3920
+ return void 0;
3955
3921
  }
3956
3922
  const result = {};
3957
3923
  for (const key of Object.keys(parsedInput)) {
@@ -3977,7 +3943,7 @@ function parse$2(schema, input, data, coerce = false) {
3977
3943
  }
3978
3944
  }
3979
3945
  if (data.errors.length) {
3980
- return undefined;
3946
+ return void 0;
3981
3947
  }
3982
3948
  return result;
3983
3949
  }
@@ -4004,7 +3970,7 @@ function recursive(propA, propB) {
4004
3970
  instancePath: context.instancePath,
4005
3971
  schemaPath: context.schemaPath
4006
3972
  });
4007
- return undefined;
3973
+ return void 0;
4008
3974
  }
4009
3975
  if (recursiveFns[id]) {
4010
3976
  return recursiveFns[id].parse(input, {
@@ -4020,7 +3986,7 @@ function recursive(propA, propB) {
4020
3986
  instancePath: context.instancePath,
4021
3987
  schemaPath: context.schemaPath
4022
3988
  });
4023
- return undefined;
3989
+ return void 0;
4024
3990
  }
4025
3991
  if (recursiveFns[id]) {
4026
3992
  return recursiveFns[id].serialize(input, context);
@@ -4040,7 +4006,7 @@ function recursive(propA, propB) {
4040
4006
  instancePath: context.instancePath,
4041
4007
  schemaPath: context.schemaPath
4042
4008
  });
4043
- return undefined;
4009
+ return void 0;
4044
4010
  }
4045
4011
  if (recursiveFns[id]) {
4046
4012
  return recursiveFns[id].coerce(input, context);
@@ -4124,7 +4090,7 @@ function parse$1(input, data) {
4124
4090
  schemaPath: data.schemaPath,
4125
4091
  data: err
4126
4092
  });
4127
- return undefined;
4093
+ return void 0;
4128
4094
  }
4129
4095
  }
4130
4096
  function coerce$1(input, options) {