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