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.
Files changed (111) hide show
  1. package/module/Validate/any/core.d.ts +2 -1
  2. package/module/Validate/any/core.js +3 -2
  3. package/module/Validate/any/core.js.map +1 -1
  4. package/module/Validate/array/arrayOf.d.ts +2 -1
  5. package/module/Validate/array/arrayOf.js +3 -1
  6. package/module/Validate/array/arrayOf.js.map +1 -1
  7. package/module/Validate/bigint/core.d.ts +2 -1
  8. package/module/Validate/bigint/core.js +3 -1
  9. package/module/Validate/bigint/core.js.map +1 -1
  10. package/module/Validate/boolean/core.d.ts +2 -1
  11. package/module/Validate/boolean/core.js +3 -1
  12. package/module/Validate/boolean/core.js.map +1 -1
  13. package/module/Validate/date/core.d.ts +2 -1
  14. package/module/Validate/date/core.js +3 -1
  15. package/module/Validate/date/core.js.map +1 -1
  16. package/module/Validate/file/core.d.ts +2 -1
  17. package/module/Validate/file/core.js +3 -1
  18. package/module/Validate/file/core.js.map +1 -1
  19. package/module/Validate/function/core.d.ts +2 -1
  20. package/module/Validate/function/core.js +2 -1
  21. package/module/Validate/function/core.js.map +1 -1
  22. package/module/Validate/index.d.ts +1 -0
  23. package/module/Validate/index.js +1 -0
  24. package/module/Validate/index.js.map +1 -1
  25. package/module/Validate/instanceof/core.d.ts +2 -1
  26. package/module/Validate/instanceof/core.js +3 -1
  27. package/module/Validate/instanceof/core.js.map +1 -1
  28. package/module/Validate/map/core.d.ts +2 -1
  29. package/module/Validate/map/core.js +3 -1
  30. package/module/Validate/map/core.js.map +1 -1
  31. package/module/Validate/never/core.d.ts +2 -1
  32. package/module/Validate/never/core.js +7 -8
  33. package/module/Validate/never/core.js.map +1 -1
  34. package/module/Validate/number/core.d.ts +3 -2
  35. package/module/Validate/number/core.js +3 -1
  36. package/module/Validate/number/core.js.map +1 -1
  37. package/module/Validate/object/core.d.ts +2 -1
  38. package/module/Validate/object/core.js +2 -1
  39. package/module/Validate/object/core.js.map +1 -1
  40. package/module/Validate/object/intersection.d.ts +2 -1
  41. package/module/Validate/object/intersection.js +3 -1
  42. package/module/Validate/object/intersection.js.map +1 -1
  43. package/module/Validate/object/nullable.d.ts +2 -1
  44. package/module/Validate/object/nullable.js +2 -1
  45. package/module/Validate/object/nullable.js.map +1 -1
  46. package/module/Validate/object/optional.d.ts +2 -1
  47. package/module/Validate/object/optional.js +2 -1
  48. package/module/Validate/object/optional.js.map +1 -1
  49. package/module/Validate/object/union.d.ts +2 -1
  50. package/module/Validate/object/union.js +3 -1
  51. package/module/Validate/object/union.js.map +1 -1
  52. package/module/Validate/set/core.d.ts +2 -1
  53. package/module/Validate/set/core.js +3 -1
  54. package/module/Validate/set/core.js.map +1 -1
  55. package/module/Validate/standardSchema.d.ts +93 -0
  56. package/module/Validate/standardSchema.js +58 -0
  57. package/module/Validate/standardSchema.js.map +1 -0
  58. package/module/Validate/string/core.d.ts +3 -2
  59. package/module/Validate/string/core.js +5 -1
  60. package/module/Validate/string/core.js.map +1 -1
  61. package/module/Validate/templateLiteral/core.d.ts +2 -1
  62. package/module/Validate/templateLiteral/core.js +3 -1
  63. package/module/Validate/templateLiteral/core.js.map +1 -1
  64. package/module/Validate/unknown/core.d.ts +2 -1
  65. package/module/Validate/unknown/core.js +3 -1
  66. package/module/Validate/unknown/core.js.map +1 -1
  67. package/module/es5/Validate/any/core.d.ts +2 -1
  68. package/module/es5/Validate/any/core.js +3 -2
  69. package/module/es5/Validate/array/arrayOf.d.ts +2 -1
  70. package/module/es5/Validate/array/arrayOf.js +3 -1
  71. package/module/es5/Validate/bigint/core.d.ts +2 -1
  72. package/module/es5/Validate/bigint/core.js +4 -4
  73. package/module/es5/Validate/boolean/core.d.ts +2 -1
  74. package/module/es5/Validate/boolean/core.js +3 -1
  75. package/module/es5/Validate/date/core.d.ts +2 -1
  76. package/module/es5/Validate/date/core.js +3 -1
  77. package/module/es5/Validate/file/core.d.ts +2 -1
  78. package/module/es5/Validate/file/core.js +3 -1
  79. package/module/es5/Validate/function/core.d.ts +2 -1
  80. package/module/es5/Validate/function/core.js +3 -4
  81. package/module/es5/Validate/index.d.ts +1 -0
  82. package/module/es5/Validate/index.js +11 -0
  83. package/module/es5/Validate/instanceof/core.d.ts +2 -1
  84. package/module/es5/Validate/instanceof/core.js +3 -1
  85. package/module/es5/Validate/map/core.d.ts +2 -1
  86. package/module/es5/Validate/map/core.js +4 -4
  87. package/module/es5/Validate/never/core.d.ts +2 -1
  88. package/module/es5/Validate/never/core.js +3 -2
  89. package/module/es5/Validate/number/core.d.ts +3 -2
  90. package/module/es5/Validate/number/core.js +3 -1
  91. package/module/es5/Validate/object/core.d.ts +2 -1
  92. package/module/es5/Validate/object/core.js +2 -1
  93. package/module/es5/Validate/object/intersection.d.ts +2 -1
  94. package/module/es5/Validate/object/intersection.js +3 -1
  95. package/module/es5/Validate/object/nullable.d.ts +2 -1
  96. package/module/es5/Validate/object/nullable.js +2 -1
  97. package/module/es5/Validate/object/optional.d.ts +2 -1
  98. package/module/es5/Validate/object/optional.js +2 -1
  99. package/module/es5/Validate/object/union.d.ts +2 -1
  100. package/module/es5/Validate/object/union.js +3 -1
  101. package/module/es5/Validate/set/core.d.ts +2 -1
  102. package/module/es5/Validate/set/core.js +4 -4
  103. package/module/es5/Validate/standardSchema.d.ts +93 -0
  104. package/module/es5/Validate/standardSchema.js +91 -0
  105. package/module/es5/Validate/string/core.d.ts +3 -2
  106. package/module/es5/Validate/string/core.js +3 -1
  107. package/module/es5/Validate/templateLiteral/core.d.ts +2 -1
  108. package/module/es5/Validate/templateLiteral/core.js +7 -6
  109. package/module/es5/Validate/unknown/core.d.ts +2 -1
  110. package/module/es5/Validate/unknown/core.js +3 -1
  111. package/package.json +9 -9
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.attachStandard = exports.STANDARD_SCHEMA_VENDOR = void 0;
7
+ /**
8
+ * Standard Schema V1 integration
9
+ *
10
+ * Defines the public Standard Schema V1 surface (https://standardschema.dev)
11
+ * and exposes the `attachStandard()` helper used by every UMT validator
12
+ * factory to advertise itself as a Standard Schema V1 implementation. The
13
+ * `~standard` property added by `attachStandard()` lets external tools
14
+ * (Zod-, Valibot-, ArkType-style ecosystems) consume UMT validators without
15
+ * adapters.
16
+ *
17
+ * Biome's `noNamespace` lint rule forbids TypeScript namespaces, so the spec
18
+ * is mirrored with flat interface/type names that remain structurally
19
+ * compatible with the official `StandardSchemaV1` interface published by
20
+ * `@standard-schema/spec`.
21
+ */
22
+
23
+ /** The Standard Schema V1 interface. */
24
+
25
+ /** The Standard Schema V1 properties interface. */
26
+
27
+ /** The result type produced by `Props.validate`. */
28
+
29
+ /** The result interface when validation succeeds. */
30
+
31
+ /** The result interface when validation fails. */
32
+
33
+ /** The issue interface returned on failure. */
34
+
35
+ /** The path segment interface for nested issues. */
36
+
37
+ /** The Standard Schema V1 types interface. */
38
+
39
+ /** Infers the input type of a Standard Schema V1 implementation. */
40
+
41
+ /** Infers the output type of a Standard Schema V1 implementation. */
42
+
43
+ /**
44
+ * Vendor identifier used by all UMT validators when advertising Standard
45
+ * Schema V1 compatibility. External tools may key off this value to attach
46
+ * UMT-specific behavior.
47
+ */
48
+ var STANDARD_SCHEMA_VENDOR = exports.STANDARD_SCHEMA_VENDOR = "umt";
49
+
50
+ /** Minimal shape of UMT validator results consumed by `attachStandard`. */
51
+
52
+ /**
53
+ * Attaches a Standard Schema V1 `~standard` property to a UMT validator
54
+ * function in place. The validator's existing call signature, attached
55
+ * helpers (such as `shape` on `object()` or `implement` on `function_()`),
56
+ * and return type are preserved untouched; only the `~standard` property is
57
+ * added.
58
+ *
59
+ * Validation is delegated to the wrapped validator. On success the input
60
+ * value is returned through the Standard Schema `value` field; on failure a
61
+ * single issue carrying the validator's message is emitted. UMT validators
62
+ * never transform their input, so `Input` and `Output` default to the same
63
+ * type.
64
+ *
65
+ * @template Input - The input type advertised through `~standard.types`
66
+ * @template Output - The output type advertised through `~standard.types`
67
+ * @template F - The validator function being augmented
68
+ * @param {F} validator - The validator function to augment
69
+ * @returns {F & StandardSchemaV1<Input, Output>} The same function with `~standard` attached
70
+ */
71
+ var attachStandard = exports.attachStandard = function attachStandard(validator) {
72
+ var properties = {
73
+ version: 1,
74
+ vendor: STANDARD_SCHEMA_VENDOR,
75
+ validate: function validate(value) {
76
+ var result = validator(value);
77
+ if (result.validate) {
78
+ return {
79
+ value: value
80
+ };
81
+ }
82
+ return {
83
+ issues: [{
84
+ message: result.message || "Validation failed"
85
+ }]
86
+ };
87
+ }
88
+ };
89
+ validator["~standard"] = properties;
90
+ return validator;
91
+ };
@@ -2,7 +2,8 @@
2
2
  * String validation core module
