@arrirpc/schema 0.78.0 → 0.79.1

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
@@ -146,7 +146,7 @@ function booleanTemplate$2(input) {
146
146
  else if (${input.val} === false || ${input.val} === 'false' || ${input.val} === 'FALSE' || ${input.val} === 0 || ${input.val} === '0') {
147
147
  ${input.targetVal} = false;
148
148
  }`);
149
- if (input.schema.nullable) {
149
+ if (input.schema.isNullable) {
150
150
  templateParts.push(`else if (${input.val} === null || ${input.val} === 'null') {
151
151
  ${input.targetVal} = null;
152
152
  }`);
@@ -166,7 +166,7 @@ function booleanTemplate$2(input) {
166
166
  if (${input.val} === 'false') {
167
167
  ${input.targetVal} = false;
168
168
  }`);
169
- if (input.schema.nullable) {
169
+ if (input.schema.isNullable) {
170
170
  templateParts.push(`if (${input.val} === 'null') {
171
171
  ${input.targetVal} = null;
172
172
  }`);
@@ -181,7 +181,7 @@ function booleanTemplate$2(input) {
181
181
  } else {
182
182
  $fallback("${input.instancePath}", "${input.schemaPath}/type", "${errorMessage}");
183
183
  }`;
184
- if (input.schema.nullable) {
184
+ if (input.schema.isNullable) {
185
185
  templateParts.push(`if (${input.val} === null) {
186
186
  ${input.targetVal} = null;
187
187
  } else {
@@ -199,7 +199,7 @@ function stringTemplate$2(input) {
199
199
  } else {
200
200
  $fallback("${input.instancePath}", "${input.schemaPath}/type", "${errorMessage}");
201
201
  }`;
202
- if (input.schema.nullable) {
202
+ if (input.schema.isNullable) {
203
203
  return `if (${input.val} === null) {
204
204
  ${input.targetVal} = ${input.val};
205
205
  } else {
@@ -222,7 +222,7 @@ function floatTemplate$1(input) {
222
222
  if (!Number.isNaN(${valName})) {
223
223
  ${input.targetVal} = ${valName};
224
224
  }`);
225
- if (input.schema.nullable) {
225
+ if (input.schema.isNullable) {
226
226
  templateParts.push(`else if (${input.val} === 'null') {
227
227
  ${input.targetVal} = null;
228
228
  }`);
@@ -240,7 +240,7 @@ function floatTemplate$1(input) {
240
240
  } else {
241
241
  $fallback("${input.instancePath}", "${input.schemaPath}/type", "${errorMessage}");
242
242
  }`;
243
- if (input.schema.nullable) {
243
+ if (input.schema.isNullable) {
244
244
  templateParts.push(`${input.instancePath.length === 0 || input.shouldCoerce ? "else " : ""}if (${input.val} === null) {
245
245
  ${input.targetVal} = null;
246
246
  } else {
@@ -262,7 +262,7 @@ function intTemplate$1(input, min, max) {
262
262
  if (Number.isInteger(parsedVal) && parsedVal >= ${min} && parsedVal <= ${max}) {
263
263
  ${input.targetVal} = parsedVal;
264
264
  }`);
265
- if (input.schema.nullable) {
265
+ if (input.schema.isNullable) {
266
266
  templateParts.push(`else if (${input.val} === 'null') {
267
267
  ${input.targetVal} = null;
268
268
  }`);
@@ -280,7 +280,7 @@ function intTemplate$1(input, min, max) {
280
280
  $fallback("${input.instancePath}", "${input.schemaPath}", "Expected valid integer between ${min} and ${max}");
281
281
  }`;
282
282
  const prefix = shouldCoerce ? `else ` : "";
283
- if (input.schema.nullable) {
283
+ if (input.schema.isNullable) {
284
284
  templateParts.push(`${prefix}if (${input.val} === null) {
285
285
  ${input.targetVal} = null;
286
286
  } else {
@@ -296,7 +296,7 @@ function bigIntTemplate$2(input, isUnsigned) {
296
296
  templateParts.push(
297
297
  `if (typeof ${input.val} === 'string' || typeof ${input.val} === 'number') {`
298
298
  );
299
- if ((input.instancePath.length === 0 || input.shouldCoerce) && input.schema.nullable) {
299
+ if ((input.instancePath.length === 0 || input.shouldCoerce) && input.schema.isNullable) {
300
300
  templateParts.push(`if (${input.val} === 'null') {
301
301
  ${input.targetVal} = null;
302
302
  } else {`);
@@ -315,7 +315,7 @@ function bigIntTemplate$2(input, isUnsigned) {
315
315
  templateParts.push(`} catch(err) {
316
316
  $fallback("${input.instancePath}", "${input.schemaPath}", \`Unable to parse BigInt from \${${input.val}}\`);
317
317
  }`);
318
- if ((input.instancePath.length === 0 || input.shouldCoerce) && input.schema.nullable) {
318
+ if ((input.instancePath.length === 0 || input.shouldCoerce) && input.schema.isNullable) {
319
319
  templateParts.push("}");
320
320
  }
321
321
  templateParts.push("}");
@@ -332,7 +332,7 @@ function bigIntTemplate$2(input, isUnsigned) {
332
332
  ${input.targetVal} = ${input.val};
333
333
  }`);
334
334
  }
335
- if (input.schema.nullable) {
335
+ if (input.schema.isNullable) {
336
336
  templateParts.push(`else if (${input.val} === null) {
337
337
  ${input.targetVal} = null;
338
338
  }`);
@@ -350,7 +350,7 @@ function timestampTemplate$2(input) {
350
350
  const parsedVal = new Date(${input.val});
351
351
  if (!Number.isNaN(parsedVal.getMonth())) {
352
352
  ${input.targetVal} = parsedVal;
353
- } ${input.schema.nullable ? `else if (${input.val} === 'null') {
353
+ } ${input.schema.isNullable ? `else if (${input.val} === 'null') {
354
354
  ${input.targetVal} = null;
355
355
  }` : ""} else {
356
356
  $fallback("${input.instancePath}", "${input.schemaPath}", "Unable to coerce date");
@@ -367,7 +367,7 @@ function timestampTemplate$2(input) {
367
367
  }
368
368
  } else if (typeof ${input.val} === 'object' && ${input.val} instanceof Date) {
369
369
  ${input.targetVal} = ${input.val};
370
- }${input.schema.nullable ? ` else if (${input.val} === null) {
370
+ }${input.schema.isNullable ? ` else if (${input.val} === null) {
371
371
  ${input.targetVal} = null;
372
372
  }` : ""} else {
373
373
  $fallback("${input.instancePath}", "${input.schemaPath}", "Unable to parse date");
@@ -379,7 +379,7 @@ function timestampTemplate$2(input) {
379
379
  if (!Number.isNaN(parsedVal.getMonth())) {
380
380
  ${input.targetVal} = parsedVal;
381
381
  }`);
382
- if (input.schema.nullable) {
382
+ if (input.schema.isNullable) {
383
383
  templateParts.push(`if (${input.val} === 'null') {
384
384
  ${input.targetVal} = null;
385
385
  }`);
@@ -396,7 +396,7 @@ function timestampTemplate$2(input) {
396
396
  } else {
397
397
  $fallback("${input.instancePath}", "${input.schemaPath}", "Expected instanceof Date or ISO Date string")
398
398
  }`;
399
- if (input.schema.nullable) {
399
+ if (input.schema.isNullable) {
400
400
  templateParts.push(`if (${input.val} === null) {
401
401
  ${input.targetVal} = null
402
402
  } else {
@@ -418,7 +418,7 @@ function enumTemplate$2(input) {
418
418
  ${input.targetVal} = ${input.val};
419
419
  }
420
420
  `);
421
- if (input.instancePath.length === 0 && input.schema.nullable) {
421
+ if (input.instancePath.length === 0 && input.schema.isNullable) {
422
422
  templateParts.push(`else if (${input.val} === 'null') {
423
423
  ${input.targetVal} = null;
424
424
  }`);
@@ -432,7 +432,7 @@ function enumTemplate$2(input) {
432
432
  }`
433
433
  );
434
434
  const mainTemplate = templateParts.join("\n");
435
- if (input.schema.nullable) {
435
+ if (input.schema.isNullable) {
436
436
  return `if (${input.val} === null) {
437
437
  ${input.targetVal} = null;
438
438
  } else {
@@ -450,7 +450,7 @@ function objectTemplate$2(input) {
450
450
  `${innerTargetVal}.${input.discriminatorKey} = "${input.discriminatorValue}";`
451
451
  );
452
452
  }
453
- if (input.schema.strict) {
453
+ if (input.schema.isStrict) {
454
454
  const keyVal = `_${depthStr}_keys`;
455
455
  const optionalKeyVal = `_${depthStr}_optionalKeys`;
456
456
  const keys = Object.keys(input.schema.properties).map((key) => `"${key}"`).join(",");
@@ -516,7 +516,7 @@ function objectTemplate$2(input) {
516
516
  }
517
517
  mainTemplate = `${input.targetVal} = ${fnName}(${input.val});`;
518
518
  }
519
- if (input.schema.nullable) {
519
+ if (input.schema.isNullable) {
520
520
  return `if (${input.val} === null) {
521
521
  ${input.targetVal} = null;
522
522
  } else {
@@ -549,7 +549,7 @@ function arrayTemplate$2(input) {
549
549
  } else {
550
550
  $fallback("${input.instancePath}", "${input.schemaPath}", "Expected Array");
551
551
  }`;
552
- if (input.schema.nullable) {
552
+ if (input.schema.isNullable) {
553
553
  return `if (${input.val} === null) {
554
554
  ${input.targetVal} = null;
555
555
  } else {
@@ -600,7 +600,7 @@ function discriminatorTemplate$2(input) {
600
600
  }
601
601
  mainTemplate = `${input.targetVal} = ${fnName}(${input.val});`;
602
602
  }
603
- if (input.schema.nullable) {
603
+ if (input.schema.isNullable) {
604
604
  return `if (${input.val} === null) {
605
605
  ${input.targetVal} = null;
606
606
  } else {
@@ -639,7 +639,7 @@ function recordTemplate$2(input) {
639
639
  } else {
640
640
  $fallback("${input.instancePath}", "${input.schemaPath}", "Expected object.");
641
641
  }`;
642
- if (input.schema.nullable) {
642
+ if (input.schema.isNullable) {
643
643
  return `if (${input.val} === null) {
644
644
  ${input.targetVal} = null;
645
645
  } else {
@@ -656,7 +656,7 @@ function refTemplate$2(input) {
656
656
  if (!Object.keys(input.subFunctions).includes(fnName)) {
657
657
  input.subFunctions[fnName] = "";
658
658
  }
659
- if (input.schema.nullable) {
659
+ if (input.schema.isNullable) {
660
660
  return `if (${input.val} === null) {
661
661
  ${input.targetVal} = null;
662
662
  } else {
@@ -745,7 +745,7 @@ function scalarTemplate(input) {
745
745
  }
746
746
  function stringTemplate$1(input) {
747
747
  if (input.instancePath.length === 0) {
748
- if (input.schema.nullable) {
748
+ if (input.schema.isNullable) {
749
749
  return `if (typeof ${input.val} === 'string') {
750
750
  return ${input.val};
751
751
  }
@@ -785,7 +785,7 @@ if (${input.val}.length < 42) {
785
785
  } else {
786
786
  ${input.targetVal} += JSON.stringify(${input.val});
787
787
  }`;
788
- if (input.schema.nullable) {
788
+ if (input.schema.isNullable) {
789
789
  return `if (typeof ${input.val} === 'string') {
790
790
  ${mainTemplate}
791
791
  } else {
@@ -799,7 +799,7 @@ function booleanTemplate$1(input) {
799
799
  return `return \`\${${input.val}}\`;`;
800
800
  }
801
801
  const mainTemplate = `${input.targetVal} += \`${input.outputPrefix}\${${input.val}}\`;`;
802
- if (input.schema.nullable) {
802
+ if (input.schema.isNullable) {
803
803
  return `if (typeof ${input.val} === 'boolean') {
804
804
  ${mainTemplate}
805
805
  } else {
@@ -810,7 +810,7 @@ function booleanTemplate$1(input) {
810
810
  }
811
811
  function timestampTemplate$1(input) {
812
812
  if (input.instancePath.length === 0) {
813
- if (input.schema.nullable) {
813
+ if (input.schema.isNullable) {
814
814
  return `if (typeof ${input.val} === 'object' && ${input.val} instanceof Date) {
815
815
  return ${input.val}.toISOString();
816
816
  }
@@ -819,7 +819,7 @@ function timestampTemplate$1(input) {
819
819
  return `return ${input.val}.toISOString();`;
820
820
  }
821
821
  const mainTemplate = `${input.targetVal} += \`${input.outputPrefix}"\${${input.val}.toISOString()}"\`;`;
822
- if (input.schema.nullable) {
822
+ if (input.schema.isNullable) {
823
823
  return `if (typeof ${input.val} === 'object' && ${input.val} instanceof Date) {
824
824
  ${mainTemplate}
825
825
  } else {
@@ -830,7 +830,7 @@ function timestampTemplate$1(input) {
830
830
  }
831
831
  function numberTemplate(input) {
832
832
  if (input.instancePath.length === 0) {
833
- if (input.schema.nullable) {
833
+ if (input.schema.isNullable) {
834
834
  return `if (typeof ${input.val} === 'number' && !Number.isNaN(${input.val})) {
835
835
  return \`\${${input.val}}\`;
836
836
  }
@@ -843,7 +843,7 @@ function numberTemplate(input) {
843
843
  throw new Error("Expected number at ${input.instancePath} got NaN");
844
844
  }
845
845
  ${input.targetVal} += \`${input.outputPrefix}\${${input.val}}\`;`;
846
- if (input.schema.nullable) {
846
+ if (input.schema.isNullable) {
847
847
  return `if (typeof ${input.val} === 'number' && !Number.isNaN(${input.val})) {
848
848
  ${mainTemplate}
849
849
  } else {
@@ -854,7 +854,7 @@ function numberTemplate(input) {
854
854
  }
855
855
  function bigIntTemplate$1(input) {
856
856
  if (input.instancePath.length === 0) {
857
- if (input.schema.nullable) {
857
+ if (input.schema.isNullable) {
858
858
  return `if (typeof ${input.val} === 'bigint') {
859
859
  return ${input.val}.toString();
860
860
  }
@@ -863,7 +863,7 @@ function bigIntTemplate$1(input) {
863
863
  return `return ${input.val}.toString();`;
864
864
  }
865
865
  const mainTemplate = `${input.targetVal} += \`${input.outputPrefix}"\${${input.val}.toString()}"\`;`;
866
- if (input.schema.nullable) {
866
+ if (input.schema.isNullable) {
867
867
  return `if (typeof ${input.val} === 'bigint') {
868
868
  ${mainTemplate}
869
869
  } else {
@@ -874,7 +874,7 @@ function bigIntTemplate$1(input) {
874
874
  }
875
875
  function enumTemplate$1(input) {
876
876
  if (input.instancePath.length === 0) {
877
- if (input.schema.nullable) {
877
+ if (input.schema.isNullable) {
878
878
  return `if (typeof ${input.val} === 'string') {
879
879
  return ${input.val};
880
880
  }
@@ -883,7 +883,7 @@ function enumTemplate$1(input) {
883
883
  return `return ${input.val};`;
884
884
  }
885
885
  const mainTemplate = `${input.targetVal} += \`${input.outputPrefix}"\${${input.val}}"\``;
886
- if (input.schema.nullable) {
886
+ if (input.schema.isNullable) {
887
887
  return `if (typeof ${input.val} === 'string') {
888
888
  ${mainTemplate}
889
889
  } else {
@@ -990,7 +990,7 @@ function objectTemplate$1(input) {
990
990
  }
991
991
  mainTemplate = `${fnName}(${input.val});`;
992
992
  }
993
- if (input.schema.nullable) {
993
+ if (input.schema.isNullable) {
994
994
  return `if (typeof ${input.val} === 'object' && ${input.val} !== null) {
995
995
  ${input.targetVal} += '${input.outputPrefix}';
996
996
  ${mainTemplate.split("___val___").join(input.val)}
@@ -1031,7 +1031,7 @@ function arrayTemplate$1(input) {
1031
1031
  }`);
1032
1032
  templateParts.push(`${input.targetVal} += ']';`);
1033
1033
  const mainTemplate = templateParts.join("\n");
1034
- if (input.schema.nullable) {
1034
+ if (input.schema.isNullable) {
1035
1035
  return `if (Array.isArray(${input.val})) {
1036
1036
  ${mainTemplate}
1037
1037
  } else {
@@ -1096,7 +1096,7 @@ function recordTemplate$1(input) {
1096
1096
  }`);
1097
1097
  templateParts.push(`${input.targetVal} += '}';`);
1098
1098
  const mainTemplate = templateParts.join("\n");
1099
- if (input.schema.nullable) {
1099
+ if (input.schema.isNullable) {
1100
1100
  return `if (typeof ${input.val} === 'object' && ${input.val} !== null) {
1101
1101
  ${mainTemplate}
1102
1102
  } else {
@@ -1139,7 +1139,7 @@ function discriminatorTemplate$1(input) {
1139
1139
  }
1140
1140
  mainTemplate = `${fnName}(${input.val});`;
1141
1141
  }
1142
- if (input.schema.nullable) {
1142
+ if (input.schema.isNullable) {
1143
1143
  return `if (typeof ${input.val} === 'object' && ${input.val} !== null) {
1144
1144
  ${mainTemplate.split(inputPlaceholder).join(input.val)}
1145
1145
  } else {
@@ -1153,7 +1153,7 @@ function anyTemplate(input) {
1153
1153
  const mainTemplate = `if (typeof ${input.val} !== 'undefined') {
1154
1154
  ${input.targetVal} += '${input.outputPrefix}' + JSON.stringify(${input.val});
1155
1155
  }`;
1156
- if (input.schema.nullable) {
1156
+ if (input.schema.isNullable) {
1157
1157
  return `if (${input.val} === null) {
1158
1158
  ${input.targetVal} += '${input.outputPrefix}null';
1159
1159
  } else {
@@ -1174,7 +1174,7 @@ function refTemplate$1(input) {
1174
1174
  if (!Object.keys(input.subFunctions).includes(fnName)) {
1175
1175
  input.subFunctions[fnName] = "";
1176
1176
  }
1177
- if (input.schema.nullable) {
1177
+ if (input.schema.isNullable) {
1178
1178
  return `if (${input.val} === null) {
1179
1179
  ${input.targetVal} += '${input.outputPrefix}null';
1180
1180
  } else {
@@ -1251,38 +1251,38 @@ function schemaTemplate(input) {
1251
1251
  return "true";
1252
1252
  }
1253
1253
  function booleanTemplate(input) {
1254
- if (input.schema.nullable) {
1254
+ if (input.schema.isNullable) {
1255
1255
  return `(${input.val} === null || typeof ${input.val} === 'boolean')`;
1256
1256
  }
1257
1257
  return `typeof ${input.val} === 'boolean'`;
1258
1258
  }
1259
1259
  function floatTemplate(input) {
1260
- if (input.schema.nullable) {
1260
+ if (input.schema.isNullable) {
1261
1261
  return `((typeof ${input.val} === 'number' && !Number.isNaN(${input.val})) || ${input.val} === null)`;
1262
1262
  }
1263
1263
  return `(typeof ${input.val} === 'number' && !Number.isNaN(${input.val}))`;
1264
1264
  }
1265
1265
  function intTemplate(input, min, max) {
1266
- if (input.schema.nullable) {
1266
+ if (input.schema.isNullable) {
1267
1267
  return `((typeof ${input.val} === 'number' && Number.isInteger(${input.val}) && ${input.val} >= ${min} && ${input.val} <= ${max}) || ${input.val} === null)`;
1268
1268
  }
1269
1269
  return `(typeof ${input.val} === 'number' && Number.isInteger(${input.val}) && ${input.val} >= ${min} && ${input.val} <= ${max})`;
1270
1270
  }
1271
1271
  function bigIntTemplate(input, isUnsigned = false) {
1272
1272
  const mainTemplate = isUnsigned ? `typeof ${input.val} === 'bigint' && ${input.val} >= BigInt("0")` : `typeof ${input.val} === 'bigint' && ${input.val} < BigInt("9223372036854775808") && ${input.val} > BigInt("-9223372036854775809")`;
1273
- if (input.schema.nullable) {
1273
+ if (input.schema.isNullable) {
1274
1274
  return `(${mainTemplate}) || ${input.val} === null`;
1275
1275
  }
1276
1276
  return mainTemplate;
1277
1277
  }
1278
1278
  function stringTemplate(input) {
1279
- if (input.schema.nullable) {
1279
+ if (input.schema.isNullable) {
1280
1280
  return `(typeof ${input.val} === 'string' || ${input.val} === null)`;
1281
1281
  }
1282
1282
  return `typeof ${input.val} === 'string'`;
1283
1283
  }
1284
1284
  function timestampTemplate(input) {
1285
- if (input.schema.nullable) {
1285
+ if (input.schema.isNullable) {
1286
1286
  return `((typeof ${input.val} === 'object' && ${input.val} instanceof Date) || ${input.val} === null)`;
1287
1287
  }
1288
1288
  return `typeof ${input.val} === 'object' && ${input.val} instanceof Date`;
@@ -1296,7 +1296,7 @@ function objectTemplate(input) {
1296
1296
  } else {
1297
1297
  parts.push(`typeof ${input.val} === 'object' && ${input.val} !== null`);
1298
1298
  }
1299
- if (input.schema.strict) {
1299
+ if (input.schema.isStrict) {
1300
1300
  const allowedKeys = Object.keys(input.schema.properties);
1301
1301
  for (const key of Object.keys(input.schema.optionalProperties ?? {})) {
1302
1302
  allowedKeys.push(key);
@@ -1340,14 +1340,14 @@ function objectTemplate(input) {
1340
1340
  }
1341
1341
  mainTemplate = `${fnName}(${input.val})`;
1342
1342
  }
1343
- if (input.schema.nullable) {
1343
+ if (input.schema.isNullable) {
1344
1344
  return `((${mainTemplate}) || ${input.val} === null)`;
1345
1345
  }
1346
1346
  return mainTemplate;
1347
1347
  }
1348
1348
  function enumTemplate(input) {
1349
1349
  const enumPart = input.schema.enum.map((val) => `${input.val} === "${val}"`).join(" || ");
1350
- if (input.schema.nullable) {
1350
+ if (input.schema.isNullable) {
1351
1351
  return `((typeof ${input.val} === 'string' && (${enumPart})) || ${input.val} === null)`;
1352
1352
  }
1353
1353
  return `(typeof ${input.val} === 'string' && (${enumPart}))`;
@@ -1359,7 +1359,7 @@ function arrayTemplate(input) {
1359
1359
  schemaPath: `${input.schemaPath}/elements`,
1360
1360
  schema: input.schema.elements,
1361
1361
  subFunctions: input.subFunctions});
1362
- if (input.schema.nullable) {
1362
+ if (input.schema.isNullable) {
1363
1363
  return `((Array.isArray(${input.val}) && ${input.val}.every((item) => ${innerTemplate})) || ${input.val} === null)`;
1364
1364
  }
1365
1365
  return `(Array.isArray(${input.val}) && ${input.val}.every((item) => ${innerTemplate}))`;
@@ -1372,7 +1372,7 @@ function recordTemplate(input) {
1372
1372
  val: `${input.val}[key]`,
1373
1373
  subFunctions: input.subFunctions});
1374
1374
  const mainTemplate = `typeof ${input.val} === 'object' && ${input.val} !== null && Object.keys(${input.val}).every((key) => ${subTemplate})`;
1375
- if (input.schema.nullable) {
1375
+ if (input.schema.isNullable) {
1376
1376
  return `((${mainTemplate}) || ${input.val} === null)`;
1377
1377
  }
1378
1378
  return mainTemplate;
@@ -1405,7 +1405,7 @@ function discriminatorTemplate(input) {
1405
1405
  }
1406
1406
  mainTemplate = `${fnName}(${input.val})`;
1407
1407
  }
1408
- if (input.schema.nullable) {
1408
+ if (input.schema.isNullable) {
1409
1409
  return `((${mainTemplate}) || ${input.val} === null)`;
1410
1410
  }
1411
1411
  return mainTemplate;
@@ -1418,7 +1418,7 @@ function refTemplate(input) {
1418
1418
  if (!Object.keys(input.subFunctions).includes(fnName)) {
1419
1419
  input.subFunctions[fnName] = "";
1420
1420
  }
1421
- if (input.schema.nullable) {
1421
+ if (input.schema.isNullable) {
1422
1422
  return `(${input.val} === null || ${fnName}(${input.val}))`;
1423
1423
  }
1424
1424
  return `${fnName}(${input.val})`;
@@ -1599,7 +1599,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1599
1599
  switch (schema.type) {
1600
1600
  case "float32":
1601
1601
  case "float64":
1602
- if (schema.nullable) {
1602
+ if (schema.isNullable) {
1603
1603
  return {
1604
1604
  fn: nullableFloatDecoder,
1605
1605
  code
@@ -1615,7 +1615,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1615
1615
  return bigIntDecoder(
1616
1616
  input2,
1617
1617
  false,
1618
- schema.nullable ?? false,
1618
+ schema.isNullable ?? false,
1619
1619
  context
1620
1620
  );
1621
1621
  },
@@ -1627,14 +1627,14 @@ function getCompiledParser(input, schema, shouldCoerce) {
1627
1627
  return bigIntDecoder(
1628
1628
  input2,
1629
1629
  true,
1630
- schema.nullable ?? false,
1630
+ schema.isNullable ?? false,
1631
1631
  context
1632
1632
  );
1633
1633
  },
1634
1634
  code
1635
1635
  };
1636
1636
  case "int32":
1637
- if (schema.nullable) {
1637
+ if (schema.isNullable) {
1638
1638
  return {
1639
1639
  fn(input2, context) {
1640
1640
  return nullableIntDecoder(
@@ -1654,7 +1654,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1654
1654
  code
1655
1655
  };
1656
1656
  case "int16":
1657
- if (schema.nullable) {
1657
+ if (schema.isNullable) {
1658
1658
  return {
1659
1659
  fn(input2, context) {
1660
1660
  return nullableIntDecoder(
@@ -1674,7 +1674,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1674
1674
  code
1675
1675
  };
1676
1676
  case "int8":
1677
- if (schema.nullable) {
1677
+ if (schema.isNullable) {
1678
1678
  return {
1679
1679
  fn(input2, context) {
1680
1680
  return nullableIntDecoder(
@@ -1694,7 +1694,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1694
1694
  code
1695
1695
  };
1696
1696
  case "uint32":
1697
- if (schema.nullable) {
1697
+ if (schema.isNullable) {
1698
1698
  return {
1699
1699
  fn(input2, context) {
1700
1700
  return nullableIntDecoder(
@@ -1714,7 +1714,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1714
1714
  code
1715
1715
  };
1716
1716
  case "uint16":
1717
- if (schema.nullable) {
1717
+ if (schema.isNullable) {
1718
1718
  return {
1719
1719
  fn(input2, context) {
1720
1720
  return nullableIntDecoder(
@@ -1734,7 +1734,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1734
1734
  code
1735
1735
  };
1736
1736
  case "uint8":
1737
- if (schema.nullable) {
1737
+ if (schema.isNullable) {
1738
1738
  return {
1739
1739
  fn(input2, context) {
1740
1740
  return nullableIntDecoder(
@@ -1755,7 +1755,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1755
1755
  };
1756
1756
  case "boolean":
1757
1757
  if (shouldCoerce) {
1758
- if (schema.nullable) {
1758
+ if (schema.isNullable) {
1759
1759
  return {
1760
1760
  code,
1761
1761
  fn(input2, context) {
@@ -1817,7 +1817,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1817
1817
  }
1818
1818
  };
1819
1819
  }
1820
- if (schema.nullable) {
1820
+ if (schema.isNullable) {
1821
1821
  return {
1822
1822
  code,
1823
1823
  fn(input2, context) {
@@ -1870,7 +1870,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1870
1870
  code
1871
1871
  };
1872
1872
  case "string":
1873
- if (schema.nullable) {
1873
+ if (schema.isNullable) {
1874
1874
  return {
1875
1875
  fn(input2, context) {
1876
1876
  if (typeof input2 === "string") {
@@ -1908,7 +1908,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1908
1908
  };
1909
1909
  case "timestamp":
1910
1910
  if (shouldCoerce) {
1911
- if (schema.nullable) {
1911
+ if (schema.isNullable) {
1912
1912
  return {
1913
1913
  fn(input2, context) {
1914
1914
  if (typeof input2 === "string") {
@@ -1969,7 +1969,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
1969
1969
  code
1970
1970
  };
1971
1971
  }
1972
- if (schema.nullable) {
1972
+ if (schema.isNullable) {
1973
1973
  return {
1974
1974
  fn(input2, context) {
1975
1975
  if (typeof input2 === "string") {
@@ -2020,7 +2020,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
2020
2020
  }
2021
2021
  }
2022
2022
  if (isSchemaFormEnum(schema)) {
2023
- if (schema.nullable) {
2023
+ if (schema.isNullable) {
2024
2024
  return {
2025
2025
  fn(input2, context) {
2026
2026
  if (typeof input2 === "string") {
@@ -2236,7 +2236,7 @@ function getCompiledSerializer(schema) {
2236
2236
  if (isSchemaFormType(schema)) {
2237
2237
  switch (schema.type) {
2238
2238
  case "string":
2239
- if (schema.nullable) {
2239
+ if (schema.isNullable) {
2240
2240
  return {
2241
2241
  fn(input) {
2242
2242
  if (typeof input === "string") {
@@ -2254,7 +2254,7 @@ function getCompiledSerializer(schema) {
2254
2254
  code
2255
2255
  };
2256
2256
  case "timestamp":
2257
- if (schema.nullable) {
2257
+ if (schema.isNullable) {
2258
2258
  return {
2259
2259
  fn(input) {
2260
2260
  if (typeof input === "object" && input !== null) {
@@ -2272,7 +2272,7 @@ function getCompiledSerializer(schema) {
2272
2272
  code
2273
2273
  };
2274
2274
  case "boolean":
2275
- if (schema.nullable) {
2275
+ if (schema.isNullable) {
2276
2276
  return {
2277
2277
  fn(input) {
2278
2278
  if (typeof input === "boolean") {
@@ -2297,7 +2297,7 @@ function getCompiledSerializer(schema) {
2297
2297
  case "uint8":
2298
2298
  case "uint16":
2299
2299
  case "uint32":
2300
- if (schema.nullable) {
2300
+ if (schema.isNullable) {
2301
2301
  return {
2302
2302
  fn(input) {
2303
2303
  if (typeof input === "number") {
@@ -2316,7 +2316,7 @@ function getCompiledSerializer(schema) {
2316
2316
  };
2317
2317
  case "int64":
2318
2318
  case "uint64":
2319
- if (schema.nullable) {
2319
+ if (schema.isNullable) {
2320
2320
  return {
2321
2321
  fn(input) {
2322
2322
  if (typeof input === "bigint") {
@@ -2336,7 +2336,7 @@ function getCompiledSerializer(schema) {
2336
2336
  }
2337
2337
  }
2338
2338
  if (isSchemaFormEnum(schema)) {
2339
- if (schema.nullable) {
2339
+ if (schema.isNullable) {
2340
2340
  return {
2341
2341
  fn(input) {
2342
2342
  if (typeof input === "string" && schema.enum.includes(input)) {
@@ -2375,6 +2375,7 @@ function any(options = {}) {
2375
2375
  };
2376
2376
  const validator = {
2377
2377
  output: void 0,
2378
+ optional: false,
2378
2379
  parse,
2379
2380
  coerce: (input, context) => {
2380
2381
  if (context.instancePath.length === 0 && typeof input === "string") {
@@ -2413,6 +2414,7 @@ function array(schema, opts = {}) {
2413
2414
  };
2414
2415
  const validator = {
2415
2416
  output: [],
2417
+ optional: false,
2416
2418
  parse: parseType,
2417
2419
  coerce(input, context) {
2418
2420
  return parse$5(schema, input, context, true);
@@ -2519,6 +2521,7 @@ function parse$5(innerSchema, input, context, coerce = false) {
2519
2521
  function boolean(opts = {}) {
2520
2522
  const validator = {
2521
2523
  output: false,
2524
+ optional: false,
2522
2525
  parse: parse$4,
2523
2526
  validate: validate$4,
2524
2527
  serialize: serialize$2,
@@ -2607,6 +2610,7 @@ function discriminator(propA, propB, propC) {
2607
2610
  };
2608
2611
  const validator = {
2609
2612
  output: {},
2613
+ optional: false,
2610
2614
  validate: isType,
2611
2615
  parse: parseType,
2612
2616
  coerce: (input, context) => {
@@ -2776,6 +2780,7 @@ function enumerator(paramA, paramB) {
2776
2780
  };
2777
2781
  const validator = {
2778
2782
  output: paramA[0] ?? "",
2783
+ optional: false,
2779
2784
  parse,
2780
2785
  coerce: (input, context) => {
2781
2786
  if (isType(input)) {
@@ -2851,7 +2856,7 @@ function nullable(schema, opts = {}) {
2851
2856
  };
2852
2857
  const result = {
2853
2858
  ...schema,
2854
- nullable: true,
2859
+ isNullable: true,
2855
2860
  metadata: {
2856
2861
  id: opts.id ?? schema.metadata?.id,
2857
2862
  description: opts.description ?? schema.metadata?.description,
@@ -2916,6 +2921,9 @@ function optional(input, opts = {}) {
2916
2921
  hideInvalidProperties(result);
2917
2922
  return result;
2918
2923
  }
2924
+ function undefinable(input, opts = {}) {
2925
+ return optional(input, opts);
2926
+ }
2919
2927
  function clone(input, opts = {}) {
2920
2928
  const validator = {
2921
2929
  ...input[VALIDATOR_KEY]
@@ -3089,6 +3097,7 @@ function int64(opts = {}) {
3089
3097
  }
3090
3098
  const validator = {
3091
3099
  output: BigInt("0"),
3100
+ optional: false,
3092
3101
  validate: isType,
3093
3102
  parse,
3094
3103
  coerce: parse,
@@ -3150,6 +3159,7 @@ function uint64(opts = {}) {
3150
3159
  }
3151
3160
  const validator = {
3152
3161
  output: BigInt("0"),
3162
+ optional: false,
3153
3163
  validate: isType,
3154
3164
  parse,
3155
3165
  coerce: parse,
@@ -3239,6 +3249,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
3239
3249
  };
3240
3250
  const validator = {
3241
3251
  output: 0,
3252
+ optional: false,
3242
3253
  validate,
3243
3254
  parse,
3244
3255
  serialize: serializeNumber,
@@ -3285,8 +3296,10 @@ function object(propA, propB) {
3285
3296
  const schema = {
3286
3297
  properties: {}
3287
3298
  };
3288
- if (typeof options.strict === "boolean") {
3289
- schema.strict = options.strict;
3299
+ if (typeof options.isStrict === "boolean") {
3300
+ schema.isStrict = options.isStrict;
3301
+ } else if (typeof options.strict === "boolean") {
3302
+ schema.isStrict = options.strict;
3290
3303
  }
3291
3304
  for (const key of Object.keys(input)) {
3292
3305
  const prop = input[key];
@@ -3312,6 +3325,7 @@ function object(propA, propB) {
3312
3325
  };
3313
3326
  const validator = {
3314
3327
  output: {},
3328
+ optional: false,
3315
3329
  parse: decode,
3316
3330
  coerce(input2, context) {
3317
3331
  return decodeObjectSchema(
@@ -3371,7 +3385,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
3371
3385
  const inputKeys = Object.keys(parsedInput);
3372
3386
  const requiredKeys = Object.keys(schema.properties);
3373
3387
  const optionalKeys = Object.keys(optionalProps);
3374
- if (schema.strict) {
3388
+ if (schema.isStrict) {
3375
3389
  for (const key of inputKeys) {
3376
3390
  if (!requiredKeys.includes(key) && !optionalKeys.includes(key) && key !== context.discriminatorKey) {
3377
3391
  context.errors.push({
@@ -3460,7 +3474,7 @@ function validateObjectSchema(schema, input) {
3460
3474
  if (!isObject(input)) {
3461
3475
  return false;
3462
3476
  }
3463
- const allowedKeys = schema.strict ? [] : void 0;
3477
+ const allowedKeys = schema.isStrict ? [] : void 0;
3464
3478
  for (const key of Object.keys(schema.properties)) {
3465
3479
  const propSchema = schema.properties[key];
3466
3480
  const isValid = propSchema[VALIDATOR_KEY].validate(input[key]);
@@ -3485,10 +3499,10 @@ function validateObjectSchema(schema, input) {
3485
3499
  function pick(inputSchema, keys, options = {}) {
3486
3500
  const schema = {
3487
3501
  properties: {},
3488
- nullable: inputSchema.nullable
3502
+ isNullable: inputSchema.isNullable
3489
3503
  };
3490
- if (typeof options.strict === "boolean") {
3491
- schema.strict = options.strict;
3504
+ if (typeof options.isStrict === "boolean") {
3505
+ schema.isStrict = options.isStrict;
3492
3506
  }
3493
3507
  Object.keys(inputSchema.properties).forEach((key) => {
3494
3508
  if (!schema.properties) {
@@ -3543,10 +3557,10 @@ function omit(inputSchema, keys, options = {}) {
3543
3557
  properties: {
3544
3558
  ...inputSchema.properties
3545
3559
  },
3546
- nullable: inputSchema.nullable
3560
+ isNullable: inputSchema.isNullable
3547
3561
  };
3548
- if (typeof options.strict === "boolean") {
3549
- schema.strict = options.strict;
3562
+ if (typeof options.isStrict === "boolean") {
3563
+ schema.isStrict = options.isStrict;
3550
3564
  }
3551
3565
  Object.keys(inputSchema.properties).forEach((key) => {
3552
3566
  if (keys.includes(key)) {
@@ -3649,12 +3663,13 @@ function extend(baseSchema, inputSchema, options = {}) {
3649
3663
  description: options.description
3650
3664
  }
3651
3665
  };
3652
- if (typeof options.strict === "boolean") {
3653
- schema.strict = options.strict;
3666
+ if (typeof options.isStrict === "boolean") {
3667
+ schema.isNullable = options.isStrict;
3654
3668
  }
3655
3669
  const isType = (input) => validateObjectSchema(schema, input);
3656
3670
  const validator = {
3657
3671
  output: {},
3672
+ optional: false,
3658
3673
  parse(input, context) {
3659
3674
  return decodeObjectSchema(schema, input, context, false);
3660
3675
  },
@@ -3681,14 +3696,14 @@ function partial(schema, options = {}) {
3681
3696
  const newSchema = {
3682
3697
  properties: {},
3683
3698
  optionalProperties: {},
3684
- nullable: schema.nullable,
3699
+ isNullable: schema.isNullable,
3685
3700
  metadata: {
3686
3701
  id: options.id,
3687
3702
  description: options.description
3688
3703
  }
3689
3704
  };
3690
- if (typeof options.strict === "boolean") {
3691
- schema.strict = options.strict;
3705
+ if (typeof options.isStrict === "boolean") {
3706
+ schema.isStrict = options.isStrict;
3692
3707
  }
3693
3708
  for (const key of Object.keys(schema.properties)) {
3694
3709
  const prop = schema.properties[key];
@@ -3737,6 +3752,7 @@ function partial(schema, options = {}) {
3737
3752
  function string(opts = {}) {
3738
3753
  const validator = {
3739
3754
  output: "",
3755
+ optional: false,
3740
3756
  parse: decode,
3741
3757
  coerce: coerce$2,
3742
3758
  validate: validate$2,
@@ -3840,6 +3856,7 @@ function record(schema, opts = {}) {
3840
3856
  };
3841
3857
  const validator = {
3842
3858
  output: {},
3859
+ optional: false,
3843
3860
  validate: validateFn,
3844
3861
  parse: parseFn,
3845
3862
  coerce(input, data) {
@@ -3963,6 +3980,7 @@ function recursive(propA, propB) {
3963
3980
  const recursiveFns = {};
3964
3981
  const validator = {
3965
3982
  output: "",
3983
+ optional: false,
3966
3984
  parse(input, context) {
3967
3985
  if (context.depth >= context.maxDepth) {
3968
3986
  context.errors.push({
@@ -4039,6 +4057,7 @@ function recursive(propA, propB) {
4039
4057
  function timestamp(opts = {}) {
4040
4058
  const validator = {
4041
4059
  output: /* @__PURE__ */ new Date(),
4060
+ optional: false,
4042
4061
  validate: validate$1,
4043
4062
  parse: parse$1,
4044
4063
  coerce: coerce$1,
@@ -4268,7 +4287,8 @@ const _namespace = {
4268
4287
  uint32: uint32,
4269
4288
  uint64: uint64,
4270
4289
  uint8: uint8,
4290
+ undefinable: undefinable,
4271
4291
  validate: validate
4272
4292
  };
4273
4293
 
4274
- export { STR_ESCAPE, VALIDATOR_KEY, ValidationException, _namespace as a, any, array, boolean, clone, coerce, coerceUnsafe, compile, decodeObjectSchema, discriminator, enumerator, errorMessageFromErrors, errors, extend, float32, float64, getCompiledParser, getCompiledSerializer, createParsingTemplate as getSchemaDecodingCode, createSerializationV2Template as getSchemaSerializationCode, createValidationTemplate as getSchemaValidationCode, int16, int16Max, int16Min, int32, int32Max, int32Min, int64, int64Max, int64Min, int8, int8Max, int8Min, isAAraySchema, isADiscriminatorSchema, isAObjectSchema, isARecordSchema, isARefSchema, isAScalarSchema, isAStringEnumSchema, isObject, isValidationException, isValueError, newValidationContext, nullable, number, object, omit, optional, parse, parseUnsafe, partial, pick, record, recursive, sanitizeJson, serialize, serializeObject, serializeSmallString, serializeString, serializeUnsafe, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint64Max, uint64Min, uint8, uint8Max, uint8Min, validate, validateObjectSchema };
4294
+ export { STR_ESCAPE, VALIDATOR_KEY, ValidationException, _namespace as a, any, array, boolean, clone, coerce, coerceUnsafe, compile, decodeObjectSchema, discriminator, enumerator, errorMessageFromErrors, errors, extend, float32, float64, getCompiledParser, getCompiledSerializer, createParsingTemplate as getSchemaDecodingCode, createSerializationV2Template as getSchemaSerializationCode, createValidationTemplate as getSchemaValidationCode, int16, int16Max, int16Min, int32, int32Max, int32Min, int64, int64Max, int64Min, int8, int8Max, int8Min, isAAraySchema, isADiscriminatorSchema, isAObjectSchema, isARecordSchema, isARefSchema, isAScalarSchema, isAStringEnumSchema, isObject, isValidationException, isValueError, newValidationContext, nullable, number, object, omit, optional, parse, parseUnsafe, partial, pick, record, recursive, sanitizeJson, serialize, serializeObject, serializeSmallString, serializeString, serializeUnsafe, string, stringEnum, timestamp, uint16, uint16Max, uint16Min, uint32, uint32Max, uint32Min, uint64, uint64Max, uint64Min, uint8, uint8Max, uint8Min, undefinable, validate, validateObjectSchema };