umt 2.18.0 → 2.19.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.
@@ -0,0 +1,9 @@
1
+ import type { ValidateCoreReturnType } from "../../Validate/type";
2
+ /**
3
+ * Creates an array validator that validates every element with a single validator
4
+ * @template T - Element type validated by the wrapped validator
5
+ * @param {Function} validator - Validator applied to each element (e.g. an object validator)
6
+ * @param {string} [message] - Custom error message for array type validation
7
+ * @returns {Function} - Validator function for arrays whose elements satisfy the given validator
8
+ */
9
+ export declare const arrayOf: <T>(validator: (value: T) => ValidateCoreReturnType<T>, message?: string) => (values: T[]) => ValidateCoreReturnType<T[]>;
@@ -0,0 +1,35 @@
1
+ import { isArray } from "../../Validate/isArray";
2
+ /**
3
+ * Creates an array validator that validates every element with a single validator
4
+ * @template T - Element type validated by the wrapped validator
5
+ * @param {Function} validator - Validator applied to each element (e.g. an object validator)
6
+ * @param {string} [message] - Custom error message for array type validation
7
+ * @returns {Function} - Validator function for arrays whose elements satisfy the given validator
8
+ */
9
+ export const arrayOf = (validator, message) => {
10
+ return (values) => {
11
+ if (!isArray(values)) {
12
+ return {
13
+ validate: false,
14
+ message: message ?? "",
15
+ type: values,
16
+ };
17
+ }
18
+ for (const value of values) {
19
+ const result = validator(value);
20
+ if (!result.validate) {
21
+ return {
22
+ validate: false,
23
+ message: result.message,
24
+ type: values,
25
+ };
26
+ }
27
+ }
28
+ return {
29
+ validate: true,
30
+ message: "",
31
+ type: values,
32
+ };
33
+ };
34
+ };
35
+ //# sourceMappingURL=arrayOf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrayOf.js","sourceRoot":"","sources":["../../../src/Validate/array/arrayOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,SAAkD,EAClD,OAAgB,EAChB,EAAE;IACF,OAAO,CAAC,MAAW,EAA+B,EAAE;QAClD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACrB,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,MAAM;aACb,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;YAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACrB,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,IAAI,EAAE,MAAM;iBACb,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,MAAM;SACb,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -1 +1,2 @@
1
+ export * from "./arrayOf";
1
2
  export * from "./core";
@@ -1,2 +1,3 @@
1
+ export * from "./arrayOf";
1
2
  export * from "./core";
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/array/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Validate/array/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
@@ -37,7 +37,7 @@ export type _ValidateType2<T> = T extends "undefined" ? undefined : T extends "n
37
37
  * @returns The corresponding TypeScript type (string, number, boolean) or the original type T
38
38
  */
39
39
  export type ValidateType<T> = T extends "string" | "number" | "boolean" ? _ValidateType<T> : T extends "undefined" | "null" ? _ValidateType2<T> : T;
40
- export type SchemaToInterface<T extends (value: any) => ValidateCoreReturnType<any>> = ReturnType<T>["type"];
40
+ export type SchemaToInterface<T extends (value: any) => ValidateCoreReturnType<any>> = ValidateType<ReturnType<T>["type"]>;
41
41
  export type OptionalKeys<T> = {
42
42
  [K in keyof T]: undefined extends T[K] ? K : never;
43
43
  }[keyof T];
@@ -0,0 +1,9 @@
1
+ import type { ValidateCoreReturnType } from "../../Validate/type";
2
+ /**
3
+ * Creates an array validator that validates every element with a single validator
4
+ * @template T - Element type validated by the wrapped validator
5
+ * @param {Function} validator - Validator applied to each element (e.g. an object validator)
6
+ * @param {string} [message] - Custom error message for array type validation
7
+ * @returns {Function} - Validator function for arrays whose elements satisfy the given validator
8
+ */
9
+ export declare const arrayOf: <T>(validator: (value: T) => ValidateCoreReturnType<T>, message?: string) => (values: T[]) => ValidateCoreReturnType<T[]>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.arrayOf = void 0;
7
+ var _isArray = require("../../Validate/isArray");
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
+ /**
12
+ * Creates an array validator that validates every element with a single validator
13
+ * @template T - Element type validated by the wrapped validator
14
+ * @param {Function} validator - Validator applied to each element (e.g. an object validator)
15
+ * @param {string} [message] - Custom error message for array type validation
16
+ * @returns {Function} - Validator function for arrays whose elements satisfy the given validator
17
+ */
18
+ var arrayOf = exports.arrayOf = function arrayOf(validator, message) {
19
+ return function (values) {
20
+ if (!(0, _isArray.isArray)(values)) {
21
+ return {
22
+ validate: false,
23
+ message: message !== null && message !== void 0 ? message : "",
24
+ type: values
25
+ };
26
+ }
27
+ var _iterator = _createForOfIteratorHelper(values),
28
+ _step;
29
+ try {
30
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
31
+ var value = _step.value;
32
+ var result = validator(value);
33
+ if (!result.validate) {
34
+ return {
35
+ validate: false,
36
+ message: result.message,
37
+ type: values
38
+ };
39
+ }
40
+ }
41
+ } catch (err) {
42
+ _iterator.e(err);
43
+ } finally {
44
+ _iterator.f();
45
+ }
46
+ return {
47
+ validate: true,
48
+ message: "",
49
+ type: values
50
+ };
51
+ };
52
+ };
@@ -1 +1,2 @@
1
+ export * from "./arrayOf";
1
2
  export * from "./core";