3
3
  * Provides the base validation functionality for string values
4
4
  */
5
- import type { ValidateReturnType } from "../../Validate/type";
5
+ import { type StandardSchemaV1 } from "../../Validate/standardSchema";
6
+ import type { ValidateCoreReturnType, ValidateReturnType } from "../../Validate/type";
6
7
  /**
7
8
  * Creates a string validator with optional validation rules
8
9
  * @template T - Array of validation rules for strings
@@ -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 string and applies validation rules
12
13
  */
13
- export declare const string: <T extends ValidateReturnType<string>[]>(option?: T, message?: string) => (value: string) => import("../../Validate/type").ValidateCoreReturnType<string>;
14
+ export declare const string: <T extends ValidateReturnType<string>[]>(option?: T, message?: string) => ((value: string) => ValidateCoreReturnType<string>) & StandardSchemaV1<string, string>;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.string = void 0;
7
7
  var _core = require("../../Validate/core");
8
+ var _standardSchema = require("../../Validate/standardSchema");
8
9
  /**
9
10
  * String validation core module
10
11
  * Provides the base validation functionality for string values
@@ -18,7 +19,8 @@ var _core = require("../../Validate/core");
18
19
  * @returns {Function} - Validator function that checks if the value is a string and applies validation rules
19
20
  */
