@infra-blocks/zod-utils 0.28.0 → 0.29.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
@@ -447,6 +447,18 @@ expectTypeOf(result).toEqualTypeOf<zu.NumberString>();
447
447
  expect(result).to.equal("1234.5678");
448
448
  ```
449
449
 
450
+ ### positiveInteger
451
+
452
+ ```typescript
453
+ import { zu } from "@infra-blocks/zod-utils";
454
+ import { expectTypeOf } from "expect-type";
455
+
456
+ // Uses z.string().regex(/^\d+$/) internally.
457
+ const result = zu.string.positiveInteger().parse("1234");
458
+ expectTypeOf(result).toEqualTypeOf<zu.PositiveIntegerString>();
459
+ expect(result).to.equal("1234");
460
+ ```
461
+
450
462
  ### typeGuard
451
463
 
452
464
  The `typeGuard` utility allows to obtain a function that will act as a type guard for the type
@@ -3,10 +3,12 @@ export declare const string: {
3
3
  integer: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "IntegerString">;
4
4
  json: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "JsonString">;
5
5
  number: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "NumberString">;
6
+ positiveInteger: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "PositiveIntegerString">;
6
7
  url: () => import("zod/v4/core").$ZodBranded<import("zod").ZodURL, "UrlString">;
7
8
  };
8
9
  export type { Base64UrlString } from "./base64url.js";
9
10
  export type { IntegerString } from "./integer.js";
10
11
  export type { JsonString } from "./json.js";
11
12
  export type { NumberString } from "./number.js";
13
+ export type { PositiveIntegerString } from "./positive-integer.js";
12
14
  export type { UrlString } from "./url.js";
@@ -5,12 +5,14 @@ const base64url_js_1 = require("./base64url.js");
5
5
  const integer_js_1 = require("./integer.js");
6
6
  const json_js_1 = require("./json.js");
7
7
  const number_js_1 = require("./number.js");
8
+ const positive_integer_js_1 = require("./positive-integer.js");
8
9
  const url_js_1 = require("./url.js");
9
10
  exports.string = {
10
11
  base64url: base64url_js_1.base64url,
11
12
  integer: integer_js_1.integer,
12
13
  json: json_js_1.json,
13
14
  number: number_js_1.number,
15
+ positiveInteger: positive_integer_js_1.positiveInteger,
14
16
  url: url_js_1.url,
15
17
  };
16
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/string/index.ts"],"names":[],"mappings":";;;AAAA,iDAA2C;AAC3C,6CAAuC;AACvC,uCAAiC;AACjC,2CAAqC;AACrC,qCAA+B;AAElB,QAAA,MAAM,GAAG;IACpB,SAAS,EAAT,wBAAS;IACT,OAAO,EAAP,oBAAO;IACP,IAAI,EAAJ,cAAI;IACJ,MAAM,EAAN,kBAAM;IACN,GAAG,EAAH,YAAG;CACJ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/string/index.ts"],"names":[],"mappings":";;;AAAA,iDAA2C;AAC3C,6CAAuC;AACvC,uCAAiC;AACjC,2CAAqC;AACrC,+DAAwD;AACxD,qCAA+B;AAElB,QAAA,MAAM,GAAG;IACpB,SAAS,EAAT,wBAAS;IACT,OAAO,EAAP,oBAAO;IACP,IAAI,EAAJ,cAAI;IACJ,MAAM,EAAN,kBAAM;IACN,eAAe,EAAf,qCAAe;IACf,GAAG,EAAH,YAAG;CACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ declare const schema: z.core.$ZodBranded<z.ZodString, "PositiveIntegerString">;
3
+ export type PositiveIntegerString = z.infer<typeof schema>;
4
+ /**
5
+ * @returns A schema that uses `z.string().regex(...)` internally and returns a {@link PositiveIntegerString}
6
+ * upon success.
7
+ */
8
+ export declare const positiveInteger: () => z.core.$ZodBranded<z.ZodString, "PositiveIntegerString">;
9
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.positiveInteger = void 0;
4
+ const zod_1 = require("zod");
5
+ const schema = zod_1.z.string().regex(/^\d+$/).brand("PositiveIntegerString");
6
+ /**
7
+ * @returns A schema that uses `z.string().regex(...)` internally and returns a {@link PositiveIntegerString}
8
+ * upon success.
9
+ */
10
+ const positiveInteger = () => schema;
11
+ exports.positiveInteger = positiveInteger;
12
+ //# sourceMappingURL=positive-integer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positive-integer.js","sourceRoot":"","sources":["../../../src/string/positive-integer.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,MAAM,MAAM,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAIxE;;;GAGG;AACI,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC;AAA/B,QAAA,eAAe,mBAAgB"}
@@ -3,10 +3,12 @@ export declare const string: {
3
3
  integer: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "IntegerString">;
4
4
  json: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "JsonString">;
5
5
  number: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "NumberString">;
6
+ positiveInteger: () => import("zod/v4/core").$ZodBranded<import("zod").ZodString, "PositiveIntegerString">;
6
7
  url: () => import("zod/v4/core").$ZodBranded<import("zod").ZodURL, "UrlString">;
7
8
  };
8
9
  export type { Base64UrlString } from "./base64url.js";
9
10
  export type { IntegerString } from "./integer.js";
10
11
  export type { JsonString } from "./json.js";
11
12
  export type { NumberString } from "./number.js";
13
+ export type { PositiveIntegerString } from "./positive-integer.js";
12
14
  export type { UrlString } from "./url.js";
@@ -2,12 +2,14 @@ import { base64url } from "./base64url.js";
2
2
  import { integer } from "./integer.js";
3
3
  import { json } from "./json.js";
4
4
  import { number } from "./number.js";
5
+ import { positiveInteger } from "./positive-integer.js";
5
6
  import { url } from "./url.js";
6
7
  export const string = {
7
8
  base64url,
8
9
  integer,
9
10
  json,
10
11
  number,
12
+ positiveInteger,
11
13
  url,
12
14
  };
13
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/string/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,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,CAAC,MAAM,MAAM,GAAG;IACpB,SAAS;IACT,OAAO;IACP,IAAI;IACJ,MAAM;IACN,GAAG;CACJ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/string/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,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,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,SAAS;IACT,OAAO;IACP,IAAI;IACJ,MAAM;IACN,eAAe;IACf,GAAG;CACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ declare const schema: z.core.$ZodBranded<z.ZodString, "PositiveIntegerString">;
3
+ export type PositiveIntegerString = z.infer<typeof schema>;
4
+ /**
5
+ * @returns A schema that uses `z.string().regex(...)` internally and returns a {@link PositiveIntegerString}
6
+ * upon success.
7
+ */
8
+ export declare const positiveInteger: () => z.core.$ZodBranded<z.ZodString, "PositiveIntegerString">;
9
+ export {};
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ const schema = z.string().regex(/^\d+$/).brand("PositiveIntegerString");
3
+ /**
4
+ * @returns A schema that uses `z.string().regex(...)` internally and returns a {@link PositiveIntegerString}
5
+ * upon success.
6
+ */
7
+ export const positiveInteger = () => schema;
8
+ //# sourceMappingURL=positive-integer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positive-integer.js","sourceRoot":"","sources":["../../../src/string/positive-integer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;AAIxE;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infra-blocks/zod-utils",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Extensions to the zod package.",
5
5
  "keywords": [
6
6
  "zod",