@infra-blocks/zod-utils 0.21.0 → 0.22.0-alpha.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/README.md CHANGED
@@ -381,6 +381,19 @@ expectTypeOf(result).toEqualTypeOf<UrlString>();
381
381
  expect(result).to.equal('[1, "word", null]');
382
382
  ```
383
383
 
384
+ #### number
385
+
386
+ ```typescript
387
+ import { zu } from "@infra-blocks/zod-utils";
388
+ import { NumberString } from "@infra-blocks/zod-utils/string";
389
+ import { expectTypeOf } from "expect-type";
390
+
391
+ // Uses z.string().regex(z.regexes.number) internally.
392
+ const result = zu.string.integer().parse("1234.5678");
393
+ expectTypeOf(result).toEqualTypeOf<NumberString>();
394
+ expect(result).to.equal("1234.5678");
395
+ ```
396
+
384
397
  ### Type Guard
385
398
 
386
399
  The `typeGuard` utility allows to obtain a function that will act as a type guard for the type
@@ -77,6 +77,7 @@ declare const zu: {
77
77
  string: {
78
78
  integer: () => z.core.$ZodBranded<z.ZodString, "IntegerString">;
79
79
  json: () => z.core.$ZodBranded<z.ZodString, "JsonString">;
80
+ number: () => z.core.$ZodBranded<z.ZodString, "NumberString">;
80
81
  url: () => z.core.$ZodBranded<z.ZodURL, "UrlString">;
81
82
  };
82
83
  isValid: typeof isValid;
@@ -1,6 +1,7 @@
1
1
  declare const string: {
2
2
  integer: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "IntegerString">;
3
3
  json: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "JsonString">;
4
+ number: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "NumberString">;
4
5
  url: () => import("zod/v4/core").$ZodBranded<import("zod").ZodURL, "UrlString">;
5
6
  };
6
7
  export { string };
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.string = void 0;
4
4
  const integer_js_1 = require("./integer.js");
5
5
  const json_js_1 = require("./json.js");
6
+ const number_js_1 = require("./number.js");
6
7
  const url_js_1 = require("./url.js");
7
8
  const string = {
8
9
  integer: integer_js_1.integer,
9
10
  json: json_js_1.json,
11
+ number: number_js_1.number,
10
12
  url: url_js_1.url,
11
13
  };
12
14
  exports.string = string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/string/index.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,uCAAiC;AACjC,qCAA+B;AAE/B,MAAM,MAAM,GAAG;IACb,OAAO,EAAP,oBAAO;IACP,IAAI,EAAJ,cAAI;IACJ,GAAG,EAAH,YAAG;CACJ,CAAC;AAEO,wBAAM"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/string/index.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,uCAAiC;AACjC,2CAAqC;AACrC,qCAA+B;AAE/B,MAAM,MAAM,GAAG;IACb,OAAO,EAAP,oBAAO;IACP,IAAI,EAAJ,cAAI;IACJ,MAAM,EAAN,kBAAM;IACN,GAAG,EAAH,YAAG;CACJ,CAAC;AAEO,wBAAM"}
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ declare const schema: z.core.$ZodBranded<z.ZodString, "NumberString">;
3
+ export type NumberString = z.infer<typeof schema>;
4
+ /**
5
+ * @returns A schema that uses `z.string().regex(z.regexes.number)` internally and returns an {@link NumberString}
6
+ * upon success.
7
+ */
8
+ export declare const number: () => z.core.$ZodBranded<z.ZodString, "NumberString">;
9
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.number = void 0;
4
+ const zod_1 = require("zod");
5
+ const schema = zod_1.z.string().regex(zod_1.z.regexes.number).brand("NumberString");
6
+ /**
7
+ * @returns A schema that uses `z.string().regex(z.regexes.number)` internally and returns an {@link NumberString}
8
+ * upon success.
9
+ */
10
+ const number = () => schema;
11
+ exports.number = number;
12
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","sourceRoot":"","sources":["../../../src/string/number.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,MAAM,MAAM,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAIxE;;;GAGG;AACI,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC;AAAtB,QAAA,MAAM,UAAgB"}
@@ -1,3 +1,4 @@
1
1
  export { IntegerString } from "./integer.js";
2
2
  export { JsonString } from "./json.js";
3
+ export { NumberString } from "./number.js";
3
4
  export { UrlString } from "./url.js";
@@ -77,6 +77,7 @@ declare const zu: {
77
77
  string: {
78
78
  integer: () => z.core.$ZodBranded<z.ZodString, "IntegerString">;
79
79
  json: () => z.core.$ZodBranded<z.ZodString, "JsonString">;
80
+ number: () => z.core.$ZodBranded<z.ZodString, "NumberString">;
80
81
  url: () => z.core.$ZodBranded<z.ZodURL, "UrlString">;
81
82
  };
82
83
  isValid: typeof isValid;
@@ -1,6 +1,7 @@
1
1
  declare const string: {
2
2
  integer: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "IntegerString">;
3
3
  json: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "JsonString">;
4
+ number: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "NumberString">;
4
5
  url: () => import("zod/v4/core").$ZodBranded<import("zod").ZodURL, "UrlString">;
5
6
  };
6
7
  export { string };
@@ -1,9 +1,11 @@
1
1
  import { integer } from "./integer.js";
2
2
  import { json } from "./json.js";
3
+ import { number } from "./number.js";
3
4
  import { url } from "./url.js";
4
5
  const string = {
5
6
  integer,
6
7
  json,
8
+ number,
7
9
  url,
8
10
  };
9
11
  export { string };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/string/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,MAAM,GAAG;IACb,OAAO;IACP,IAAI;IACJ,GAAG;CACJ,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/string/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,MAAM,GAAG;IACb,OAAO;IACP,IAAI;IACJ,MAAM;IACN,GAAG;CACJ,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ declare const schema: z.core.$ZodBranded<z.ZodString, "NumberString">;
3
+ export type NumberString = z.infer<typeof schema>;
4
+ /**
5
+ * @returns A schema that uses `z.string().regex(z.regexes.number)` internally and returns an {@link NumberString}
6
+ * upon success.
7
+ */
8
+ export declare const number: () => z.core.$ZodBranded<z.ZodString, "NumberString">;
9
+ export {};
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ const schema = z.string().regex(z.regexes.number).brand("NumberString");
3
+ /**
4
+ * @returns A schema that uses `z.string().regex(z.regexes.number)` internally and returns an {@link NumberString}
5
+ * upon success.
6
+ */
7
+ export const number = () => schema;
8
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","sourceRoot":"","sources":["../../../src/string/number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAIxE;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { IntegerString } from "./integer.js";
2
2
  export { JsonString } from "./json.js";
3
+ export { NumberString } from "./number.js";
3
4
  export { UrlString } from "./url.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infra-blocks/zod-utils",
3
- "version": "0.21.0",
3
+ "version": "0.22.0-alpha.0",
4
4
  "description": "Extensions to the zod package.",
5
5
  "keywords": [
6
6
  "zod",