20
21
  var string = exports.string = function string(option, message) {
21
- return function (value) {
22
+ var validator = function validator(value) {
22
23
  return (0, _core.core)("string")(value, option, message);
23
24
  };
25
+ return (0, _standardSchema.attachStandard)(validator);
24
26
  };
@@ -6,6 +6,7 @@
6
6
  * an auto-generated regular expression assembled from the parts, while the
7
7
  * inferred type is the corresponding TypeScript template literal type.
8
8
  */
9
+ import { type StandardSchemaV1 } from "../../Validate/standardSchema";
9
10
  import type { ValidateType } from "../../Validate/type";
10
11
  export type TemplateLiteralAnyValidator = (value?: any) => {
11
12
  type: unknown;
@@ -51,4 +52,4 @@ export interface TemplateLiteralReturnType<T extends string> {
51
52
  * @param {string} [message] - Custom error message for validation failure
52
53
  * @returns {Function} - Validator function for template literal strings
53
54
  */
54
- export declare const templateLiteral: <const Parts extends readonly TemplateLiteralPart[]>(parts: Parts, message?: string) => (value: BuildTemplateLiteral<Parts>) => TemplateLiteralReturnType<BuildTemplateLiteral<Parts>>;
55
+ export declare const templateLiteral: <const Parts extends readonly TemplateLiteralPart[]>(parts: Parts, message?: string) => ((value: BuildTemplateLiteral<Parts>) => TemplateLiteralReturnType<BuildTemplateLiteral<Parts>>) & StandardSchemaV1<BuildTemplateLiteral<Parts>, BuildTemplateLiteral<Parts>>;
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.templateLiteral = void 0;
7
+ var _standardSchema = require("../../Validate/standardSchema");
7
8
  var _templateObject, _templateObject2, _templateObject3;
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; } } }; }
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; } }
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
- function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
12
9
  /**
13
10
  * Template literal validation core module
14
11
  * Provides a validator that checks whether a string matches a template
@@ -17,7 +14,10 @@ function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.fre
17
14
  * an auto-generated regular expression assembled from the parts, while the
18
15
  * inferred type is the corresponding TypeScript template literal type.
19
16
  */
