umt 3.0.0 → 3.2.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/module/Date/getDay.d.ts +1 -2
- package/module/Object/keyBy.d.ts +3 -4
- package/module/Validate/any/core.d.ts +2 -1
- package/module/Validate/any/core.js +3 -2
- package/module/Validate/any/core.js.map +1 -1
- package/module/Validate/array/arrayOf.d.ts +3 -3
- package/module/Validate/array/arrayOf.js +3 -1
- package/module/Validate/array/arrayOf.js.map +1 -1
- package/module/Validate/bigint/core.d.ts +2 -1
- package/module/Validate/bigint/core.js +3 -1
- package/module/Validate/bigint/core.js.map +1 -1
- package/module/Validate/boolean/core.d.ts +2 -1
- package/module/Validate/boolean/core.js +3 -1
- package/module/Validate/boolean/core.js.map +1 -1
- package/module/Validate/date/core.d.ts +2 -1
- package/module/Validate/date/core.js +3 -1
- package/module/Validate/date/core.js.map +1 -1
- package/module/Validate/file/core.d.ts +2 -1
- package/module/Validate/file/core.js +3 -1
- package/module/Validate/file/core.js.map +1 -1
- package/module/Validate/function/core.d.ts +11 -11
- package/module/Validate/function/core.js +2 -1
- package/module/Validate/function/core.js.map +1 -1
- package/module/Validate/index.d.ts +1 -0
- package/module/Validate/index.js +1 -0
- package/module/Validate/index.js.map +1 -1
- package/module/Validate/instanceof/core.d.ts +3 -3
- package/module/Validate/instanceof/core.js +3 -1
- package/module/Validate/instanceof/core.js.map +1 -1
- package/module/Validate/map/core.d.ts +3 -3
- package/module/Validate/map/core.js +3 -1
- package/module/Validate/map/core.js.map +1 -1
- package/module/Validate/never/core.d.ts +2 -1
- package/module/Validate/never/core.js +7 -8
- package/module/Validate/never/core.js.map +1 -1
- package/module/Validate/number/core.d.ts +3 -2
- package/module/Validate/number/core.js +3 -1
- package/module/Validate/number/core.js.map +1 -1
- package/module/Validate/object/core.d.ts +2 -1
- package/module/Validate/object/core.js +2 -1
- package/module/Validate/object/core.js.map +1 -1
- package/module/Validate/object/intersection.d.ts +5 -5
- package/module/Validate/object/intersection.js +3 -1
- package/module/Validate/object/intersection.js.map +1 -1
- package/module/Validate/object/nullable.d.ts +3 -3
- package/module/Validate/object/nullable.js +2 -1
- package/module/Validate/object/nullable.js.map +1 -1
- package/module/Validate/object/optional.d.ts +3 -3
- package/module/Validate/object/optional.js +2 -1
- package/module/Validate/object/optional.js.map +1 -1
- package/module/Validate/object/partial.d.ts +1 -2
- package/module/Validate/object/required.d.ts +2 -3
- package/module/Validate/object/union.d.ts +3 -3
- package/module/Validate/object/union.js +3 -1
- package/module/Validate/object/union.js.map +1 -1
- package/module/Validate/set/core.d.ts +3 -3
- package/module/Validate/set/core.js +3 -1
- package/module/Validate/set/core.js.map +1 -1
- package/module/Validate/standardSchema.d.ts +93 -0
- package/module/Validate/standardSchema.js +58 -0
- package/module/Validate/standardSchema.js.map +1 -0
- package/module/Validate/string/core.d.ts +3 -2
- package/module/Validate/string/core.js +5 -1
- package/module/Validate/string/core.js.map +1 -1
- package/module/Validate/templateLiteral/core.d.ts +7 -7
- package/module/Validate/templateLiteral/core.js +3 -1
- package/module/Validate/templateLiteral/core.js.map +1 -1
- package/module/Validate/unknown/core.d.ts +2 -1
- package/module/Validate/unknown/core.js +3 -1
- package/module/Validate/unknown/core.js.map +1 -1
- package/module/es5/Date/getDay.d.ts +1 -2
- package/module/es5/Object/keyBy.d.ts +3 -4
- package/module/es5/Validate/any/core.d.ts +2 -1
- package/module/es5/Validate/any/core.js +3 -2
- package/module/es5/Validate/array/arrayOf.d.ts +3 -3
- package/module/es5/Validate/array/arrayOf.js +3 -1
- package/module/es5/Validate/bigint/core.d.ts +2 -1
- package/module/es5/Validate/bigint/core.js +4 -4
- package/module/es5/Validate/boolean/core.d.ts +2 -1
- package/module/es5/Validate/boolean/core.js +3 -1
- package/module/es5/Validate/date/core.d.ts +2 -1
- package/module/es5/Validate/date/core.js +3 -1
- package/module/es5/Validate/file/core.d.ts +2 -1
- package/module/es5/Validate/file/core.js +3 -1
- package/module/es5/Validate/function/core.d.ts +11 -11
- package/module/es5/Validate/function/core.js +3 -6
- package/module/es5/Validate/index.d.ts +1 -0
- package/module/es5/Validate/index.js +11 -0
- package/module/es5/Validate/instanceof/core.d.ts +3 -3
- package/module/es5/Validate/instanceof/core.js +3 -1
- package/module/es5/Validate/map/core.d.ts +3 -3
- package/module/es5/Validate/map/core.js +4 -4
- package/module/es5/Validate/never/core.d.ts +2 -1
- package/module/es5/Validate/never/core.js +3 -2
- package/module/es5/Validate/number/core.d.ts +3 -2
- package/module/es5/Validate/number/core.js +3 -1
- package/module/es5/Validate/object/core.d.ts +2 -1
- package/module/es5/Validate/object/core.js +2 -1
- package/module/es5/Validate/object/intersection.d.ts +5 -5
- package/module/es5/Validate/object/intersection.js +3 -1
- package/module/es5/Validate/object/nullable.d.ts +3 -3
- package/module/es5/Validate/object/nullable.js +2 -1
- package/module/es5/Validate/object/optional.d.ts +3 -3
- package/module/es5/Validate/object/optional.js +2 -1
- package/module/es5/Validate/object/partial.d.ts +1 -2
- package/module/es5/Validate/object/required.d.ts +2 -3
- package/module/es5/Validate/object/union.d.ts +3 -3
- package/module/es5/Validate/object/union.js +3 -1
- package/module/es5/Validate/set/core.d.ts +3 -3
- package/module/es5/Validate/set/core.js +4 -4
- package/module/es5/Validate/standardSchema.d.ts +93 -0
- package/module/es5/Validate/standardSchema.js +91 -0
- package/module/es5/Validate/string/core.d.ts +3 -2
- package/module/es5/Validate/string/core.js +3 -1
- package/module/es5/Validate/templateLiteral/core.d.ts +7 -7
- package/module/es5/Validate/templateLiteral/core.js +7 -6
- package/module/es5/Validate/unknown/core.d.ts +2 -1
- package/module/es5/Validate/unknown/core.js +3 -1
- package/module/es5/types/array/chunk.d.ts +1 -2
- package/module/es5/types/array/zip.d.ts +4 -2
- package/module/es5/types/logic/binary1bitNor.d.ts +1 -2
- package/module/es5/types/logic/binaryFullAdder.d.ts +1 -2
- package/module/es5/types/math/divide.d.ts +1 -2
- package/module/es5/types/math/multiply.d.ts +1 -2
- package/module/es5/types/object/pickDeep.d.ts +3 -4
- package/module/types/array/chunk.d.ts +1 -2
- package/module/types/array/zip.d.ts +4 -2
- package/module/types/logic/binary1bitNor.d.ts +1 -2
- package/module/types/logic/binaryFullAdder.d.ts +1 -2
- package/module/types/math/divide.d.ts +1 -2
- package/module/types/math/multiply.d.ts +1 -2
- package/module/types/object/pickDeep.d.ts +3 -4
- package/package.json +9 -9
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.any = void 0;
|
|
7
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
7
8
|
/**
|
|
8
9
|
* Any validation core module
|
|
9
10
|
* Provides a validator that accepts any value, useful when a position in a
|
|
@@ -25,12 +26,12 @@ var anyValidator = function anyValidator(_value) {
|
|
|
25
26
|
type: "any"
|
|
26
27
|
};
|
|
27
28
|
};
|
|
29
|
+
var standardAnyValidator = (0, _standardSchema.attachStandard)(anyValidator);
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* Creates a validator that accepts any value
|
|
31
33
|
* @returns {Function} - Validator that always succeeds
|
|
32
34
|
*/
|
|
33
|
-
// biome-ignore lint/suspicious/noExplicitAny: any() must accept and infer any value
|
|
34
35
|
var any = exports.any = function any() {
|
|
35
|
-
return
|
|
36
|
+
return standardAnyValidator;
|
|
36
37
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
1
2
|
import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
2
|
-
type
|
|
3
|
+
export type ArrayOfExtractValidatedType<V> = V extends (value: never) => {
|
|
3
4
|
type: infer T;
|
|
4
5
|
} ? ValidateType<T> : never;
|
|
5
6
|
/**
|
|
@@ -13,5 +14,4 @@ export declare const arrayOf: <V extends (value: never) => {
|
|
|
13
14
|
type: unknown;
|
|
14
15
|
message: string;
|
|
15
16
|
validate: boolean;
|
|
16
|
-
}>(validator: V, message?: string) => (values:
|
|
17
|
-
export {};
|
|
17
|
+
}>(validator: V, message?: string) => ((values: ArrayOfExtractValidatedType<V>[]) => ValidateCoreReturnType<ArrayOfExtractValidatedType<V>[]>) & StandardSchemaV1<ArrayOfExtractValidatedType<V>[], ArrayOfExtractValidatedType<V>[]>;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.arrayOf = void 0;
|
|
7
7
|
var _isArray = require("../../Validate/isArray");
|
|
8
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
8
9
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
9
10
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
11
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -22,7 +23,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
22
23
|
* @returns {Function} - Validator function for arrays whose elements satisfy the given validator
|
|
23
24
|
*/
|
|
24
25
|
var arrayOf = exports.arrayOf = function arrayOf(validator, message) {
|
|
25
|
-
|
|
26
|
+
var arrayValidator = function arrayValidator(values) {
|
|
26
27
|
if (!(0, _isArray.isArray)(values)) {
|
|
27
28
|
return {
|
|
28
29
|
validate: false,
|
|
@@ -55,4 +56,5 @@ var arrayOf = exports.arrayOf = function arrayOf(validator, message) {
|
|
|
55
56
|
type: values
|
|
56
57
|
};
|
|
57
58
|
};
|
|
59
|
+
return (0, _standardSchema.attachStandard)(arrayValidator);
|
|
58
60
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* BigInt validation core module
|
|
3
3
|
* Provides the base validation functionality for bigint values
|
|
4
4
|
*/
|
|
5
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
5
6
|
import type { ValidateReturnType } from "../../Validate/type";
|
|
6
7
|
/**
|
|
7
8
|
* Return type produced by a `bigint` validator. Structurally compatible with
|
|
@@ -21,4 +22,4 @@ export interface BigIntReturnType {
|
|
|
21
22
|
* @param {string} [message] - Custom error message for type validation
|
|
22
23
|
* @returns {Function} - Validator function that checks if the value is a bigint and applies validation rules
|
|
23
24
|
*/
|
|
24
|
-
export declare const bigint: <T extends ValidateReturnType<bigint>[]>(option?: T, message?: string) => (value: bigint) => BigIntReturnType
|
|
25
|
+
export declare const bigint: <T extends ValidateReturnType<bigint>[]>(option?: T, message?: string) => ((value: bigint) => BigIntReturnType) & StandardSchemaV1<bigint, bigint>;
|
|
@@ -4,14 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bigint = void 0;
|
|
7
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
7
8
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
8
9
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
10
|
-
/**
|
|
10
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /**
|
|
11
11
|
* BigInt validation core module
|
|
12
12
|
* Provides the base validation functionality for bigint values
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
14
|
/**
|
|
16
15
|
* Return type produced by a `bigint` validator. Structurally compatible with
|
|
17
16
|
* `ValidateCoreReturnType<bigint>`, but exposes the literal `"bigint"` tag
|
|
@@ -29,7 +28,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
29
28
|
var bigint = exports.bigint = function bigint() {
|
|
30
29
|
var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
31
30
|
var message = arguments.length > 1 ? arguments[1] : undefined;
|
|
32
|
-
|
|
31
|
+
var validator = function validator(value) {
|
|
33
32
|
if (typeof value !== "bigint") {
|
|
34
33
|
return {
|
|
35
34
|
validate: false,
|
|
@@ -62,4 +61,5 @@ var bigint = exports.bigint = function bigint() {
|
|
|
62
61
|
type: "bigint"
|
|
63
62
|
};
|
|
64
63
|
};
|
|
64
|
+
return (0, _standardSchema.attachStandard)(validator);
|
|
65
65
|
};
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Boolean validation core module
|
|
3
3
|
* Provides the base validation functionality for boolean values
|
|
4
4
|
*/
|
|
5
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
5
6
|
import type { ValidateCoreReturnType } from "../../Validate/type";
|
|
6
7
|
/**
|
|
7
8
|
* Creates a boolean validator
|
|
8
9
|
* @param {string} [message] - Custom error message for type validation
|
|
9
10
|
* @returns {Function} - Validator function that checks if the value is a boolean
|
|
10
11
|
*/
|
|
11
|
-
export declare const boolean: (message?: string) => (value: boolean) => ValidateCoreReturnType<boolean>;
|
|
12
|
+
export declare const boolean: (message?: string) => ((value: boolean) => ValidateCoreReturnType<boolean>) & StandardSchemaV1<boolean, boolean>;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["boolean"] = void 0;
|
|
7
7
|
var _core = require("../../Validate/core");
|
|
8
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
8
9
|
/**
|
|
9
10
|
* Boolean validation core module
|
|
10
11
|
* Provides the base validation functionality for boolean values
|
|
@@ -16,7 +17,8 @@ var _core = require("../../Validate/core");
|
|
|
16
17
|
* @returns {Function} - Validator function that checks if the value is a boolean
|
|
17
18
|
*/
|
|
18
19
|
var _boolean = exports["boolean"] = function _boolean(message) {
|
|
19
|
-
|
|
20
|
+
var validator = function validator(value) {
|
|
20
21
|
return (0, _core.core)("boolean")(value, [], message);
|
|
21
22
|
};
|
|
23
|
+
return (0, _standardSchema.attachStandard)(validator);
|
|
22
24
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Date validation core module
|
|
3
3
|
* Provides the base validation functionality for Date instances
|
|
4
4
|
*/
|
|
5
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
5
6
|
import type { ValidateCoreReturnType } from "../../Validate/type";
|
|
6
7
|
/**
|
|
7
8
|
* Creates a Date validator. The validator checks both that the value is an
|
|
@@ -11,4 +12,4 @@ import type { ValidateCoreReturnType } from "../../Validate/type";
|
|
|
11
12
|
* @param {string} [message] - Custom error message for type validation
|
|
12
13
|
* @returns {Function} - Validator function that checks if the value is a Date instance
|
|
13
14
|
*/
|
|
14
|
-
export declare const date: (message?: string) => (value: Date) => ValidateCoreReturnType<Date>;
|
|
15
|
+
export declare const date: (message?: string) => ((value: Date) => ValidateCoreReturnType<Date>) & StandardSchemaV1<Date, Date>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.date = void 0;
|
|
7
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
7
8
|
/**
|
|
8
9
|
* Date validation core module
|
|
9
10
|
* Provides the base validation functionality for Date instances
|
|
@@ -18,7 +19,7 @@ exports.date = void 0;
|
|
|
18
19
|
* @returns {Function} - Validator function that checks if the value is a Date instance
|
|
19
20
|
*/
|
|
20
21
|
var date = exports.date = function date(message) {
|
|
21
|
-
|
|
22
|
+
var validator = function validator(value) {
|
|
22
23
|
if (!(value instanceof Date) || Number.isNaN(value.getTime())) {
|
|
23
24
|
return {
|
|
24
25
|
validate: false,
|
|
@@ -32,4 +33,5 @@ var date = exports.date = function date(message) {
|
|
|
32
33
|
type: value
|
|
33
34
|
};
|
|
34
35
|
};
|
|
36
|
+
return (0, _standardSchema.attachStandard)(validator);
|
|
35
37
|
};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Provides validation for File / Blob instances. Falls back to `Blob` when
|
|
4
4
|
* the global `File` constructor is unavailable.
|
|
5
5
|
*/
|
|
6
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
6
7
|
import type { ValidateCoreReturnType } from "../../Validate/type";
|
|
7
8
|
/**
|
|
8
9
|
* Creates a validator that checks whether a value is a `File` (or `Blob` in
|
|
@@ -10,4 +11,4 @@ import type { ValidateCoreReturnType } from "../../Validate/type";
|
|
|
10
11
|
* @param {string} [message] - Custom error message for type validation
|
|
11
12
|
* @returns {Function} - Validator function for File / Blob instances
|
|
12
13
|
*/
|
|
13
|
-
export declare const file: (message?: string) => (value: File) => ValidateCoreReturnType<File>;
|
|
14
|
+
export declare const file: (message?: string) => ((value: File) => ValidateCoreReturnType<File>) & StandardSchemaV1<File, File>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.file = void 0;
|
|
7
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
7
8
|
/**
|
|
8
9
|
* File validation core module
|
|
9
10
|
* Provides validation for File / Blob instances. Falls back to `Blob` when
|
|
@@ -20,7 +21,7 @@ var hasBlobConstructor = typeof Blob !== "undefined";
|
|
|
20
21
|
* @returns {Function} - Validator function for File / Blob instances
|
|
21
22
|
*/
|
|
22
23
|
var file = exports.file = function file(message) {
|
|
23
|
-
|
|
24
|
+
var validator = function validator(value) {
|
|
24
25
|
var isFile = hasFileConstructor && value instanceof File;
|
|
25
26
|
var isBlob = hasBlobConstructor && value instanceof Blob;
|
|
26
27
|
if (!(isFile || isBlob)) {
|
|
@@ -36,4 +37,5 @@ var file = exports.file = function file(message) {
|
|
|
36
37
|
type: value
|
|
37
38
|
};
|
|
38
39
|
};
|
|
40
|
+
return (0, _standardSchema.attachStandard)(validator);
|
|
39
41
|
};
|
|
@@ -10,28 +10,29 @@
|
|
|
10
10
|
* `implement` property directly) to create a wrapped function that asserts
|
|
11
11
|
* the schema on every call.
|
|
12
12
|
*/
|
|
13
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
13
14
|
import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
14
|
-
type
|
|
15
|
-
type
|
|
15
|
+
export type FunctionAnyValidator = (value: any) => ValidateCoreReturnType<unknown>;
|
|
16
|
+
export type FunctionExtractValidatedType<V> = V extends (value: never) => {
|
|
16
17
|
type: infer T;
|
|
17
18
|
} ? ValidateType<T> : never;
|
|
18
|
-
type InferInputs<Inputs> = Inputs extends readonly
|
|
19
|
-
[K in keyof Inputs]:
|
|
19
|
+
export type InferInputs<Inputs> = Inputs extends readonly FunctionAnyValidator[] ? {
|
|
20
|
+
[K in keyof Inputs]: FunctionExtractValidatedType<Inputs[K]>;
|
|
20
21
|
} : any[];
|
|
21
|
-
type InferOutput<Output> = Output extends
|
|
22
|
+
export type InferOutput<Output> = Output extends FunctionAnyValidator ? FunctionExtractValidatedType<Output> : any;
|
|
22
23
|
/**
|
|
23
24
|
* Function schema definition. `input` describes positional parameters and
|
|
24
25
|
* `output` describes the return type. Both are optional; when omitted the
|
|
25
26
|
* validator only enforces that the value is callable.
|
|
26
27
|
*/
|
|
27
28
|
export interface FunctionSchema {
|
|
28
|
-
input?: readonly
|
|
29
|
-
output?:
|
|
29
|
+
input?: readonly FunctionAnyValidator[];
|
|
30
|
+
output?: FunctionAnyValidator;
|
|
30
31
|
}
|
|
31
|
-
type ExtractInput<S> = S extends {
|
|
32
|
+
export type ExtractInput<S> = S extends {
|
|
32
33
|
input: infer I;
|
|
33
34
|
} ? I : undefined;
|
|
34
|
-
type ExtractOutput<S> = S extends {
|
|
35
|
+
export type ExtractOutput<S> = S extends {
|
|
35
36
|
output: infer O;
|
|
36
37
|
} ? O : undefined;
|
|
37
38
|
/**
|
|
@@ -71,5 +72,4 @@ export interface FunctionValidator<Inputs, Output> {
|
|
|
71
72
|
* @param {string} [message] - Custom error message for type validation
|
|
72
73
|
* @returns {FunctionValidator} - Validator augmented with `implement()`
|
|
73
74
|
*/
|
|
74
|
-
export declare const function_: <const S extends FunctionSchema = FunctionSchema>(schema?: S, message?: string) => FunctionValidator<ExtractInput<S>, ExtractOutput<S
|
|
75
|
-
export {};
|
|
75
|
+
export declare const function_: <const S extends FunctionSchema = FunctionSchema>(schema?: S, message?: string) => FunctionValidator<ExtractInput<S>, ExtractOutput<S>> & StandardSchemaV1<InferFunction<ExtractInput<S>, ExtractOutput<S>>, InferFunction<ExtractInput<S>, ExtractOutput<S>>>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.function_ = void 0;
|
|
7
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
7
8
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
8
9
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
10
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
@@ -14,8 +15,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
14
15
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
15
16
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
16
17
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
17
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
18
|
-
/**
|
|
18
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /**
|
|
19
19
|
* Function validation core module
|
|
20
20
|
* Provides a validator for function values along with an `implement()`
|
|
21
21
|
* helper that wraps a concrete function with runtime validation of its
|
|
@@ -27,9 +27,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
27
27
|
* `implement` property directly) to create a wrapped function that asserts
|
|
28
28
|
* the schema on every call.
|
|
29
29
|
*/
|
|
30
|
-
|
|
31
|
-
// biome-ignore lint/suspicious/noExplicitAny: validator signatures vary
|
|
32
|
-
|
|
33
30
|
/**
|
|
34
31
|
* Function schema definition. `input` describes positional parameters and
|
|
35
32
|
* `output` describes the return type. Both are optional; when omitted the
|
|
@@ -121,5 +118,5 @@ var function_ = exports.function_ = function function_(schema, message) {
|
|
|
121
118
|
};
|
|
122
119
|
return wrapped;
|
|
123
120
|
};
|
|
124
|
-
return validator;
|
|
121
|
+
return (0, _standardSchema.attachStandard)(validator);
|
|
125
122
|
};
|
|
@@ -146,6 +146,17 @@ Object.keys(_set).forEach(function (key) {
|
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
});
|
|
149
|
+
var _standardSchema = require("./standardSchema");
|
|
150
|
+
Object.keys(_standardSchema).forEach(function (key) {
|
|
151
|
+
if (key === "default" || key === "__esModule") return;
|
|
152
|
+
if (key in exports && exports[key] === _standardSchema[key]) return;
|
|
153
|
+
Object.defineProperty(exports, key, {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
get: function get() {
|
|
156
|
+
return _standardSchema[key];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
149
160
|
var _string = require("./string");
|
|
150
161
|
Object.keys(_string).forEach(function (key) {
|
|
151
162
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* specific constructor, including subclasses. The validator is exported as
|
|
5
5
|
* `instanceof_` because `instanceof` is a reserved keyword in JavaScript.
|
|
6
6
|
*/
|
|
7
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
7
8
|
import type { ValidateCoreReturnType } from "../../Validate/type";
|
|
8
|
-
type Constructor<T> = new (...arguments_: any[]) => T;
|
|
9
|
+
export type Constructor<T> = new (...arguments_: any[]) => T;
|
|
9
10
|
/**
|
|
10
11
|
* Creates a validator that checks whether a value is an instance of the given
|
|
11
12
|
* constructor. Subclasses of the constructor satisfy the validator, matching
|
|
@@ -15,5 +16,4 @@ type Constructor<T> = new (...arguments_: any[]) => T;
|
|
|
15
16
|
* @param {string} [message] - Custom error message for validation failure
|
|
16
17
|
* @returns {Function} - Validator function for instances of the constructor
|
|
17
18
|
*/
|
|
18
|
-
export declare const instanceof_: <T>(classConstructor: Constructor<T>, message?: string) => (value: T) => ValidateCoreReturnType<T>;
|
|
19
|
-
export {};
|
|
19
|
+
export declare const instanceof_: <T>(classConstructor: Constructor<T>, message?: string) => ((value: T) => ValidateCoreReturnType<T>) & StandardSchemaV1<T, T>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.instanceof_ = void 0;
|
|
7
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
7
8
|
/**
|
|
8
9
|
* instanceof validation core module
|
|
9
10
|
* Provides a validator that checks whether a value is an instance of a
|
|
@@ -23,7 +24,7 @@ exports.instanceof_ = void 0;
|
|
|
23
24
|
* @returns {Function} - Validator function for instances of the constructor
|
|
24
25
|
*/
|
|
25
26
|
var instanceof_ = exports.instanceof_ = function instanceof_(classConstructor, message) {
|
|
26
|
-
|
|
27
|
+
var validator = function validator(value) {
|
|
27
28
|
if (!(value instanceof classConstructor)) {
|
|
28
29
|
return {
|
|
29
30
|
validate: false,
|
|
@@ -37,4 +38,5 @@ var instanceof_ = exports.instanceof_ = function instanceof_(classConstructor, m
|
|
|
37
38
|
type: value
|
|
38
39
|
};
|
|
39
40
|
};
|
|
41
|
+
return (0, _standardSchema.attachStandard)(validator);
|
|
40
42
|
};
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* delegate to per-entry validators for keys and values, mirroring how
|
|
5
5
|
* `arrayOf()` validates each element of an array.
|
|
6
6
|
*/
|
|
7
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
7
8
|
import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
8
|
-
type
|
|
9
|
+
export type MapExtractValidatedType<V> = V extends (value: never) => {
|
|
9
10
|
type: infer T;
|
|
10
11
|
} ? ValidateType<T> : never;
|
|
11
12
|
/**
|
|
@@ -20,5 +21,4 @@ type ExtractValidatedType<V> = V extends (value: never) => {
|
|
|
20
21
|
* @param {string} [message] - Custom error message for type validation
|
|
21
22
|
* @returns {Function} - Validator function for Map instances
|
|
22
23
|
*/
|
|
23
|
-
export declare const map: <KV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, VV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, K =
|
|
24
|
-
export {};
|
|
24
|
+
export declare const map: <KV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, VV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, K = MapExtractValidatedType<KV>, V = MapExtractValidatedType<VV>>(keyValidator?: KV, valueValidator?: VV, message?: string) => ((value: Map<K, V>) => ValidateCoreReturnType<Map<K, V>>) & StandardSchemaV1<Map<K, V>, Map<K, V>>;
|
|
@@ -4,20 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.map = void 0;
|
|
7
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
7
8
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
9
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
10
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
11
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11
12
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
12
13
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
13
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
|
-
/**
|
|
14
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /**
|
|
15
15
|
* Map validation core module
|
|
16
16
|
* Provides validation for `Map` instances. The validator can optionally
|
|
17
17
|
* delegate to per-entry validators for keys and values, mirroring how
|
|
18
18
|
* `arrayOf()` validates each element of an array.
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
20
|
/**
|
|
22
21
|
* Creates a Map validator. The validator can optionally accept per-entry key
|
|
23
22
|
* and value validators that are applied to every entry of the map. When the
|
|
@@ -31,7 +30,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
31
30
|
* @returns {Function} - Validator function for Map instances
|
|
32
31
|
*/
|
|
33
32
|
var map = exports.map = function map(keyValidator, valueValidator, message) {
|
|
34
|
-
|
|
33
|
+
var mapValidator = function mapValidator(value) {
|
|
35
34
|
if (!(value instanceof Map)) {
|
|
36
35
|
return {
|
|
37
36
|
validate: false,
|
|
@@ -78,4 +77,5 @@ var map = exports.map = function map(keyValidator, valueValidator, message) {
|
|
|
78
77
|
type: value
|
|
79
78
|
};
|
|
80
79
|
};
|
|
80
|
+
return (0, _standardSchema.attachStandard)(mapValidator);
|
|
81
81
|
};
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* positions in a schema that must never be filled (for example, exhaustive
|
|
5
5
|
* union members that should be unreachable at the type level).
|
|
6
6
|
*/
|
|
7
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
7
8
|
/**
|
|
8
9
|
* Return type produced by a `never` validator. Exposes the literal `"never"`
|
|
9
10
|
* tag through the `type` field so `ValidateType<"never">` can map it back to
|
|
@@ -19,4 +20,4 @@ export interface NeverReturnType {
|
|
|
19
20
|
* @param {string} [message] - Custom error message for validation failure
|
|
20
21
|
* @returns {Function} - Validator that always returns a failing result
|
|
21
22
|
*/
|
|
22
|
-
export declare const never: (message?: string) => ((value: any) => NeverReturnType)
|
|
23
|
+
export declare const never: (message?: string) => ((value: any) => NeverReturnType) & StandardSchemaV1<never, never>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.never = void 0;
|
|
7
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
7
8
|
/**
|
|
8
9
|
* Never validation core module
|
|
9
10
|
* Provides a validator that fails for every input, useful for marking
|
|
@@ -22,14 +23,14 @@ exports.never = void 0;
|
|
|
22
23
|
* @param {string} [message] - Custom error message for validation failure
|
|
23
24
|
* @returns {Function} - Validator that always returns a failing result
|
|
24
25
|
*/
|
|
25
|
-
// biome-ignore lint/suspicious/noExplicitAny: never() is widened to accept any input from union/intersection
|
|
26
26
|
var never = exports.never = function never(message) {
|
|
27
27
|
// biome-ignore lint/suspicious/noExplicitAny: signature mirrors the public type
|
|
28
|
-
|
|
28
|
+
var neverValidator = function neverValidator(_value) {
|
|
29
29
|
return {
|
|
30
30
|
validate: false,
|
|
31
31
|
message: message !== null && message !== void 0 ? message : "",
|
|
32
32
|
type: "never"
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
+
return (0, _standardSchema.attachStandard)(neverValidator);
|
|
35
36
|
};
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Number validation core module
|
|
3
3
|
* Provides the base validation functionality for number values
|
|
4
4
|
*/
|
|
5
|
-
import type
|
|
5
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
6
|
+
import type { ValidateCoreReturnType, ValidateReturnType } from "../../Validate/type";
|
|
6
7
|
/**
|
|
7
8
|
* Creates a number validator with optional validation rules
|
|
8
9
|
* @template T - Array of validation rules for numbers
|
|
@@ -10,4 +11,4 @@ import type { ValidateReturnType } from "../../Validate/type";
|
|
|
10
11
|
* @param {string} [message] - Custom error message for type validation
|
|
11
12
|
* @returns {Function} - Validator function that checks if the value is a number and applies validation rules
|
|
12
13
|
*/
|
|
13
|
-
export declare const number: <T extends ValidateReturnType<number>[]>(option?: T, message?: string) => (value: number) =>
|
|
14
|
+
export declare const number: <T extends ValidateReturnType<number>[]>(option?: T, message?: string) => ((value: number) => ValidateCoreReturnType<number>) & StandardSchemaV1<number, number>;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.number = void 0;
|
|
7
7
|
var _core = require("../../Validate/core");
|
|
8
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
8
9
|
/**
|
|
9
10
|
* Number validation core module
|
|
10
11
|
* Provides the base validation functionality for number values
|
|
@@ -18,7 +19,8 @@ var _core = require("../../Validate/core");
|
|
|
18
19
|
* @returns {Function} - Validator function that checks if the value is a number and applies validation rules
|
|
19
20
|
*/
|
|
20
21
|
var number = exports.number = function number(option, message) {
|
|
21
|
-
|
|
22
|
+
var validator = function validator(value) {
|
|
22
23
|
return (0, _core.core)("number")(value, option, message);
|
|
23
24
|
};
|
|
25
|
+
return (0, _standardSchema.attachStandard)(validator);
|
|
24
26
|
};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Provides validation functionality for objects with type-specific validation rules for each property
|
|
4
4
|
*/
|
|
5
5
|
import type { PickPartial } from "../../types/object";
|
|
6
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
6
7
|
import type { OptionalKeys, ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
7
8
|
/**
|
|
8
9
|
* Shape map describing per-property validators consumed by `object()`
|
|
@@ -31,4 +32,4 @@ export type ObjectValidator<T extends ObjectShape, U = {
|
|
|
31
32
|
* @param {string} [message] - Custom error message for object type validation
|
|
32
33
|
* @returns {ObjectValidator<T>} - Validator function with `.shape` attached so it can compose with `pick()`, `omit()`, `partial()`, and `required()`
|
|
33
34
|
*/
|
|
34
|
-
export declare const object: <T extends ObjectShape>(option?: T, message?: string) => ObjectValidator<T>;
|
|
35
|
+
export declare const object: <T extends ObjectShape>(option?: T, message?: string) => ObjectValidator<T> & StandardSchemaV1<unknown, unknown>;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.object = void 0;
|
|
7
7
|
var _isDictionaryObject = require("../../Validate/isDictionaryObject");
|
|
8
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
8
9
|
/**
|
|
9
10
|
* Object validation core module
|
|
10
11
|
* Provides validation functionality for objects with type-specific validation rules for each property
|
|
@@ -58,5 +59,5 @@ var object = exports.object = function object() {
|
|
|
58
59
|
};
|
|
59
60
|
};
|
|
60
61
|
validator.shape = option;
|
|
61
|
-
return validator;
|
|
62
|
+
return (0, _standardSchema.attachStandard)(validator);
|
|
62
63
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
1
2
|
import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
2
|
-
type
|
|
3
|
+
export type IntersectionExtractValidatedType<V> = V extends (value: never) => {
|
|
3
4
|
type: infer T;
|
|
4
5
|
} ? ValidateType<T> : never;
|
|
5
|
-
type IntersectValidatedTypes<Vs> = Vs extends readonly [
|
|
6
|
+
export type IntersectValidatedTypes<Vs> = Vs extends readonly [
|
|
6
7
|
infer Head,
|
|
7
8
|
...infer Tail
|
|
8
|
-
] ?
|
|
9
|
+
] ? IntersectionExtractValidatedType<Head> & IntersectValidatedTypes<Tail> : unknown;
|
|
9
10
|
/**
|
|
10
11
|
* Creates an intersection validator that passes only if all given validators pass
|
|
11
12
|
* @param validators - Validator functions to compose as an intersection (logical AND)
|
|
12
13
|
* @returns {Function} - Validator that checks if the value matches all validators
|
|
13
14
|
*/
|
|
14
|
-
export declare const intersection: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => (value: IntersectValidatedTypes<Vs>) => ValidateCoreReturnType<IntersectValidatedTypes<Vs>>;
|
|
15
|
-
export {};
|
|
15
|
+
export declare const intersection: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => ((value: IntersectValidatedTypes<Vs>) => ValidateCoreReturnType<IntersectValidatedTypes<Vs>>) & StandardSchemaV1<IntersectValidatedTypes<Vs>, IntersectValidatedTypes<Vs>>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.intersection = void 0;
|
|
7
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
7
8
|
// Extract the validated value type by reading the validator's `type` field
|
|
8
9
|
// (and applying `ValidateType` to map type tags like "string" back to the
|
|
9
10
|
// runtime type). Reading the field directly lets validators that expose the
|
|
@@ -25,7 +26,7 @@ var intersection = exports.intersection = function intersection() {
|
|
|
25
26
|
for (var _len = arguments.length, validators = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
27
|
validators[_key] = arguments[_key];
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
var intersectionValidator = function intersectionValidator(value) {
|
|
29
30
|
for (var _i = 0, _validators = validators; _i < _validators.length; _i++) {
|
|
30
31
|
var validator = _validators[_i];
|
|
31
32
|
var result = validator(value);
|
|
@@ -43,4 +44,5 @@ var intersection = exports.intersection = function intersection() {
|
|
|
43
44
|
type: value
|
|
44
45
|
};
|
|
45
46
|
};
|
|
47
|
+
return (0, _standardSchema.attachStandard)(intersectionValidator);
|
|
46
48
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
2
|
+
export interface NullReturn {
|
|
2
3
|
validate: boolean;
|
|
3
4
|
message: string;
|
|
4
5
|
type: "null";
|
|
@@ -14,5 +15,4 @@ export declare const nullable: <T, R extends {
|
|
|
14
15
|
type: unknown;
|
|
15
16
|
message: string;
|
|
16
17
|
validate: boolean;
|
|
17
|
-
}>(validator: (value: T) => R) => ((value: T | null) => R | NullReturn)
|
|
18
|
-
export {};
|
|
18
|
+
}>(validator: (value: T) => R) => ((value: T | null) => R | NullReturn) & StandardSchemaV1<T | null, T | null>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.nullable = void 0;
|
|
7
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
7
8
|
/**
|
|
8
9
|
* Wraps a validator to accept null values
|
|
9
10
|
* @template T - The type of value the wrapped validator expects
|
|
@@ -22,5 +23,5 @@ var nullable = exports.nullable = function nullable(validator) {
|
|
|
22
23
|
}
|
|
23
24
|
return validator(value);
|
|
24
25
|
};
|
|
25
|
-
return nullableValidator;
|
|
26
|
+
return (0, _standardSchema.attachStandard)(nullableValidator);
|
|
26
27
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
2
|
+
export interface UndefinedReturn {
|
|
2
3
|
validate: boolean;
|
|
3
4
|
message: string;
|
|
4
5
|
type: "undefined";
|
|
@@ -32,5 +33,4 @@ export declare const optional: <T, R extends {
|
|
|
32
33
|
type: unknown;
|
|
33
34
|
message: string;
|
|
34
35
|
validate: boolean;
|
|
35
|
-
}>(validator: (value: T) => R) => OptionalValidator<T, R>;
|
|
36
|
-
export {};
|
|
36
|
+
}>(validator: (value: T) => R) => OptionalValidator<T, R> & StandardSchemaV1<T | undefined, T | undefined>;
|