@lucania/schema 3.1.0 → 3.1.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/build/index.d.ts +1 -0
- package/build/index.js +25 -0
- package/package.json +2 -2
package/build/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./schema/NumberSchema";
|
|
|
14
14
|
export * from "./schema/ObjectSchema";
|
|
15
15
|
export * from "./schema/OrSetSchema";
|
|
16
16
|
export * from "./schema/StringSchema";
|
|
17
|
+
export * from "./schema/TupleSchema";
|
|
17
18
|
export * from "./typing/extended";
|
|
18
19
|
export * from "./typing/toolbox";
|
|
19
20
|
export { Schema as $ } from "./builder";
|
package/build/index.js
CHANGED
|
@@ -923,6 +923,30 @@
|
|
|
923
923
|
Schema.Values = Values;
|
|
924
924
|
})(exports.Schema || (exports.Schema = {}));
|
|
925
925
|
|
|
926
|
+
class TupleSchema extends BaseSchema {
|
|
927
|
+
subschema;
|
|
928
|
+
constructor(subschema, required, defaultValue, additionalValidationPasses) {
|
|
929
|
+
super(required, defaultValue, additionalValidationPasses);
|
|
930
|
+
this.subschema = subschema;
|
|
931
|
+
}
|
|
932
|
+
get type() { return "Tuple"; }
|
|
933
|
+
_validate(source, options, pass) {
|
|
934
|
+
return source;
|
|
935
|
+
}
|
|
936
|
+
convert(value, pass) {
|
|
937
|
+
return this.subschema.map((schema, i) => schema.validate(value[i]));
|
|
938
|
+
}
|
|
939
|
+
clone() {
|
|
940
|
+
return new TupleSchema(this.subschema, this._required, this._default, this._additionalValidationPasses);
|
|
941
|
+
}
|
|
942
|
+
getJsonSchema() {
|
|
943
|
+
return {
|
|
944
|
+
type: "Tuple",
|
|
945
|
+
description: this._getJsonSchemaDescription(),
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
|
|
926
950
|
exports.$ = exports.Schema;
|
|
927
951
|
exports.AnySchema = AnySchema;
|
|
928
952
|
exports.ArraySchema = ArraySchema;
|
|
@@ -937,6 +961,7 @@
|
|
|
937
961
|
exports.ObjectSchema = ObjectSchema;
|
|
938
962
|
exports.OrSetSchema = OrSetSchema;
|
|
939
963
|
exports.StringSchema = StringSchema;
|
|
964
|
+
exports.TupleSchema = TupleSchema;
|
|
940
965
|
exports.ValidationError = ValidationError;
|
|
941
966
|
exports.ValidationPass = ValidationPass;
|
|
942
967
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucania/schema",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "A schema module for compile-time and runtime type checking.",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
"tslib": "^2.6.3",
|
|
38
38
|
"typescript": "^5.4.5"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|