20
-
17
+ 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; } } }; }
18
+ 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; } }
19
+ 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; }
20
+ function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
21
21
  // biome-ignore lint/suspicious/noExplicitAny: validator signatures vary
22
22
 
23
23
  /**
@@ -97,7 +97,7 @@ var templateLiteral = exports.templateLiteral = function templateLiteral(parts,
97
97
  }
98
98
  pattern += "$";
99
99
  var regex = new RegExp(pattern);
100
- return function (value) {
100
+ var templateValidator = function templateValidator(value) {
101
101
  if (typeof value !== "string" || !regex.test(value)) {
102
102
  return {
103
103
  validate: false,
@@ -111,4 +111,5 @@ var templateLiteral = exports.templateLiteral = function templateLiteral(parts,
111
111
  type: value
112
112
  };
113
113
  };
114
+ return (0, _standardSchema.attachStandard)(templateValidator);
114
115
  };
@@ -3,6 +3,7 @@
3
3
  * Provides a validator that accepts any value but exposes it as `unknown`
4
4
  * to keep callers honest about narrowing before use.
5
5
  */
6
+ import { type StandardSchemaV1 } from "../../Validate/standardSchema";
6
7
  /**
7
8
  * Return type produced by an `unknown` validator. Exposes the literal
8
9
  * `"unknown"` tag through the `type` field so `ValidateType<"unknown">` can
@@ -18,4 +19,4 @@ export interface UnknownReturnType {
18
19
  * Creates a validator that accepts any value but typed as unknown
19
20
  * @returns {Function} - Validator that always succeeds
20
21
  */