@@ -3,6 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _arrayOf = require("./arrayOf");
7
+ Object.keys(_arrayOf).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _arrayOf[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _arrayOf[key];
14
+ }
15
+ });
16
+ });
6
17
  var _core = require("./core");
7
18
  Object.keys(_core).forEach(function (key) {
8
19
  if (key === "default" || key === "__esModule") return;
@@ -37,7 +37,7 @@ export type _ValidateType2<T> = T extends "undefined" ? undefined : T extends "n
37
37
  * @returns The corresponding TypeScript type (string, number, boolean) or the original type T
38
38
  */
39
39
  export type ValidateType<T> = T extends "string" | "number" | "boolean" ? _ValidateType<T> : T extends "undefined" | "null" ? _ValidateType2<T> : T;
40
- export type SchemaToInterface<T extends (value: any) => ValidateCoreReturnType<any>> = ReturnType<T>["type"];
40
+ export type SchemaToInterface<T extends (value: any) => ValidateCoreReturnType<any>> = ValidateType<ReturnType<T>["type"]>;
41
41
  export type OptionalKeys<T> = {
42
42
  [K in keyof T]: undefined extends T[K] ? K : never;
43
43
  }[keyof T];
package/package.json CHANGED
@@ -7,23 +7,23 @@
7
7
  "devDependencies": {
8
8
  "@babel/cli": "7.28.6",
9
9
  "@babel/core": "7.29.0",
10
- "@babel/preset-env": "7.29.2",
10
+ "@babel/preset-env": "7.29.5",
11
11
  "@babel/preset-typescript": "7.28.5",
12
- "@biomejs/biome": "2.4.13",
12
+ "@biomejs/biome": "2.4.14",
13
13
  "@codecov/bundle-analyzer": "2.0.1",
14
14
  "@eslint/js": "10.0.1",
15
- "@swc/core": "1.15.32",
15
+ "@swc/core": "1.15.33",
16
16
  "@swc/jest": "0.2.39",
17
17
  "@types/bun": "1.3.13",
18
18
  "@types/jest": "30.0.0",
19
19
  "@types/lodash": "4.17.24",
20
20
  "@types/node": "25.6.0",
21
- "@typescript-eslint/eslint-plugin": "8.59.1",
22
- "@typescript-eslint/parser": "8.59.1",
21
+ "@typescript-eslint/eslint-plugin": "8.59.2",
22
+ "@typescript-eslint/parser": "8.59.2",
23
23
  "bun-types": "1.3.13",
24
- "dependency-cruiser": "17.3.10",
25
- "es-toolkit": "1.46.0",
26
- "eslint": "10.2.1",
24
+ "dependency-cruiser": "17.4.0",
25
+ "es-toolkit": "1.46.1",
26
+ "eslint": "10.3.0",
27
27
  "eslint-plugin-baseline-js": "0.6.2",
28
28
  "eslint-plugin-import": "2.32.0",
29
29
  "eslint-plugin-unicorn": "64.0.0",
@@ -35,12 +35,12 @@
35
35
  "mitata": "1.0.34",
36
36
  "ts-jest": "29.4.9",
37
37
  "ts-node": "10.9.2",
38
- "tsc-alias": "1.8.16",
38
+ "tsc-alias": "1.8.17",
39
39
  "typedoc": "0.28.19",
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.1"
43
+ "typescript-eslint": "8.59.2"
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": "2.18.0"
229
+ "version": "2.19.0"
230
230
  }