umt 3.1.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/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 +2 -1
- 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 +2 -1
- 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 +2 -1
- package/module/Validate/instanceof/core.js +3 -1
- package/module/Validate/instanceof/core.js.map +1 -1
- package/module/Validate/map/core.d.ts +2 -1
- 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 +2 -1
- package/module/Validate/object/intersection.js +3 -1
- package/module/Validate/object/intersection.js.map +1 -1
- package/module/Validate/object/nullable.d.ts +2 -1
- package/module/Validate/object/nullable.js +2 -1
- package/module/Validate/object/nullable.js.map +1 -1
- package/module/Validate/object/optional.d.ts +2 -1
- package/module/Validate/object/optional.js +2 -1
- package/module/Validate/object/optional.js.map +1 -1
- package/module/Validate/object/union.d.ts +2 -1
- package/module/Validate/object/union.js +3 -1
- package/module/Validate/object/union.js.map +1 -1
- package/module/Validate/set/core.d.ts +2 -1
- 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 +2 -1
- 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/Validate/any/core.d.ts +2 -1
- package/module/es5/Validate/any/core.js +3 -2
- package/module/es5/Validate/array/arrayOf.d.ts +2 -1
- 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 +2 -1
- package/module/es5/Validate/function/core.js +3 -4
- 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 +2 -1
- package/module/es5/Validate/instanceof/core.js +3 -1
- package/module/es5/Validate/map/core.d.ts +2 -1
- 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 +2 -1
- package/module/es5/Validate/object/intersection.js +3 -1
- package/module/es5/Validate/object/nullable.d.ts +2 -1
- package/module/es5/Validate/object/nullable.js +2 -1
- package/module/es5/Validate/object/optional.d.ts +2 -1
- package/module/es5/Validate/object/optional.js +2 -1
- package/module/es5/Validate/object/union.d.ts +2 -1
- package/module/es5/Validate/object/union.js +3 -1
- package/module/es5/Validate/set/core.d.ts +2 -1
- 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 +2 -1
- 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/package.json +9 -9
|
@@ -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,6 +10,7 @@
|
|
|
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
15
|
export type FunctionAnyValidator = (value: any) => ValidateCoreReturnType<unknown>;
|
|
15
16
|
export type FunctionExtractValidatedType<V> = V extends (value: never) => {
|
|
@@ -71,4 +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 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,7 +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
30
|
/**
|
|
32
31
|
* Function schema definition. `input` describes positional parameters and
|
|
33
32
|
* `output` describes the return type. Both are optional; when omitted the
|
|
@@ -119,5 +118,5 @@ var function_ = exports.function_ = function function_(schema, message) {
|
|
|
119
118
|
};
|
|
120
119
|
return wrapped;
|
|
121
120
|
};
|
|
122
|
-
return validator;
|
|
121
|
+
return (0, _standardSchema.attachStandard)(validator);
|
|
123
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,6 +4,7 @@
|
|
|
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
9
|
export type Constructor<T> = new (...arguments_: any[]) => T;
|
|
9
10
|
/**
|
|
@@ -15,4 +16,4 @@ export 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 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,6 +4,7 @@
|
|
|
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
9
|
export type MapExtractValidatedType<V> = V extends (value: never) => {
|
|
9
10
|
type: infer T;
|
|
@@ -20,4 +21,4 @@ export type MapExtractValidatedType<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 = MapExtractValidatedType<KV>, V = MapExtractValidatedType<VV>>(keyValidator?: KV, valueValidator?: VV, message?: string) => (value: Map<K, V>) => ValidateCoreReturnType<Map<K, V>>;
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
1
2
|
import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
2
3
|
export type IntersectionExtractValidatedType<V> = V extends (value: never) => {
|
|
3
4
|
type: infer T;
|
|
@@ -11,4 +12,4 @@ export type IntersectValidatedTypes<Vs> = Vs extends readonly [
|
|
|
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 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,3 +1,4 @@
|
|
|
1
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
1
2
|
export interface NullReturn {
|
|
2
3
|
validate: boolean;
|
|
3
4
|
message: string;
|
|
@@ -14,4 +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
|
+
}>(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,3 +1,4 @@
|
|
|
1
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
1
2
|
export interface UndefinedReturn {
|
|
2
3
|
validate: boolean;
|
|
3
4
|
message: string;
|
|
@@ -32,4 +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
|
+
}>(validator: (value: T) => R) => OptionalValidator<T, R> & StandardSchemaV1<T | undefined, T | undefined>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.optional = void 0;
|
|
7
|
+
var _standardSchema = require("../../Validate/standardSchema");
|
|
7
8
|
/**
|
|
8
9
|
* Optional validator augmented with a reference to the wrapped validator,
|
|
9
10
|
* used by `required()` to unwrap optional layers when rebuilding a shape
|
|
@@ -31,5 +32,5 @@ var optional = exports.optional = function optional(validator) {
|
|
|
31
32
|
};
|
|
32
33
|
optionalValidator.inner = validator;
|
|
33
34
|
optionalValidator.isOptional = true;
|
|
34
|
-
return optionalValidator;
|
|
35
|
+
return (0, _standardSchema.attachStandard)(optionalValidator);
|
|
35
36
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
1
2
|
import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
2
3
|
export type UnionExtractValidatedType<V> = V extends (value: never) => {
|
|
3
4
|
type: infer T;
|
|
@@ -7,4 +8,4 @@ export type UnionExtractValidatedType<V> = V extends (value: never) => {
|
|
|
7
8
|
* @param validators - Validator functions to compose as a union (logical OR)
|
|
8
9
|
* @returns {Function} - Validator that checks if the value matches any of the validators
|
|
9
10
|
*/
|
|
10
|
-
export declare const union: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => (value: UnionExtractValidatedType<Vs[number]>) => ValidateCoreReturnType<UnionExtractValidatedType<Vs[number]>>;
|
|
11
|
+
export declare const union: <Vs extends ((value: never) => ValidateCoreReturnType<unknown>)[]>(...validators: [...Vs]) => ((value: UnionExtractValidatedType<Vs[number]>) => ValidateCoreReturnType<UnionExtractValidatedType<Vs[number]>>) & StandardSchemaV1<UnionExtractValidatedType<Vs[number]>, UnionExtractValidatedType<Vs[number]>>;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.union = 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
|
|
@@ -19,7 +20,7 @@ var union = exports.union = function union() {
|
|
|
19
20
|
for (var _len = arguments.length, validators = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
21
|
validators[_key] = arguments[_key];
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
var unionValidator = function unionValidator(value) {
|
|
23
24
|
var lastMessage = "";
|
|
24
25
|
for (var _i = 0, _validators = validators; _i < _validators.length; _i++) {
|
|
25
26
|
var validator = _validators[_i];
|
|
@@ -39,4 +40,5 @@ var union = exports.union = function union() {
|
|
|
39
40
|
type: value
|
|
40
41
|
};
|
|
41
42
|
};
|
|
43
|
+
return (0, _standardSchema.attachStandard)(unionValidator);
|
|
42
44
|
};
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* The function is exported as `set_` because the top-level `Object` module
|
|
8
8
|
* already exposes a `set` runtime helper.
|
|
9
9
|
*/
|
|
10
|
+
import { type StandardSchemaV1 } from "../../Validate/standardSchema";
|
|
10
11
|
import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
|
|
11
12
|
export type SetExtractValidatedType<V> = V extends (value: never) => {
|
|
12
13
|
type: infer T;
|
|
@@ -20,4 +21,4 @@ export type SetExtractValidatedType<V> = V extends (value: never) => {
|
|
|
20
21
|
* @param {string} [message] - Custom error message for type validation
|
|
21
22
|
* @returns {Function} - Validator function for Set instances
|
|
22
23
|
*/
|
|
23
|
-
export declare const set_: <IV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, T = SetExtractValidatedType<IV>>(itemValidator?: IV, message?: string) => (value: Set<T>) => ValidateCoreReturnType<Set<T>>;
|
|
24
|
+
export declare const set_: <IV extends (value: any) => ValidateCoreReturnType<unknown> = (value: unknown) => ValidateCoreReturnType<unknown>, T = SetExtractValidatedType<IV>>(itemValidator?: IV, message?: string) => ((value: Set<T>) => ValidateCoreReturnType<Set<T>>) & StandardSchemaV1<Set<T>, Set<T>>;
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.set_ = 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
|
* Set validation core module
|
|
12
12
|
* Provides validation for `Set` instances. The validator can optionally
|
|
13
13
|
* delegate to a per-element validator, mirroring how `arrayOf()` validates
|
|
@@ -16,7 +16,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
16
16
|
* The function is exported as `set_` because the top-level `Object` module
|
|
17
17
|
* already exposes a `set` runtime helper.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
19
|
/**
|
|
21
20
|
* Creates a Set validator. When a per-element validator is supplied, every
|
|
22
21
|
* element of the set must satisfy it; iteration short-circuits at the first
|
|
@@ -27,7 +26,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
27
26
|
* @returns {Function} - Validator function for Set instances
|
|
28
27
|
*/
|
|
29
28
|
var set_ = exports.set_ = function set_(itemValidator, message) {
|
|
30
|
-
|
|
29
|
+
var setValidator = function setValidator(value) {
|
|
31
30
|
if (!(value instanceof Set)) {
|
|
32
31
|
return {
|
|
33
32
|
validate: false,
|
|
@@ -62,4 +61,5 @@ var set_ = exports.set_ = function set_(itemValidator, message) {
|
|
|
62
61
|
type: value
|
|
63
62
|
};
|
|
64
63
|
};
|
|
64
|
+
return (0, _standardSchema.attachStandard)(setValidator);
|
|
65
65
|
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard Schema V1 integration
|
|
3
|
+
*
|
|
4
|
+
* Defines the public Standard Schema V1 surface (https://standardschema.dev)
|
|
5
|
+
* and exposes the `attachStandard()` helper used by every UMT validator
|
|
6
|
+
* factory to advertise itself as a Standard Schema V1 implementation. The
|
|
7
|
+
* `~standard` property added by `attachStandard()` lets external tools
|
|
8
|
+
* (Zod-, Valibot-, ArkType-style ecosystems) consume UMT validators without
|
|
9
|
+
* adapters.
|
|
10
|
+
*
|
|
11
|
+
* Biome's `noNamespace` lint rule forbids TypeScript namespaces, so the spec
|
|
12
|
+
* is mirrored with flat interface/type names that remain structurally
|
|
13
|
+
* compatible with the official `StandardSchemaV1` interface published by
|
|
14
|
+
* `@standard-schema/spec`.
|
|
15
|
+
*/
|
|
16
|
+
/** The Standard Schema V1 interface. */
|
|
17
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
18
|
+
readonly "~standard": StandardSchemaV1Properties<Input, Output>;
|
|
19
|
+
}
|
|
20
|
+
/** The Standard Schema V1 properties interface. */
|
|
21
|
+
export interface StandardSchemaV1Properties<Input = unknown, Output = Input> {
|
|
22
|
+
/** The version number of the standard. */
|
|
23
|
+
readonly version: 1;
|
|
24
|
+
/** The vendor name of the schema library. */
|
|
25
|
+
readonly vendor: string;
|
|
26
|
+
/** Validates unknown input values. */
|
|
27
|
+
readonly validate: (value: unknown) => StandardSchemaV1Result<Output> | Promise<StandardSchemaV1Result<Output>>;
|
|
28
|
+
/** Inferred types associated with the schema. */
|
|
29
|
+
readonly types?: StandardSchemaV1Types<Input, Output> | undefined;
|
|
30
|
+
}
|
|
31
|
+
/** The result type produced by `Props.validate`. */
|
|
32
|
+
export type StandardSchemaV1Result<Output> = StandardSchemaV1SuccessResult<Output> | StandardSchemaV1FailureResult;
|
|
33
|
+
/** The result interface when validation succeeds. */
|
|
34
|
+
export interface StandardSchemaV1SuccessResult<Output> {
|
|
35
|
+
readonly value: Output;
|
|
36
|
+
readonly issues?: undefined;
|
|
37
|
+
}
|
|
38
|
+
/** The result interface when validation fails. */
|
|
39
|
+
export interface StandardSchemaV1FailureResult {
|
|
40
|
+
readonly issues: readonly StandardSchemaV1Issue[];
|
|
41
|
+
}
|
|
42
|
+
/** The issue interface returned on failure. */
|
|
43
|
+
export interface StandardSchemaV1Issue {
|
|
44
|
+
readonly message: string;
|
|
45
|
+
readonly path?: readonly (PropertyKey | StandardSchemaV1PathSegment)[] | undefined;
|
|
46
|
+
}
|
|
47
|
+
/** The path segment interface for nested issues. */
|
|
48
|
+
export interface StandardSchemaV1PathSegment {
|
|
49
|
+
readonly key: PropertyKey;
|
|
50
|
+
}
|
|
51
|
+
/** The Standard Schema V1 types interface. */
|
|
52
|
+
export interface StandardSchemaV1Types<Input = unknown, Output = Input> {
|
|
53
|
+
/** The input type of the schema. */
|
|
54
|
+
readonly input: Input;
|
|
55
|
+
/** The output type of the schema. */
|
|
56
|
+
readonly output: Output;
|
|
57
|
+
}
|
|
58
|
+
/** Infers the input type of a Standard Schema V1 implementation. */
|
|
59
|
+
export type StandardSchemaV1InferInput<Schema extends StandardSchemaV1<any, any>> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
60
|
+
/** Infers the output type of a Standard Schema V1 implementation. */
|
|
61
|
+
export type StandardSchemaV1InferOutput<Schema extends StandardSchemaV1<any, any>> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
62
|
+
/**
|
|
63
|
+
* Vendor identifier used by all UMT validators when advertising Standard
|
|
64
|
+
* Schema V1 compatibility. External tools may key off this value to attach
|
|
65
|
+
* UMT-specific behavior.
|
|
66
|
+
*/
|
|
67
|
+
export declare const STANDARD_SCHEMA_VENDOR = "umt";
|
|
68
|
+
/** Minimal shape of UMT validator results consumed by `attachStandard`. */
|
|
69
|
+
export interface UmtValidatorResult {
|
|
70
|
+
validate: boolean;
|
|
71
|
+
message: string;
|
|
72
|
+
type: unknown;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Attaches a Standard Schema V1 `~standard` property to a UMT validator
|
|
76
|
+
* function in place. The validator's existing call signature, attached
|
|
77
|
+
* helpers (such as `shape` on `object()` or `implement` on `function_()`),
|
|
78
|
+
* and return type are preserved untouched; only the `~standard` property is
|
|
79
|
+
* added.
|
|
80
|
+
*
|
|
81
|
+
* Validation is delegated to the wrapped validator. On success the input
|
|
82
|
+
* value is returned through the Standard Schema `value` field; on failure a
|
|
83
|
+
* single issue carrying the validator's message is emitted. UMT validators
|
|
84
|
+
* never transform their input, so `Input` and `Output` default to the same
|
|
85
|
+
* type.
|
|
86
|
+
*
|
|
87
|
+
* @template Input - The input type advertised through `~standard.types`
|
|
88
|
+
* @template Output - The output type advertised through `~standard.types`
|
|
89
|
+
* @template F - The validator function being augmented
|
|
90
|
+
* @param {F} validator - The validator function to augment
|
|
91
|
+
* @returns {F & StandardSchemaV1<Input, Output>} The same function with `~standard` attached
|
|
92
|
+
*/
|
|
93
|
+
export declare const attachStandard: <Input, Output = Input, F extends (...arguments_: any[]) => UmtValidatorResult = (...arguments_: any[]) => UmtValidatorResult>(validator: F) => F & StandardSchemaV1<Input, Output>;
|