@arrirpc/schema 0.74.1 → 0.75.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.cjs +76 -76
- package/dist/index.mjs +76 -76
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1587,7 +1587,7 @@ function compile(schema) {
|
|
|
1587
1587
|
const result2 = parse(input);
|
|
1588
1588
|
if (!result2.success) {
|
|
1589
1589
|
ctx.errors = result2.errors;
|
|
1590
|
-
return
|
|
1590
|
+
return void 0;
|
|
1591
1591
|
}
|
|
1592
1592
|
return result2.value;
|
|
1593
1593
|
})
|
|
@@ -1784,7 +1784,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1784
1784
|
schemaPath: "/type",
|
|
1785
1785
|
message: `Unable to coerce ${input2} into boolean`
|
|
1786
1786
|
});
|
|
1787
|
-
return
|
|
1787
|
+
return void 0;
|
|
1788
1788
|
}
|
|
1789
1789
|
}
|
|
1790
1790
|
};
|
|
@@ -1813,7 +1813,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1813
1813
|
schemaPath: "/type",
|
|
1814
1814
|
message: `Unable to coerce ${input2} into boolean`
|
|
1815
1815
|
});
|
|
1816
|
-
return
|
|
1816
|
+
return void 0;
|
|
1817
1817
|
}
|
|
1818
1818
|
}
|
|
1819
1819
|
};
|
|
@@ -1844,7 +1844,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1844
1844
|
schemaPath: "/type",
|
|
1845
1845
|
message: `Expected boolean. Got ${typeof input2}`
|
|
1846
1846
|
});
|
|
1847
|
-
return
|
|
1847
|
+
return void 0;
|
|
1848
1848
|
}
|
|
1849
1849
|
};
|
|
1850
1850
|
}
|
|
@@ -1866,7 +1866,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1866
1866
|
schemaPath: "/type",
|
|
1867
1867
|
message: `Expected boolean. Got ${typeof input2}`
|
|
1868
1868
|
});
|
|
1869
|
-
return
|
|
1869
|
+
return void 0;
|
|
1870
1870
|
},
|
|
1871
1871
|
code
|
|
1872
1872
|
};
|
|
@@ -1888,7 +1888,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1888
1888
|
schemaPath: "/type",
|
|
1889
1889
|
message: `Expected string or null. Got ${typeof input2}.`
|
|
1890
1890
|
});
|
|
1891
|
-
return
|
|
1891
|
+
return void 0;
|
|
1892
1892
|
},
|
|
1893
1893
|
code
|
|
1894
1894
|
};
|
|
@@ -1903,7 +1903,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1903
1903
|
instancePath: "/",
|
|
1904
1904
|
schemaPath: "/type"
|
|
1905
1905
|
});
|
|
1906
|
-
return
|
|
1906
|
+
return void 0;
|
|
1907
1907
|
},
|
|
1908
1908
|
code
|
|
1909
1909
|
};
|
|
@@ -1938,7 +1938,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1938
1938
|
schemaPath: "/type",
|
|
1939
1939
|
message: `Expected instanceof Date, ISO Date string, or null. Got ${typeof input2}.`
|
|
1940
1940
|
});
|
|
1941
|
-
return
|
|
1941
|
+
return void 0;
|
|
1942
1942
|
},
|
|
1943
1943
|
code
|
|
1944
1944
|
};
|
|
@@ -1965,7 +1965,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1965
1965
|
schemaPath: "/type",
|
|
1966
1966
|
message: `Expected instanceof Date or ISO Date string. Got ${typeof input2}.`
|
|
1967
1967
|
});
|
|
1968
|
-
return
|
|
1968
|
+
return void 0;
|
|
1969
1969
|
},
|
|
1970
1970
|
code
|
|
1971
1971
|
};
|
|
@@ -1993,7 +1993,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1993
1993
|
schemaPath: "/type",
|
|
1994
1994
|
message: `Expected instanceof Date, ISO Date string, or null. Got ${typeof input2}.`
|
|
1995
1995
|
});
|
|
1996
|
-
return
|
|
1996
|
+
return void 0;
|
|
1997
1997
|
},
|
|
1998
1998
|
code
|
|
1999
1999
|
};
|
|
@@ -2014,7 +2014,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
2014
2014
|
schemaPath: "/type",
|
|
2015
2015
|
message: `Expected instance of Date or ISO date string. Got ${typeof input2}.`
|
|
2016
2016
|
});
|
|
2017
|
-
return
|
|
2017
|
+
return void 0;
|
|
2018
2018
|
},
|
|
2019
2019
|
code
|
|
2020
2020
|
};
|
|
@@ -2044,7 +2044,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
2044
2044
|
", "
|
|
2045
2045
|
)}] or null. Got ${typeof input2}.`
|
|
2046
2046
|
});
|
|
2047
|
-
return
|
|
2047
|
+
return void 0;
|
|
2048
2048
|
},
|
|
2049
2049
|
code
|
|
2050
2050
|
};
|
|
@@ -2065,7 +2065,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
2065
2065
|
", "
|
|
2066
2066
|
)}]. Got ${typeof input2}.`
|
|
2067
2067
|
});
|
|
2068
|
-
return
|
|
2068
|
+
return void 0;
|
|
2069
2069
|
},
|
|
2070
2070
|
code
|
|
2071
2071
|
};
|
|
@@ -2083,7 +2083,7 @@ function compiledFloatDecoder(input, context) {
|
|
|
2083
2083
|
schemaPath: "/type",
|
|
2084
2084
|
message: `Unable to decode number from ${input}`
|
|
2085
2085
|
});
|
|
2086
|
-
return
|
|
2086
|
+
return void 0;
|
|
2087
2087
|
}
|
|
2088
2088
|
if (typeof input === "number" && !Number.isNaN(input)) {
|
|
2089
2089
|
return input;
|
|
@@ -2093,7 +2093,7 @@ function compiledFloatDecoder(input, context) {
|
|
|
2093
2093
|
schemaPath: "/type",
|
|
2094
2094
|
message: `Expected number. Got ${typeof input}`
|
|
2095
2095
|
});
|
|
2096
|
-
return
|
|
2096
|
+
return void 0;
|
|
2097
2097
|
}
|
|
2098
2098
|
function nullableFloatDecoder(input, context) {
|
|
2099
2099
|
if (typeof input === "string") {
|
|
@@ -2109,7 +2109,7 @@ function nullableFloatDecoder(input, context) {
|
|
|
2109
2109
|
schemaPath: "/type",
|
|
2110
2110
|
message: `Unable to decode number from ${input}`
|
|
2111
2111
|
});
|
|
2112
|
-
return
|
|
2112
|
+
return void 0;
|
|
2113
2113
|
}
|
|
2114
2114
|
if (typeof input === "number" && !Number.isNaN(input)) {
|
|
2115
2115
|
return input;
|
|
@@ -2122,7 +2122,7 @@ function nullableFloatDecoder(input, context) {
|
|
|
2122
2122
|
schemaPath: "/type",
|
|
2123
2123
|
message: `Expected number or null. Got ${typeof input}`
|
|
2124
2124
|
});
|
|
2125
|
-
return
|
|
2125
|
+
return void 0;
|
|
2126
2126
|
}
|
|
2127
2127
|
function bigIntDecoder(input, isUnsigned, isNullable, context) {
|
|
2128
2128
|
if (typeof input === "string" || typeof input === "number") {
|
|
@@ -2158,7 +2158,7 @@ function bigIntDecoder(input, isUnsigned, isNullable, context) {
|
|
|
2158
2158
|
data: err,
|
|
2159
2159
|
message: `Error transforming ${input} to BigInt`
|
|
2160
2160
|
});
|
|
2161
|
-
return
|
|
2161
|
+
return void 0;
|
|
2162
2162
|
}
|
|
2163
2163
|
}
|
|
2164
2164
|
if (typeof input === "bigint") {
|
|
@@ -2180,7 +2180,7 @@ function bigIntDecoder(input, isUnsigned, isNullable, context) {
|
|
|
2180
2180
|
instancePath: "/",
|
|
2181
2181
|
message: `int64 must be an integer between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807`
|
|
2182
2182
|
});
|
|
2183
|
-
return
|
|
2183
|
+
return void 0;
|
|
2184
2184
|
}
|
|
2185
2185
|
if (isNullable && input === null) {
|
|
2186
2186
|
return null;
|
|
@@ -2190,7 +2190,7 @@ function bigIntDecoder(input, isUnsigned, isNullable, context) {
|
|
|
2190
2190
|
instancePath: "/",
|
|
2191
2191
|
message: "Expected BigInt or Integer string"
|
|
2192
2192
|
});
|
|
2193
|
-
return
|
|
2193
|
+
return void 0;
|
|
2194
2194
|
}
|
|
2195
2195
|
function nullableIntDecoder(input, minNum, maxNum, context) {
|
|
2196
2196
|
if (typeof input === "string") {
|
|
@@ -2213,7 +2213,7 @@ function nullableIntDecoder(input, minNum, maxNum, context) {
|
|
|
2213
2213
|
schemaPath: "/type",
|
|
2214
2214
|
message: `Expected valid integer between ${minNum} & ${maxNum} or null. Got ${typeof input}.`
|
|
2215
2215
|
});
|
|
2216
|
-
return
|
|
2216
|
+
return void 0;
|
|
2217
2217
|
}
|
|
2218
2218
|
function intDecoder(input, minNum, maxNum, context) {
|
|
2219
2219
|
if (typeof input === "string") {
|
|
@@ -2230,7 +2230,7 @@ function intDecoder(input, minNum, maxNum, context) {
|
|
|
2230
2230
|
schemaPath: "/type",
|
|
2231
2231
|
message: `Expected valid integer between ${minNum} & ${maxNum}`
|
|
2232
2232
|
});
|
|
2233
|
-
return
|
|
2233
|
+
return void 0;
|
|
2234
2234
|
}
|
|
2235
2235
|
function getCompiledSerializer(schema) {
|
|
2236
2236
|
const code = createSerializationV2Template("input", schema);
|
|
@@ -2375,7 +2375,7 @@ function any(options = {}) {
|
|
|
2375
2375
|
return input;
|
|
2376
2376
|
};
|
|
2377
2377
|
const validator = {
|
|
2378
|
-
output:
|
|
2378
|
+
output: void 0,
|
|
2379
2379
|
parse,
|
|
2380
2380
|
coerce: (input, context) => {
|
|
2381
2381
|
if (context.instancePath.length === 0 && typeof input === "string") {
|
|
@@ -2432,7 +2432,7 @@ function array(schema, opts = {}) {
|
|
|
2432
2432
|
exitOnFirstError: context.exitOnFirstError
|
|
2433
2433
|
});
|
|
2434
2434
|
if (!part) {
|
|
2435
|
-
return
|
|
2435
|
+
return void 0;
|
|
2436
2436
|
}
|
|
2437
2437
|
strParts.push(part);
|
|
2438
2438
|
}
|
|
@@ -2475,7 +2475,7 @@ function parse$5(innerSchema, input, context, coerce = false) {
|
|
|
2475
2475
|
schemaPath: `${context.schemaPath}/elements`,
|
|
2476
2476
|
message: `Error at ${context.instancePath}. Invalid JSON.`
|
|
2477
2477
|
});
|
|
2478
|
-
return
|
|
2478
|
+
return void 0;
|
|
2479
2479
|
}
|
|
2480
2480
|
}
|
|
2481
2481
|
if (!Array.isArray(parsedInput)) {
|
|
@@ -2484,7 +2484,7 @@ function parse$5(innerSchema, input, context, coerce = false) {
|
|
|
2484
2484
|
schemaPath: `${context.schemaPath}/elements`,
|
|
2485
2485
|
message: `Error at ${context.instancePath}. Expected array. Got ${typeof input}.`
|
|
2486
2486
|
});
|
|
2487
|
-
return
|
|
2487
|
+
return void 0;
|
|
2488
2488
|
}
|
|
2489
2489
|
const result = [];
|
|
2490
2490
|
for (let i = 0; i < parsedInput.length; i++) {
|
|
@@ -2512,7 +2512,7 @@ function parse$5(innerSchema, input, context, coerce = false) {
|
|
|
2512
2512
|
}
|
|
2513
2513
|
}
|
|
2514
2514
|
if (context.errors.length) {
|
|
2515
|
-
return
|
|
2515
|
+
return void 0;
|
|
2516
2516
|
}
|
|
2517
2517
|
return result;
|
|
2518
2518
|
}
|
|
@@ -2544,7 +2544,7 @@ function boolean(opts = {}) {
|
|
|
2544
2544
|
schemaPath: context.schemaPath,
|
|
2545
2545
|
message: `Error at ${context.instancePath}. Unable to coerce ${input} to boolean.`
|
|
2546
2546
|
});
|
|
2547
|
-
return
|
|
2547
|
+
return void 0;
|
|
2548
2548
|
}
|
|
2549
2549
|
};
|
|
2550
2550
|
const result = {
|
|
@@ -2579,14 +2579,14 @@ function parse$4(input, data) {
|
|
|
2579
2579
|
schemaPath: `${data.schemaPath}/type`,
|
|
2580
2580
|
message: `Error at ${data.instancePath}. Expected boolean. Got ${typeof input}.`
|
|
2581
2581
|
});
|
|
2582
|
-
return
|
|
2582
|
+
return void 0;
|
|
2583
2583
|
}
|
|
2584
2584
|
data.errors.push({
|
|
2585
2585
|
instancePath: data.instancePath,
|
|
2586
2586
|
schemaPath: `${data.schemaPath}/type`,
|
|
2587
2587
|
message: `Error at ${data.instancePath}. Expected boolean. Got ${typeof input}.`
|
|
2588
2588
|
});
|
|
2589
|
-
return
|
|
2589
|
+
return void 0;
|
|
2590
2590
|
}
|
|
2591
2591
|
function serialize$2(input) {
|
|
2592
2592
|
return `${input}`;
|
|
@@ -2620,7 +2620,7 @@ function discriminator(propA, propB, propC) {
|
|
|
2620
2620
|
context.errors.push(
|
|
2621
2621
|
discriminatorMappingError(discriminatorVal, context)
|
|
2622
2622
|
);
|
|
2623
|
-
return
|
|
2623
|
+
return void 0;
|
|
2624
2624
|
}
|
|
2625
2625
|
const result2 = targetSchema[adapters.VALIDATOR_KEY].serialize(input, {
|
|
2626
2626
|
instancePath: context.instancePath,
|
|
@@ -2678,7 +2678,7 @@ function parse$3(discriminator2, mapping, input, context, coerce = false) {
|
|
|
2678
2678
|
instancePath: context.instancePath,
|
|
2679
2679
|
schemaPath: context.schemaPath
|
|
2680
2680
|
});
|
|
2681
|
-
return
|
|
2681
|
+
return void 0;
|
|
2682
2682
|
}
|
|
2683
2683
|
}
|
|
2684
2684
|
if (!adapters.isObject(parsedInput)) {
|
|
@@ -2687,7 +2687,7 @@ function parse$3(discriminator2, mapping, input, context, coerce = false) {
|
|
|
2687
2687
|
schemaPath: `${context.schemaPath}/discriminator`,
|
|
2688
2688
|
message: `Error at ${context.instancePath}. Expected object. Got ${typeof parsedInput}.`
|
|
2689
2689
|
});
|
|
2690
|
-
return
|
|
2690
|
+
return void 0;
|
|
2691
2691
|
}
|
|
2692
2692
|
if (!(discriminator2 in parsedInput)) {
|
|
2693
2693
|
context.errors.push({
|
|
@@ -2695,7 +2695,7 @@ function parse$3(discriminator2, mapping, input, context, coerce = false) {
|
|
|
2695
2695
|
schemaPath: `${context.schemaPath}/discriminator`,
|
|
2696
2696
|
message: `Error at ${context.instancePath}/${discriminator2}. Discriminator field "${discriminator2}" cannot be undefined`
|
|
2697
2697
|
});
|
|
2698
|
-
return
|
|
2698
|
+
return void 0;
|
|
2699
2699
|
}
|
|
2700
2700
|
const acceptedDiscriminatorVals = Object.keys(mapping);
|
|
2701
2701
|
const discriminatorVal = parsedInput[discriminator2];
|
|
@@ -2707,11 +2707,11 @@ function parse$3(discriminator2, mapping, input, context, coerce = false) {
|
|
|
2707
2707
|
", "
|
|
2708
2708
|
)}]`
|
|
2709
2709
|
});
|
|
2710
|
-
return
|
|
2710
|
+
return void 0;
|
|
2711
2711
|
}
|
|
2712
2712
|
const targetSchema = mapping[parsedInput[discriminator2]];
|
|
2713
2713
|
if (!targetSchema) {
|
|
2714
|
-
return
|
|
2714
|
+
return void 0;
|
|
2715
2715
|
}
|
|
2716
2716
|
if (coerce) {
|
|
2717
2717
|
const result2 = targetSchema[adapters.VALIDATOR_KEY].coerce(parsedInput, {
|
|
@@ -2773,7 +2773,7 @@ function enumerator(paramA, paramB) {
|
|
|
2773
2773
|
", "
|
|
2774
2774
|
)}]`
|
|
2775
2775
|
});
|
|
2776
|
-
return
|
|
2776
|
+
return void 0;
|
|
2777
2777
|
};
|
|
2778
2778
|
const validator = {
|
|
2779
2779
|
output: paramA[0] ?? "",
|
|
@@ -2789,7 +2789,7 @@ function enumerator(paramA, paramB) {
|
|
|
2789
2789
|
", "
|
|
2790
2790
|
)}]`
|
|
2791
2791
|
});
|
|
2792
|
-
return
|
|
2792
|
+
return void 0;
|
|
2793
2793
|
},
|
|
2794
2794
|
validate: isType,
|
|
2795
2795
|
serialize(input, context) {
|
|
@@ -2869,31 +2869,31 @@ function nullable(schema, opts = {}) {
|
|
|
2869
2869
|
}
|
|
2870
2870
|
function optional(input, opts = {}) {
|
|
2871
2871
|
const isType = (val) => {
|
|
2872
|
-
if (val ===
|
|
2872
|
+
if (val === void 0) {
|
|
2873
2873
|
return true;
|
|
2874
2874
|
}
|
|
2875
2875
|
return input[adapters.VALIDATOR_KEY].validate(val);
|
|
2876
2876
|
};
|
|
2877
2877
|
const parse = (val, context) => {
|
|
2878
2878
|
if (typeof val === "undefined") {
|
|
2879
|
-
return
|
|
2879
|
+
return void 0;
|
|
2880
2880
|
}
|
|
2881
2881
|
if (context.instancePath.length === 0 && val === "undefined") {
|
|
2882
|
-
return
|
|
2882
|
+
return void 0;
|
|
2883
2883
|
}
|
|
2884
2884
|
return input[adapters.VALIDATOR_KEY].parse(val, context);
|
|
2885
2885
|
};
|
|
2886
2886
|
const validator = {
|
|
2887
|
-
output:
|
|
2887
|
+
output: void 0,
|
|
2888
2888
|
optional: true,
|
|
2889
2889
|
validate: isType,
|
|
2890
2890
|
parse,
|
|
2891
2891
|
coerce: (val, data) => {
|
|
2892
2892
|
if (typeof val === "undefined") {
|
|
2893
|
-
return
|
|
2893
|
+
return void 0;
|
|
2894
2894
|
}
|
|
2895
2895
|
if (val === "undefined") {
|
|
2896
|
-
return
|
|
2896
|
+
return void 0;
|
|
2897
2897
|
}
|
|
2898
2898
|
return input[adapters.VALIDATOR_KEY].coerce(val, data);
|
|
2899
2899
|
},
|
|
@@ -2950,7 +2950,7 @@ function coerceNumber(input, options) {
|
|
|
2950
2950
|
schemaPath: `${options.schemaPath}/type`,
|
|
2951
2951
|
message: `Error at ${options.instancePath}. Unable to coerce ${typeof input} into a number`
|
|
2952
2952
|
});
|
|
2953
|
-
return
|
|
2953
|
+
return void 0;
|
|
2954
2954
|
}
|
|
2955
2955
|
return decodeNumber(decodedInput, options);
|
|
2956
2956
|
}
|
|
@@ -3075,7 +3075,7 @@ function int64(opts = {}) {
|
|
|
3075
3075
|
schemaPath: `${context.schemaPath}/type`,
|
|
3076
3076
|
instancePath: context.instancePath
|
|
3077
3077
|
});
|
|
3078
|
-
return
|
|
3078
|
+
return void 0;
|
|
3079
3079
|
}
|
|
3080
3080
|
}
|
|
3081
3081
|
if (isType(input)) {
|
|
@@ -3086,7 +3086,7 @@ function int64(opts = {}) {
|
|
|
3086
3086
|
schemaPath: `${context.schemaPath}/type`,
|
|
3087
3087
|
instancePath: context.instancePath
|
|
3088
3088
|
});
|
|
3089
|
-
return
|
|
3089
|
+
return void 0;
|
|
3090
3090
|
}
|
|
3091
3091
|
const validator = {
|
|
3092
3092
|
output: BigInt("0"),
|
|
@@ -3136,7 +3136,7 @@ function uint64(opts = {}) {
|
|
|
3136
3136
|
schemaPath: `${context.schemaPath}/type`,
|
|
3137
3137
|
instancePath: context.instancePath
|
|
3138
3138
|
});
|
|
3139
|
-
return
|
|
3139
|
+
return void 0;
|
|
3140
3140
|
}
|
|
3141
3141
|
}
|
|
3142
3142
|
if (isType(input)) {
|
|
@@ -3147,7 +3147,7 @@ function uint64(opts = {}) {
|
|
|
3147
3147
|
schemaPath: `${context.schemaPath}/type`,
|
|
3148
3148
|
instancePath: context.instancePath
|
|
3149
3149
|
});
|
|
3150
|
-
return
|
|
3150
|
+
return void 0;
|
|
3151
3151
|
}
|
|
3152
3152
|
const validator = {
|
|
3153
3153
|
output: BigInt("0"),
|
|
@@ -3192,7 +3192,7 @@ function decodeNumber(input, context) {
|
|
|
3192
3192
|
schemaPath: `${context.schemaPath}/type`,
|
|
3193
3193
|
message: `Error at ${context.instancePath}. Invalid number.`
|
|
3194
3194
|
});
|
|
3195
|
-
return
|
|
3195
|
+
return void 0;
|
|
3196
3196
|
}
|
|
3197
3197
|
return result;
|
|
3198
3198
|
}
|
|
@@ -3204,7 +3204,7 @@ function decodeNumber(input, context) {
|
|
|
3204
3204
|
schemaPath: `${context.schemaPath}/type`,
|
|
3205
3205
|
message: `Error at ${context.instancePath}. Invalid number.`
|
|
3206
3206
|
});
|
|
3207
|
-
return
|
|
3207
|
+
return void 0;
|
|
3208
3208
|
}
|
|
3209
3209
|
function numberScalarType(type, opts, numTypeMatcher) {
|
|
3210
3210
|
const validate = (input) => {
|
|
@@ -3217,7 +3217,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
|
|
|
3217
3217
|
const parse = (input, context) => {
|
|
3218
3218
|
const result2 = decodeNumber(input, context);
|
|
3219
3219
|
if (context.errors.length) {
|
|
3220
|
-
return
|
|
3220
|
+
return void 0;
|
|
3221
3221
|
}
|
|
3222
3222
|
if (typeof result2 !== "number") {
|
|
3223
3223
|
context?.errors.push({
|
|
@@ -3225,7 +3225,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
|
|
|
3225
3225
|
schemaPath: `${context.schemaPath}/type`,
|
|
3226
3226
|
message: `Error at ${context.instancePath}. Invalid number.`
|
|
3227
3227
|
});
|
|
3228
|
-
return
|
|
3228
|
+
return void 0;
|
|
3229
3229
|
}
|
|
3230
3230
|
const matchResult = numTypeMatcher(result2);
|
|
3231
3231
|
if (matchResult.success) {
|
|
@@ -3236,7 +3236,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
|
|
|
3236
3236
|
schemaPath: `${context.schemaPath}/type`,
|
|
3237
3237
|
message: `Error at ${context.instancePath}. ${matchResult.message}`
|
|
3238
3238
|
});
|
|
3239
|
-
return
|
|
3239
|
+
return void 0;
|
|
3240
3240
|
};
|
|
3241
3241
|
const validator = {
|
|
3242
3242
|
output: 0,
|
|
@@ -3251,7 +3251,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
|
|
|
3251
3251
|
schemaPath: `${options.schemaPath}/type`,
|
|
3252
3252
|
message: `Error at ${options.instancePath}. Unable to coerce ${typeof input} to ${type}.`
|
|
3253
3253
|
});
|
|
3254
|
-
return
|
|
3254
|
+
return void 0;
|
|
3255
3255
|
}
|
|
3256
3256
|
const matchResult = numTypeMatcher(result2);
|
|
3257
3257
|
if (matchResult.success) {
|
|
@@ -3262,7 +3262,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
|
|
|
3262
3262
|
schemaPath: `${options.schemaPath}/type`,
|
|
3263
3263
|
message: `Error at ${options.instancePath}. ${matchResult.message}`
|
|
3264
3264
|
});
|
|
3265
|
-
return
|
|
3265
|
+
return void 0;
|
|
3266
3266
|
}
|
|
3267
3267
|
};
|
|
3268
3268
|
const result = {
|
|
@@ -3356,7 +3356,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3356
3356
|
schemaPath: `${context.schemaPath}/properties`,
|
|
3357
3357
|
message: `Error at ${context.instancePath}. Invalid JSON.`
|
|
3358
3358
|
});
|
|
3359
|
-
return
|
|
3359
|
+
return void 0;
|
|
3360
3360
|
}
|
|
3361
3361
|
}
|
|
3362
3362
|
if (!adapters.isObject(parsedInput)) {
|
|
@@ -3365,7 +3365,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3365
3365
|
schemaPath: `${context.schemaPath}/properties`,
|
|
3366
3366
|
message: `Error at ${context.instancePath}. Expected object`
|
|
3367
3367
|
});
|
|
3368
|
-
return
|
|
3368
|
+
return void 0;
|
|
3369
3369
|
}
|
|
3370
3370
|
const result = {};
|
|
3371
3371
|
const optionalProps = schema.optionalProperties ?? {};
|
|
@@ -3384,7 +3384,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3384
3384
|
}
|
|
3385
3385
|
}
|
|
3386
3386
|
if (context.errors.length) {
|
|
3387
|
-
return
|
|
3387
|
+
return void 0;
|
|
3388
3388
|
}
|
|
3389
3389
|
if (context.discriminatorKey) {
|
|
3390
3390
|
result[context.discriminatorKey] = context.discriminatorValue;
|
|
@@ -3402,7 +3402,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3402
3402
|
exitOnFirstError: context.exitOnFirstError
|
|
3403
3403
|
});
|
|
3404
3404
|
if (context.errors.length && context.exitOnFirstError) {
|
|
3405
|
-
return
|
|
3405
|
+
return void 0;
|
|
3406
3406
|
}
|
|
3407
3407
|
continue;
|
|
3408
3408
|
}
|
|
@@ -3415,13 +3415,13 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3415
3415
|
exitOnFirstError: context.exitOnFirstError
|
|
3416
3416
|
});
|
|
3417
3417
|
if (context.errors.length && context.exitOnFirstError) {
|
|
3418
|
-
return
|
|
3418
|
+
return void 0;
|
|
3419
3419
|
}
|
|
3420
3420
|
}
|
|
3421
3421
|
for (const key of optionalKeys) {
|
|
3422
3422
|
const val = parsedInput[key];
|
|
3423
3423
|
const prop = optionalProps[key];
|
|
3424
|
-
if (val ===
|
|
3424
|
+
if (val === void 0) {
|
|
3425
3425
|
continue;
|
|
3426
3426
|
}
|
|
3427
3427
|
if (coerce) {
|
|
@@ -3434,7 +3434,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3434
3434
|
exitOnFirstError: context.exitOnFirstError
|
|
3435
3435
|
});
|
|
3436
3436
|
if (context.errors.length && context.exitOnFirstError) {
|
|
3437
|
-
return
|
|
3437
|
+
return void 0;
|
|
3438
3438
|
}
|
|
3439
3439
|
continue;
|
|
3440
3440
|
}
|
|
@@ -3448,12 +3448,12 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3448
3448
|
exitOnFirstError: context.exitOnFirstError
|
|
3449
3449
|
});
|
|
3450
3450
|
if (context.errors.length && context.exitOnFirstError) {
|
|
3451
|
-
return
|
|
3451
|
+
return void 0;
|
|
3452
3452
|
}
|
|
3453
3453
|
}
|
|
3454
3454
|
}
|
|
3455
3455
|
if (context.errors.length) {
|
|
3456
|
-
return
|
|
3456
|
+
return void 0;
|
|
3457
3457
|
}
|
|
3458
3458
|
return result;
|
|
3459
3459
|
}
|
|
@@ -3461,7 +3461,7 @@ function validateObjectSchema(schema, input) {
|
|
|
3461
3461
|
if (!adapters.isObject(input)) {
|
|
3462
3462
|
return false;
|
|
3463
3463
|
}
|
|
3464
|
-
const allowedKeys = schema.strict ? [] :
|
|
3464
|
+
const allowedKeys = schema.strict ? [] : void 0;
|
|
3465
3465
|
for (const key of Object.keys(schema.properties)) {
|
|
3466
3466
|
const propSchema = schema.properties[key];
|
|
3467
3467
|
const isValid = propSchema[adapters.VALIDATOR_KEY].validate(input[key]);
|
|
@@ -3788,7 +3788,7 @@ function decode(input, context) {
|
|
|
3788
3788
|
schemaPath: `${context.schemaPath}/type`,
|
|
3789
3789
|
message: `Error at ${context.instancePath}. Expected 'string' got ${typeof input}.`
|
|
3790
3790
|
});
|
|
3791
|
-
return
|
|
3791
|
+
return void 0;
|
|
3792
3792
|
}
|
|
3793
3793
|
function coerce$2(input, context) {
|
|
3794
3794
|
return decode(input, context);
|
|
@@ -3853,7 +3853,7 @@ function record(schema, opts = {}) {
|
|
|
3853
3853
|
schemaPath: context.schemaPath,
|
|
3854
3854
|
message: "Max depth reached"
|
|
3855
3855
|
});
|
|
3856
|
-
return
|
|
3856
|
+
return void 0;
|
|
3857
3857
|
}
|
|
3858
3858
|
let result2 = "{";
|
|
3859
3859
|
const keys = Object.keys(input);
|
|
@@ -3896,7 +3896,7 @@ function parse$2(schema, input, data, coerce = false) {
|
|
|
3896
3896
|
schemaPath: data.schemaPath,
|
|
3897
3897
|
message: "Max depth reached"
|
|
3898
3898
|
});
|
|
3899
|
-
return
|
|
3899
|
+
return void 0;
|
|
3900
3900
|
}
|
|
3901
3901
|
let parsedInput = input;
|
|
3902
3902
|
if (data.instancePath.length === 0 && typeof input === "string" && input.length > 0) {
|
|
@@ -3909,7 +3909,7 @@ function parse$2(schema, input, data, coerce = false) {
|
|
|
3909
3909
|
schemaPath: data.schemaPath,
|
|
3910
3910
|
data: err
|
|
3911
3911
|
});
|
|
3912
|
-
return
|
|
3912
|
+
return void 0;
|
|
3913
3913
|
}
|
|
3914
3914
|
}
|
|
3915
3915
|
if (!adapters.isObject(parsedInput)) {
|
|
@@ -3918,7 +3918,7 @@ function parse$2(schema, input, data, coerce = false) {
|
|
|
3918
3918
|
schemaPath: `${data.schemaPath}/values`,
|
|
3919
3919
|
message: `Error at ${data.instancePath} Expected object`
|
|
3920
3920
|
});
|
|
3921
|
-
return
|
|
3921
|
+
return void 0;
|
|
3922
3922
|
}
|
|
3923
3923
|
const result = {};
|
|
3924
3924
|
for (const key of Object.keys(parsedInput)) {
|
|
@@ -3944,7 +3944,7 @@ function parse$2(schema, input, data, coerce = false) {
|
|
|
3944
3944
|
}
|
|
3945
3945
|
}
|
|
3946
3946
|
if (data.errors.length) {
|
|
3947
|
-
return
|
|
3947
|
+
return void 0;
|
|
3948
3948
|
}
|
|
3949
3949
|
return result;
|
|
3950
3950
|
}
|
|
@@ -3971,7 +3971,7 @@ function recursive(propA, propB) {
|
|
|
3971
3971
|
instancePath: context.instancePath,
|
|
3972
3972
|
schemaPath: context.schemaPath
|
|
3973
3973
|
});
|
|
3974
|
-
return
|
|
3974
|
+
return void 0;
|
|
3975
3975
|
}
|
|
3976
3976
|
if (recursiveFns[id]) {
|
|
3977
3977
|
return recursiveFns[id].parse(input, {
|
|
@@ -3987,7 +3987,7 @@ function recursive(propA, propB) {
|
|
|
3987
3987
|
instancePath: context.instancePath,
|
|
3988
3988
|
schemaPath: context.schemaPath
|
|
3989
3989
|
});
|
|
3990
|
-
return
|
|
3990
|
+
return void 0;
|
|
3991
3991
|
}
|
|
3992
3992
|
if (recursiveFns[id]) {
|
|
3993
3993
|
return recursiveFns[id].serialize(input, context);
|
|
@@ -4007,7 +4007,7 @@ function recursive(propA, propB) {
|
|
|
4007
4007
|
instancePath: context.instancePath,
|
|
4008
4008
|
schemaPath: context.schemaPath
|
|
4009
4009
|
});
|
|
4010
|
-
return
|
|
4010
|
+
return void 0;
|
|
4011
4011
|
}
|
|
4012
4012
|
if (recursiveFns[id]) {
|
|
4013
4013
|
return recursiveFns[id].coerce(input, context);
|
|
@@ -4091,7 +4091,7 @@ function parse$1(input, data) {
|
|
|
4091
4091
|
schemaPath: data.schemaPath,
|
|
4092
4092
|
data: err
|
|
4093
4093
|
});
|
|
4094
|
-
return
|
|
4094
|
+
return void 0;
|
|
4095
4095
|
}
|
|
4096
4096
|
}
|
|
4097
4097
|
function coerce$1(input, options) {
|
package/dist/index.mjs
CHANGED
|
@@ -1586,7 +1586,7 @@ function compile(schema) {
|
|
|
1586
1586
|
const result2 = parse(input);
|
|
1587
1587
|
if (!result2.success) {
|
|
1588
1588
|
ctx.errors = result2.errors;
|
|
1589
|
-
return
|
|
1589
|
+
return void 0;
|
|
1590
1590
|
}
|
|
1591
1591
|
return result2.value;
|
|
1592
1592
|
})
|
|
@@ -1783,7 +1783,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1783
1783
|
schemaPath: "/type",
|
|
1784
1784
|
message: `Unable to coerce ${input2} into boolean`
|
|
1785
1785
|
});
|
|
1786
|
-
return
|
|
1786
|
+
return void 0;
|
|
1787
1787
|
}
|
|
1788
1788
|
}
|
|
1789
1789
|
};
|
|
@@ -1812,7 +1812,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1812
1812
|
schemaPath: "/type",
|
|
1813
1813
|
message: `Unable to coerce ${input2} into boolean`
|
|
1814
1814
|
});
|
|
1815
|
-
return
|
|
1815
|
+
return void 0;
|
|
1816
1816
|
}
|
|
1817
1817
|
}
|
|
1818
1818
|
};
|
|
@@ -1843,7 +1843,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1843
1843
|
schemaPath: "/type",
|
|
1844
1844
|
message: `Expected boolean. Got ${typeof input2}`
|
|
1845
1845
|
});
|
|
1846
|
-
return
|
|
1846
|
+
return void 0;
|
|
1847
1847
|
}
|
|
1848
1848
|
};
|
|
1849
1849
|
}
|
|
@@ -1865,7 +1865,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1865
1865
|
schemaPath: "/type",
|
|
1866
1866
|
message: `Expected boolean. Got ${typeof input2}`
|
|
1867
1867
|
});
|
|
1868
|
-
return
|
|
1868
|
+
return void 0;
|
|
1869
1869
|
},
|
|
1870
1870
|
code
|
|
1871
1871
|
};
|
|
@@ -1887,7 +1887,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1887
1887
|
schemaPath: "/type",
|
|
1888
1888
|
message: `Expected string or null. Got ${typeof input2}.`
|
|
1889
1889
|
});
|
|
1890
|
-
return
|
|
1890
|
+
return void 0;
|
|
1891
1891
|
},
|
|
1892
1892
|
code
|
|
1893
1893
|
};
|
|
@@ -1902,7 +1902,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1902
1902
|
instancePath: "/",
|
|
1903
1903
|
schemaPath: "/type"
|
|
1904
1904
|
});
|
|
1905
|
-
return
|
|
1905
|
+
return void 0;
|
|
1906
1906
|
},
|
|
1907
1907
|
code
|
|
1908
1908
|
};
|
|
@@ -1937,7 +1937,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1937
1937
|
schemaPath: "/type",
|
|
1938
1938
|
message: `Expected instanceof Date, ISO Date string, or null. Got ${typeof input2}.`
|
|
1939
1939
|
});
|
|
1940
|
-
return
|
|
1940
|
+
return void 0;
|
|
1941
1941
|
},
|
|
1942
1942
|
code
|
|
1943
1943
|
};
|
|
@@ -1964,7 +1964,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1964
1964
|
schemaPath: "/type",
|
|
1965
1965
|
message: `Expected instanceof Date or ISO Date string. Got ${typeof input2}.`
|
|
1966
1966
|
});
|
|
1967
|
-
return
|
|
1967
|
+
return void 0;
|
|
1968
1968
|
},
|
|
1969
1969
|
code
|
|
1970
1970
|
};
|
|
@@ -1992,7 +1992,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
1992
1992
|
schemaPath: "/type",
|
|
1993
1993
|
message: `Expected instanceof Date, ISO Date string, or null. Got ${typeof input2}.`
|
|
1994
1994
|
});
|
|
1995
|
-
return
|
|
1995
|
+
return void 0;
|
|
1996
1996
|
},
|
|
1997
1997
|
code
|
|
1998
1998
|
};
|
|
@@ -2013,7 +2013,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
2013
2013
|
schemaPath: "/type",
|
|
2014
2014
|
message: `Expected instance of Date or ISO date string. Got ${typeof input2}.`
|
|
2015
2015
|
});
|
|
2016
|
-
return
|
|
2016
|
+
return void 0;
|
|
2017
2017
|
},
|
|
2018
2018
|
code
|
|
2019
2019
|
};
|
|
@@ -2043,7 +2043,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
2043
2043
|
", "
|
|
2044
2044
|
)}] or null. Got ${typeof input2}.`
|
|
2045
2045
|
});
|
|
2046
|
-
return
|
|
2046
|
+
return void 0;
|
|
2047
2047
|
},
|
|
2048
2048
|
code
|
|
2049
2049
|
};
|
|
@@ -2064,7 +2064,7 @@ function getCompiledParser(input, schema, shouldCoerce) {
|
|
|
2064
2064
|
", "
|
|
2065
2065
|
)}]. Got ${typeof input2}.`
|
|
2066
2066
|
});
|
|
2067
|
-
return
|
|
2067
|
+
return void 0;
|
|
2068
2068
|
},
|
|
2069
2069
|
code
|
|
2070
2070
|
};
|
|
@@ -2082,7 +2082,7 @@ function compiledFloatDecoder(input, context) {
|
|
|
2082
2082
|
schemaPath: "/type",
|
|
2083
2083
|
message: `Unable to decode number from ${input}`
|
|
2084
2084
|
});
|
|
2085
|
-
return
|
|
2085
|
+
return void 0;
|
|
2086
2086
|
}
|
|
2087
2087
|
if (typeof input === "number" && !Number.isNaN(input)) {
|
|
2088
2088
|
return input;
|
|
@@ -2092,7 +2092,7 @@ function compiledFloatDecoder(input, context) {
|
|
|
2092
2092
|
schemaPath: "/type",
|
|
2093
2093
|
message: `Expected number. Got ${typeof input}`
|
|
2094
2094
|
});
|
|
2095
|
-
return
|
|
2095
|
+
return void 0;
|
|
2096
2096
|
}
|
|
2097
2097
|
function nullableFloatDecoder(input, context) {
|
|
2098
2098
|
if (typeof input === "string") {
|
|
@@ -2108,7 +2108,7 @@ function nullableFloatDecoder(input, context) {
|
|
|
2108
2108
|
schemaPath: "/type",
|
|
2109
2109
|
message: `Unable to decode number from ${input}`
|
|
2110
2110
|
});
|
|
2111
|
-
return
|
|
2111
|
+
return void 0;
|
|
2112
2112
|
}
|
|
2113
2113
|
if (typeof input === "number" && !Number.isNaN(input)) {
|
|
2114
2114
|
return input;
|
|
@@ -2121,7 +2121,7 @@ function nullableFloatDecoder(input, context) {
|
|
|
2121
2121
|
schemaPath: "/type",
|
|
2122
2122
|
message: `Expected number or null. Got ${typeof input}`
|
|
2123
2123
|
});
|
|
2124
|
-
return
|
|
2124
|
+
return void 0;
|
|
2125
2125
|
}
|
|
2126
2126
|
function bigIntDecoder(input, isUnsigned, isNullable, context) {
|
|
2127
2127
|
if (typeof input === "string" || typeof input === "number") {
|
|
@@ -2157,7 +2157,7 @@ function bigIntDecoder(input, isUnsigned, isNullable, context) {
|
|
|
2157
2157
|
data: err,
|
|
2158
2158
|
message: `Error transforming ${input} to BigInt`
|
|
2159
2159
|
});
|
|
2160
|
-
return
|
|
2160
|
+
return void 0;
|
|
2161
2161
|
}
|
|
2162
2162
|
}
|
|
2163
2163
|
if (typeof input === "bigint") {
|
|
@@ -2179,7 +2179,7 @@ function bigIntDecoder(input, isUnsigned, isNullable, context) {
|
|
|
2179
2179
|
instancePath: "/",
|
|
2180
2180
|
message: `int64 must be an integer between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807`
|
|
2181
2181
|
});
|
|
2182
|
-
return
|
|
2182
|
+
return void 0;
|
|
2183
2183
|
}
|
|
2184
2184
|
if (isNullable && input === null) {
|
|
2185
2185
|
return null;
|
|
@@ -2189,7 +2189,7 @@ function bigIntDecoder(input, isUnsigned, isNullable, context) {
|
|
|
2189
2189
|
instancePath: "/",
|
|
2190
2190
|
message: "Expected BigInt or Integer string"
|
|
2191
2191
|
});
|
|
2192
|
-
return
|
|
2192
|
+
return void 0;
|
|
2193
2193
|
}
|
|
2194
2194
|
function nullableIntDecoder(input, minNum, maxNum, context) {
|
|
2195
2195
|
if (typeof input === "string") {
|
|
@@ -2212,7 +2212,7 @@ function nullableIntDecoder(input, minNum, maxNum, context) {
|
|
|
2212
2212
|
schemaPath: "/type",
|
|
2213
2213
|
message: `Expected valid integer between ${minNum} & ${maxNum} or null. Got ${typeof input}.`
|
|
2214
2214
|
});
|
|
2215
|
-
return
|
|
2215
|
+
return void 0;
|
|
2216
2216
|
}
|
|
2217
2217
|
function intDecoder(input, minNum, maxNum, context) {
|
|
2218
2218
|
if (typeof input === "string") {
|
|
@@ -2229,7 +2229,7 @@ function intDecoder(input, minNum, maxNum, context) {
|
|
|
2229
2229
|
schemaPath: "/type",
|
|
2230
2230
|
message: `Expected valid integer between ${minNum} & ${maxNum}`
|
|
2231
2231
|
});
|
|
2232
|
-
return
|
|
2232
|
+
return void 0;
|
|
2233
2233
|
}
|
|
2234
2234
|
function getCompiledSerializer(schema) {
|
|
2235
2235
|
const code = createSerializationV2Template("input", schema);
|
|
@@ -2374,7 +2374,7 @@ function any(options = {}) {
|
|
|
2374
2374
|
return input;
|
|
2375
2375
|
};
|
|
2376
2376
|
const validator = {
|
|
2377
|
-
output:
|
|
2377
|
+
output: void 0,
|
|
2378
2378
|
parse,
|
|
2379
2379
|
coerce: (input, context) => {
|
|
2380
2380
|
if (context.instancePath.length === 0 && typeof input === "string") {
|
|
@@ -2431,7 +2431,7 @@ function array(schema, opts = {}) {
|
|
|
2431
2431
|
exitOnFirstError: context.exitOnFirstError
|
|
2432
2432
|
});
|
|
2433
2433
|
if (!part) {
|
|
2434
|
-
return
|
|
2434
|
+
return void 0;
|
|
2435
2435
|
}
|
|
2436
2436
|
strParts.push(part);
|
|
2437
2437
|
}
|
|
@@ -2474,7 +2474,7 @@ function parse$5(innerSchema, input, context, coerce = false) {
|
|
|
2474
2474
|
schemaPath: `${context.schemaPath}/elements`,
|
|
2475
2475
|
message: `Error at ${context.instancePath}. Invalid JSON.`
|
|
2476
2476
|
});
|
|
2477
|
-
return
|
|
2477
|
+
return void 0;
|
|
2478
2478
|
}
|
|
2479
2479
|
}
|
|
2480
2480
|
if (!Array.isArray(parsedInput)) {
|
|
@@ -2483,7 +2483,7 @@ function parse$5(innerSchema, input, context, coerce = false) {
|
|
|
2483
2483
|
schemaPath: `${context.schemaPath}/elements`,
|
|
2484
2484
|
message: `Error at ${context.instancePath}. Expected array. Got ${typeof input}.`
|
|
2485
2485
|
});
|
|
2486
|
-
return
|
|
2486
|
+
return void 0;
|
|
2487
2487
|
}
|
|
2488
2488
|
const result = [];
|
|
2489
2489
|
for (let i = 0; i < parsedInput.length; i++) {
|
|
@@ -2511,7 +2511,7 @@ function parse$5(innerSchema, input, context, coerce = false) {
|
|
|
2511
2511
|
}
|
|
2512
2512
|
}
|
|
2513
2513
|
if (context.errors.length) {
|
|
2514
|
-
return
|
|
2514
|
+
return void 0;
|
|
2515
2515
|
}
|
|
2516
2516
|
return result;
|
|
2517
2517
|
}
|
|
@@ -2543,7 +2543,7 @@ function boolean(opts = {}) {
|
|
|
2543
2543
|
schemaPath: context.schemaPath,
|
|
2544
2544
|
message: `Error at ${context.instancePath}. Unable to coerce ${input} to boolean.`
|
|
2545
2545
|
});
|
|
2546
|
-
return
|
|
2546
|
+
return void 0;
|
|
2547
2547
|
}
|
|
2548
2548
|
};
|
|
2549
2549
|
const result = {
|
|
@@ -2578,14 +2578,14 @@ function parse$4(input, data) {
|
|
|
2578
2578
|
schemaPath: `${data.schemaPath}/type`,
|
|
2579
2579
|
message: `Error at ${data.instancePath}. Expected boolean. Got ${typeof input}.`
|
|
2580
2580
|
});
|
|
2581
|
-
return
|
|
2581
|
+
return void 0;
|
|
2582
2582
|
}
|
|
2583
2583
|
data.errors.push({
|
|
2584
2584
|
instancePath: data.instancePath,
|
|
2585
2585
|
schemaPath: `${data.schemaPath}/type`,
|
|
2586
2586
|
message: `Error at ${data.instancePath}. Expected boolean. Got ${typeof input}.`
|
|
2587
2587
|
});
|
|
2588
|
-
return
|
|
2588
|
+
return void 0;
|
|
2589
2589
|
}
|
|
2590
2590
|
function serialize$2(input) {
|
|
2591
2591
|
return `${input}`;
|
|
@@ -2619,7 +2619,7 @@ function discriminator(propA, propB, propC) {
|
|
|
2619
2619
|
context.errors.push(
|
|
2620
2620
|
discriminatorMappingError(discriminatorVal, context)
|
|
2621
2621
|
);
|
|
2622
|
-
return
|
|
2622
|
+
return void 0;
|
|
2623
2623
|
}
|
|
2624
2624
|
const result2 = targetSchema[VALIDATOR_KEY].serialize(input, {
|
|
2625
2625
|
instancePath: context.instancePath,
|
|
@@ -2677,7 +2677,7 @@ function parse$3(discriminator2, mapping, input, context, coerce = false) {
|
|
|
2677
2677
|
instancePath: context.instancePath,
|
|
2678
2678
|
schemaPath: context.schemaPath
|
|
2679
2679
|
});
|
|
2680
|
-
return
|
|
2680
|
+
return void 0;
|
|
2681
2681
|
}
|
|
2682
2682
|
}
|
|
2683
2683
|
if (!isObject(parsedInput)) {
|
|
@@ -2686,7 +2686,7 @@ function parse$3(discriminator2, mapping, input, context, coerce = false) {
|
|
|
2686
2686
|
schemaPath: `${context.schemaPath}/discriminator`,
|
|
2687
2687
|
message: `Error at ${context.instancePath}. Expected object. Got ${typeof parsedInput}.`
|
|
2688
2688
|
});
|
|
2689
|
-
return
|
|
2689
|
+
return void 0;
|
|
2690
2690
|
}
|
|
2691
2691
|
if (!(discriminator2 in parsedInput)) {
|
|
2692
2692
|
context.errors.push({
|
|
@@ -2694,7 +2694,7 @@ function parse$3(discriminator2, mapping, input, context, coerce = false) {
|
|
|
2694
2694
|
schemaPath: `${context.schemaPath}/discriminator`,
|
|
2695
2695
|
message: `Error at ${context.instancePath}/${discriminator2}. Discriminator field "${discriminator2}" cannot be undefined`
|
|
2696
2696
|
});
|
|
2697
|
-
return
|
|
2697
|
+
return void 0;
|
|
2698
2698
|
}
|
|
2699
2699
|
const acceptedDiscriminatorVals = Object.keys(mapping);
|
|
2700
2700
|
const discriminatorVal = parsedInput[discriminator2];
|
|
@@ -2706,11 +2706,11 @@ function parse$3(discriminator2, mapping, input, context, coerce = false) {
|
|
|
2706
2706
|
", "
|
|
2707
2707
|
)}]`
|
|
2708
2708
|
});
|
|
2709
|
-
return
|
|
2709
|
+
return void 0;
|
|
2710
2710
|
}
|
|
2711
2711
|
const targetSchema = mapping[parsedInput[discriminator2]];
|
|
2712
2712
|
if (!targetSchema) {
|
|
2713
|
-
return
|
|
2713
|
+
return void 0;
|
|
2714
2714
|
}
|
|
2715
2715
|
if (coerce) {
|
|
2716
2716
|
const result2 = targetSchema[VALIDATOR_KEY].coerce(parsedInput, {
|
|
@@ -2772,7 +2772,7 @@ function enumerator(paramA, paramB) {
|
|
|
2772
2772
|
", "
|
|
2773
2773
|
)}]`
|
|
2774
2774
|
});
|
|
2775
|
-
return
|
|
2775
|
+
return void 0;
|
|
2776
2776
|
};
|
|
2777
2777
|
const validator = {
|
|
2778
2778
|
output: paramA[0] ?? "",
|
|
@@ -2788,7 +2788,7 @@ function enumerator(paramA, paramB) {
|
|
|
2788
2788
|
", "
|
|
2789
2789
|
)}]`
|
|
2790
2790
|
});
|
|
2791
|
-
return
|
|
2791
|
+
return void 0;
|
|
2792
2792
|
},
|
|
2793
2793
|
validate: isType,
|
|
2794
2794
|
serialize(input, context) {
|
|
@@ -2868,31 +2868,31 @@ function nullable(schema, opts = {}) {
|
|
|
2868
2868
|
}
|
|
2869
2869
|
function optional(input, opts = {}) {
|
|
2870
2870
|
const isType = (val) => {
|
|
2871
|
-
if (val ===
|
|
2871
|
+
if (val === void 0) {
|
|
2872
2872
|
return true;
|
|
2873
2873
|
}
|
|
2874
2874
|
return input[VALIDATOR_KEY].validate(val);
|
|
2875
2875
|
};
|
|
2876
2876
|
const parse = (val, context) => {
|
|
2877
2877
|
if (typeof val === "undefined") {
|
|
2878
|
-
return
|
|
2878
|
+
return void 0;
|
|
2879
2879
|
}
|
|
2880
2880
|
if (context.instancePath.length === 0 && val === "undefined") {
|
|
2881
|
-
return
|
|
2881
|
+
return void 0;
|
|
2882
2882
|
}
|
|
2883
2883
|
return input[VALIDATOR_KEY].parse(val, context);
|
|
2884
2884
|
};
|
|
2885
2885
|
const validator = {
|
|
2886
|
-
output:
|
|
2886
|
+
output: void 0,
|
|
2887
2887
|
optional: true,
|
|
2888
2888
|
validate: isType,
|
|
2889
2889
|
parse,
|
|
2890
2890
|
coerce: (val, data) => {
|
|
2891
2891
|
if (typeof val === "undefined") {
|
|
2892
|
-
return
|
|
2892
|
+
return void 0;
|
|
2893
2893
|
}
|
|
2894
2894
|
if (val === "undefined") {
|
|
2895
|
-
return
|
|
2895
|
+
return void 0;
|
|
2896
2896
|
}
|
|
2897
2897
|
return input[VALIDATOR_KEY].coerce(val, data);
|
|
2898
2898
|
},
|
|
@@ -2949,7 +2949,7 @@ function coerceNumber(input, options) {
|
|
|
2949
2949
|
schemaPath: `${options.schemaPath}/type`,
|
|
2950
2950
|
message: `Error at ${options.instancePath}. Unable to coerce ${typeof input} into a number`
|
|
2951
2951
|
});
|
|
2952
|
-
return
|
|
2952
|
+
return void 0;
|
|
2953
2953
|
}
|
|
2954
2954
|
return decodeNumber(decodedInput, options);
|
|
2955
2955
|
}
|
|
@@ -3074,7 +3074,7 @@ function int64(opts = {}) {
|
|
|
3074
3074
|
schemaPath: `${context.schemaPath}/type`,
|
|
3075
3075
|
instancePath: context.instancePath
|
|
3076
3076
|
});
|
|
3077
|
-
return
|
|
3077
|
+
return void 0;
|
|
3078
3078
|
}
|
|
3079
3079
|
}
|
|
3080
3080
|
if (isType(input)) {
|
|
@@ -3085,7 +3085,7 @@ function int64(opts = {}) {
|
|
|
3085
3085
|
schemaPath: `${context.schemaPath}/type`,
|
|
3086
3086
|
instancePath: context.instancePath
|
|
3087
3087
|
});
|
|
3088
|
-
return
|
|
3088
|
+
return void 0;
|
|
3089
3089
|
}
|
|
3090
3090
|
const validator = {
|
|
3091
3091
|
output: BigInt("0"),
|
|
@@ -3135,7 +3135,7 @@ function uint64(opts = {}) {
|
|
|
3135
3135
|
schemaPath: `${context.schemaPath}/type`,
|
|
3136
3136
|
instancePath: context.instancePath
|
|
3137
3137
|
});
|
|
3138
|
-
return
|
|
3138
|
+
return void 0;
|
|
3139
3139
|
}
|
|
3140
3140
|
}
|
|
3141
3141
|
if (isType(input)) {
|
|
@@ -3146,7 +3146,7 @@ function uint64(opts = {}) {
|
|
|
3146
3146
|
schemaPath: `${context.schemaPath}/type`,
|
|
3147
3147
|
instancePath: context.instancePath
|
|
3148
3148
|
});
|
|
3149
|
-
return
|
|
3149
|
+
return void 0;
|
|
3150
3150
|
}
|
|
3151
3151
|
const validator = {
|
|
3152
3152
|
output: BigInt("0"),
|
|
@@ -3191,7 +3191,7 @@ function decodeNumber(input, context) {
|
|
|
3191
3191
|
schemaPath: `${context.schemaPath}/type`,
|
|
3192
3192
|
message: `Error at ${context.instancePath}. Invalid number.`
|
|
3193
3193
|
});
|
|
3194
|
-
return
|
|
3194
|
+
return void 0;
|
|
3195
3195
|
}
|
|
3196
3196
|
return result;
|
|
3197
3197
|
}
|
|
@@ -3203,7 +3203,7 @@ function decodeNumber(input, context) {
|
|
|
3203
3203
|
schemaPath: `${context.schemaPath}/type`,
|
|
3204
3204
|
message: `Error at ${context.instancePath}. Invalid number.`
|
|
3205
3205
|
});
|
|
3206
|
-
return
|
|
3206
|
+
return void 0;
|
|
3207
3207
|
}
|
|
3208
3208
|
function numberScalarType(type, opts, numTypeMatcher) {
|
|
3209
3209
|
const validate = (input) => {
|
|
@@ -3216,7 +3216,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
|
|
|
3216
3216
|
const parse = (input, context) => {
|
|
3217
3217
|
const result2 = decodeNumber(input, context);
|
|
3218
3218
|
if (context.errors.length) {
|
|
3219
|
-
return
|
|
3219
|
+
return void 0;
|
|
3220
3220
|
}
|
|
3221
3221
|
if (typeof result2 !== "number") {
|
|
3222
3222
|
context?.errors.push({
|
|
@@ -3224,7 +3224,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
|
|
|
3224
3224
|
schemaPath: `${context.schemaPath}/type`,
|
|
3225
3225
|
message: `Error at ${context.instancePath}. Invalid number.`
|
|
3226
3226
|
});
|
|
3227
|
-
return
|
|
3227
|
+
return void 0;
|
|
3228
3228
|
}
|
|
3229
3229
|
const matchResult = numTypeMatcher(result2);
|
|
3230
3230
|
if (matchResult.success) {
|
|
@@ -3235,7 +3235,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
|
|
|
3235
3235
|
schemaPath: `${context.schemaPath}/type`,
|
|
3236
3236
|
message: `Error at ${context.instancePath}. ${matchResult.message}`
|
|
3237
3237
|
});
|
|
3238
|
-
return
|
|
3238
|
+
return void 0;
|
|
3239
3239
|
};
|
|
3240
3240
|
const validator = {
|
|
3241
3241
|
output: 0,
|
|
@@ -3250,7 +3250,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
|
|
|
3250
3250
|
schemaPath: `${options.schemaPath}/type`,
|
|
3251
3251
|
message: `Error at ${options.instancePath}. Unable to coerce ${typeof input} to ${type}.`
|
|
3252
3252
|
});
|
|
3253
|
-
return
|
|
3253
|
+
return void 0;
|
|
3254
3254
|
}
|
|
3255
3255
|
const matchResult = numTypeMatcher(result2);
|
|
3256
3256
|
if (matchResult.success) {
|
|
@@ -3261,7 +3261,7 @@ function numberScalarType(type, opts, numTypeMatcher) {
|
|
|
3261
3261
|
schemaPath: `${options.schemaPath}/type`,
|
|
3262
3262
|
message: `Error at ${options.instancePath}. ${matchResult.message}`
|
|
3263
3263
|
});
|
|
3264
|
-
return
|
|
3264
|
+
return void 0;
|
|
3265
3265
|
}
|
|
3266
3266
|
};
|
|
3267
3267
|
const result = {
|
|
@@ -3355,7 +3355,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3355
3355
|
schemaPath: `${context.schemaPath}/properties`,
|
|
3356
3356
|
message: `Error at ${context.instancePath}. Invalid JSON.`
|
|
3357
3357
|
});
|
|
3358
|
-
return
|
|
3358
|
+
return void 0;
|
|
3359
3359
|
}
|
|
3360
3360
|
}
|
|
3361
3361
|
if (!isObject(parsedInput)) {
|
|
@@ -3364,7 +3364,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3364
3364
|
schemaPath: `${context.schemaPath}/properties`,
|
|
3365
3365
|
message: `Error at ${context.instancePath}. Expected object`
|
|
3366
3366
|
});
|
|
3367
|
-
return
|
|
3367
|
+
return void 0;
|
|
3368
3368
|
}
|
|
3369
3369
|
const result = {};
|
|
3370
3370
|
const optionalProps = schema.optionalProperties ?? {};
|
|
@@ -3383,7 +3383,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3383
3383
|
}
|
|
3384
3384
|
}
|
|
3385
3385
|
if (context.errors.length) {
|
|
3386
|
-
return
|
|
3386
|
+
return void 0;
|
|
3387
3387
|
}
|
|
3388
3388
|
if (context.discriminatorKey) {
|
|
3389
3389
|
result[context.discriminatorKey] = context.discriminatorValue;
|
|
@@ -3401,7 +3401,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3401
3401
|
exitOnFirstError: context.exitOnFirstError
|
|
3402
3402
|
});
|
|
3403
3403
|
if (context.errors.length && context.exitOnFirstError) {
|
|
3404
|
-
return
|
|
3404
|
+
return void 0;
|
|
3405
3405
|
}
|
|
3406
3406
|
continue;
|
|
3407
3407
|
}
|
|
@@ -3414,13 +3414,13 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3414
3414
|
exitOnFirstError: context.exitOnFirstError
|
|
3415
3415
|
});
|
|
3416
3416
|
if (context.errors.length && context.exitOnFirstError) {
|
|
3417
|
-
return
|
|
3417
|
+
return void 0;
|
|
3418
3418
|
}
|
|
3419
3419
|
}
|
|
3420
3420
|
for (const key of optionalKeys) {
|
|
3421
3421
|
const val = parsedInput[key];
|
|
3422
3422
|
const prop = optionalProps[key];
|
|
3423
|
-
if (val ===
|
|
3423
|
+
if (val === void 0) {
|
|
3424
3424
|
continue;
|
|
3425
3425
|
}
|
|
3426
3426
|
if (coerce) {
|
|
@@ -3433,7 +3433,7 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3433
3433
|
exitOnFirstError: context.exitOnFirstError
|
|
3434
3434
|
});
|
|
3435
3435
|
if (context.errors.length && context.exitOnFirstError) {
|
|
3436
|
-
return
|
|
3436
|
+
return void 0;
|
|
3437
3437
|
}
|
|
3438
3438
|
continue;
|
|
3439
3439
|
}
|
|
@@ -3447,12 +3447,12 @@ function decodeObjectSchema(schema, input, context, coerce = false) {
|
|
|
3447
3447
|
exitOnFirstError: context.exitOnFirstError
|
|
3448
3448
|
});
|
|
3449
3449
|
if (context.errors.length && context.exitOnFirstError) {
|
|
3450
|
-
return
|
|
3450
|
+
return void 0;
|
|
3451
3451
|
}
|
|
3452
3452
|
}
|
|
3453
3453
|
}
|
|
3454
3454
|
if (context.errors.length) {
|
|
3455
|
-
return
|
|
3455
|
+
return void 0;
|
|
3456
3456
|
}
|
|
3457
3457
|
return result;
|
|
3458
3458
|
}
|
|
@@ -3460,7 +3460,7 @@ function validateObjectSchema(schema, input) {
|
|
|
3460
3460
|
if (!isObject(input)) {
|
|
3461
3461
|
return false;
|
|
3462
3462
|
}
|
|
3463
|
-
const allowedKeys = schema.strict ? [] :
|
|
3463
|
+
const allowedKeys = schema.strict ? [] : void 0;
|
|
3464
3464
|
for (const key of Object.keys(schema.properties)) {
|
|
3465
3465
|
const propSchema = schema.properties[key];
|
|
3466
3466
|
const isValid = propSchema[VALIDATOR_KEY].validate(input[key]);
|
|
@@ -3787,7 +3787,7 @@ function decode(input, context) {
|
|
|
3787
3787
|
schemaPath: `${context.schemaPath}/type`,
|
|
3788
3788
|
message: `Error at ${context.instancePath}. Expected 'string' got ${typeof input}.`
|
|
3789
3789
|
});
|
|
3790
|
-
return
|
|
3790
|
+
return void 0;
|
|
3791
3791
|
}
|
|
3792
3792
|
function coerce$2(input, context) {
|
|
3793
3793
|
return decode(input, context);
|
|
@@ -3852,7 +3852,7 @@ function record(schema, opts = {}) {
|
|
|
3852
3852
|
schemaPath: context.schemaPath,
|
|
3853
3853
|
message: "Max depth reached"
|
|
3854
3854
|
});
|
|
3855
|
-
return
|
|
3855
|
+
return void 0;
|
|
3856
3856
|
}
|
|
3857
3857
|
let result2 = "{";
|
|
3858
3858
|
const keys = Object.keys(input);
|
|
@@ -3895,7 +3895,7 @@ function parse$2(schema, input, data, coerce = false) {
|
|
|
3895
3895
|
schemaPath: data.schemaPath,
|
|
3896
3896
|
message: "Max depth reached"
|
|
3897
3897
|
});
|
|
3898
|
-
return
|
|
3898
|
+
return void 0;
|
|
3899
3899
|
}
|
|
3900
3900
|
let parsedInput = input;
|
|
3901
3901
|
if (data.instancePath.length === 0 && typeof input === "string" && input.length > 0) {
|
|
@@ -3908,7 +3908,7 @@ function parse$2(schema, input, data, coerce = false) {
|
|
|
3908
3908
|
schemaPath: data.schemaPath,
|
|
3909
3909
|
data: err
|
|
3910
3910
|
});
|
|
3911
|
-
return
|
|
3911
|
+
return void 0;
|
|
3912
3912
|
}
|
|
3913
3913
|
}
|
|
3914
3914
|
if (!isObject(parsedInput)) {
|
|
@@ -3917,7 +3917,7 @@ function parse$2(schema, input, data, coerce = false) {
|
|
|
3917
3917
|
schemaPath: `${data.schemaPath}/values`,
|
|
3918
3918
|
message: `Error at ${data.instancePath} Expected object`
|
|
3919
3919
|
});
|
|
3920
|
-
return
|
|
3920
|
+
return void 0;
|
|
3921
3921
|
}
|
|
3922
3922
|
const result = {};
|
|
3923
3923
|
for (const key of Object.keys(parsedInput)) {
|
|
@@ -3943,7 +3943,7 @@ function parse$2(schema, input, data, coerce = false) {
|
|
|
3943
3943
|
}
|
|
3944
3944
|
}
|
|
3945
3945
|
if (data.errors.length) {
|
|
3946
|
-
return
|
|
3946
|
+
return void 0;
|
|
3947
3947
|
}
|
|
3948
3948
|
return result;
|
|
3949
3949
|
}
|
|
@@ -3970,7 +3970,7 @@ function recursive(propA, propB) {
|
|
|
3970
3970
|
instancePath: context.instancePath,
|
|
3971
3971
|
schemaPath: context.schemaPath
|
|
3972
3972
|
});
|
|
3973
|
-
return
|
|
3973
|
+
return void 0;
|
|
3974
3974
|
}
|
|
3975
3975
|
if (recursiveFns[id]) {
|
|
3976
3976
|
return recursiveFns[id].parse(input, {
|
|
@@ -3986,7 +3986,7 @@ function recursive(propA, propB) {
|
|
|
3986
3986
|
instancePath: context.instancePath,
|
|
3987
3987
|
schemaPath: context.schemaPath
|
|
3988
3988
|
});
|
|
3989
|
-
return
|
|
3989
|
+
return void 0;
|
|
3990
3990
|
}
|
|
3991
3991
|
if (recursiveFns[id]) {
|
|
3992
3992
|
return recursiveFns[id].serialize(input, context);
|
|
@@ -4006,7 +4006,7 @@ function recursive(propA, propB) {
|
|
|
4006
4006
|
instancePath: context.instancePath,
|
|
4007
4007
|
schemaPath: context.schemaPath
|
|
4008
4008
|
});
|
|
4009
|
-
return
|
|
4009
|
+
return void 0;
|
|
4010
4010
|
}
|
|
4011
4011
|
if (recursiveFns[id]) {
|
|
4012
4012
|
return recursiveFns[id].coerce(input, context);
|
|
@@ -4090,7 +4090,7 @@ function parse$1(input, data) {
|
|
|
4090
4090
|
schemaPath: data.schemaPath,
|
|
4091
4091
|
data: err
|
|
4092
4092
|
});
|
|
4093
|
-
return
|
|
4093
|
+
return void 0;
|
|
4094
4094
|
}
|
|
4095
4095
|
}
|
|
4096
4096
|
function coerce$1(input, options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrirpc/schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.75.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@standard-schema/spec": "1.0.0",
|
|
26
26
|
"scule": "^1.3.0",
|
|
27
27
|
"uncrypto": "^0.1.3",
|
|
28
|
-
"@arrirpc/type-defs": "0.
|
|
28
|
+
"@arrirpc/type-defs": "0.75.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"ajv": "^8.17.1",
|