21
- export declare const unknown: () => ((value: unknown) => UnknownReturnType);
22
+ export declare const unknown: () => ((value: unknown) => UnknownReturnType) & StandardSchemaV1<unknown, unknown>;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.unknown = void 0;
7
+ var _standardSchema = require("../../Validate/standardSchema");
7
8
  /**
8
9
  * Unknown validation core module
9
10
  * Provides a validator that accepts any value but exposes it as `unknown`
@@ -24,11 +25,12 @@ var unknownValidator = function unknownValidator(_value) {
24
25
  type: "unknown"
25
26
  };
26
27
  };
28
+ var standardUnknownValidator = (0, _standardSchema.attachStandard)(unknownValidator);
27
29
 
28
30
  /**
29
31
  * Creates a validator that accepts any value but typed as unknown
30
32
  * @returns {Function} - Validator that always succeeds
31
33
  */
32
34
  var unknown = exports.unknown = function unknown() {
33
- return unknownValidator;
35
+ return standardUnknownValidator;
34
36
  };
package/package.json CHANGED
@@ -9,18 +9,18 @@
9
9
  "@babel/core": "7.29.0",
10
10
  "@babel/preset-env": "7.29.5",
11
11
  "@babel/preset-typescript": "7.28.5",
12
- "@biomejs/biome": "2.4.14",
12
+ "@biomejs/biome": "2.4.15",
13
13
  "@codecov/bundle-analyzer": "2.0.1",
14
14
  "@eslint/js": "10.0.1",
15
15
  "@swc/core": "1.15.33",
16
16
  "@swc/jest": "0.2.39",
17
- "@types/bun": "1.3.13",
17
+ "@types/bun": "1.3.14",
18
18
  "@types/jest": "30.0.0",
19
19
  "@types/lodash": "4.17.24",
20
- "@types/node": "25.6.0",
21
- "@typescript-eslint/eslint-plugin": "8.59.2",
22
- "@typescript-eslint/parser": "8.59.2",
23
- "bun-types": "1.3.13",
20
+ "@types/node": "25.7.0",
21
+ "@typescript-eslint/eslint-plugin": "8.59.3",
22
+ "@typescript-eslint/parser": "8.59.3",
23
+ "bun-types": "1.3.14",
24
24
  "dependency-cruiser": "17.4.0",
25
25
  "es-toolkit": "1.46.1",
26
26
  "eslint": "10.3.0",
@@ -29,7 +29,7 @@
29
29
  "eslint-plugin-unicorn": "64.0.0",
30
30
  "fast-sort": "3.4.1",
31
31
  "gh-pages": "6.3.0",
32
- "jest": "30.3.0",
32
+ "jest": "30.4.2",
33
33
  "jest-junit": "17.0.0",
34
34
  "lodash": "4.18.1",
35
35
  "mitata": "1.0.34",
@@ -40,7 +40,7 @@
40
40
  "typedoc-github-wiki-theme": "2.1.0",
41
41
  "typedoc-plugin-markdown": "4.11.0",
42
42
  "typescript": "6.0.3",
43
- "typescript-eslint": "8.59.2"
43
+ "typescript-eslint": "8.59.3"
44
44
  },
45
45
  "exports": {
46
46
  ".": {
@@ -226,5 +226,5 @@
226
226
  },
227
227
  "type": "module",
228
228
  "types": "module/index.d.ts",
229
- "version": "3.1.0"
229
+ "version": "3.2.0"
230
230
  }