@infra-blocks/zod-utils 0.26.0 → 0.27.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
@@ -400,6 +400,21 @@ function expectsInteger(x: Integer) {
400
400
  expectsInteger(zu.number.integer().parse(42));
401
401
  ```
402
402
 
403
+ #### positiveInteger
404
+
405
+ `zu.number.positiveInteger()` produces a [branded type](#branded-types). It using `z.int().min(0)` internally.
406
+
407
+ ```typescript
408
+ import { zu } from "@infra-blocks/zod-utils";
409
+ import { PositiveInteger } from "@infra-blocks/zod-utils/number";
410
+
411
+ function doingBull(x: PositiveInteger) {
412
+ // Do some bull here.
413
+ }
414
+
415
+ doingBull(zu.number.positiveInteger().parse(42));
416
+ ```
417
+
403
418
  ### string
404
419
 
405
420
  The `zu.string` module exposes schemas for manipulating strings. All schemas return [branded types](#branded-types).
@@ -1,4 +1,5 @@
1
1
  declare const number: {
2
2
  integer: () => import("zod/v4/core").$ZodBranded<import("zod").ZodInt, "Integer">;
3
+ positiveInteger: () => import("zod/v4/core").$ZodBranded<import("zod").ZodInt, "PositiveInteger">;
3
4
  };
4
5
  export { number };
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.number = void 0;
4
4
  const integer_js_1 = require("./integer.js");
5
+ const positive_integer_js_1 = require("./positive-integer.js");
5
6
  const number = {
6
7
  integer: integer_js_1.integer,
8
+ positiveInteger: positive_integer_js_1.positiveInteger,
7
9
  };
8
10
  exports.number = number;
9
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/number/index.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AAEvC,MAAM,MAAM,GAAG;IACb,OAAO,EAAP,oBAAO;CACR,CAAC;AAEO,wBAAM"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/number/index.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,+DAAwD;AAExD,MAAM,MAAM,GAAG;IACb,OAAO,EAAP,oBAAO;IACP,eAAe,EAAf,qCAAe;CAChB,CAAC;AAEO,wBAAM"}
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ declare const schema: z.core.$ZodBranded<z.ZodInt, "PositiveInteger">;
3
+ export type PositiveInteger = z.infer<typeof schema>;
4
+ export declare const positiveInteger: () => z.core.$ZodBranded<z.ZodInt, "PositiveInteger">;
5
+ export {};
@@ -0,0 +1,8 @@
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.int().min(0).brand("PositiveInteger");
6
+ const positiveInteger = () => schema;
7
+ exports.positiveInteger = positiveInteger;
8
+ //# sourceMappingURL=positive-integer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positive-integer.js","sourceRoot":"","sources":["../../../src/number/positive-integer.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,MAAM,MAAM,GAAG,OAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAIhD,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC;AAA/B,QAAA,eAAe,mBAAgB"}
@@ -1 +1,2 @@
1
1
  export { Integer } from "./integer.js";
2
+ export { PositiveInteger } from "./positive-integer.js";
@@ -1,4 +1,5 @@
1
1
  declare const number: {
2
2
  integer: () => import("zod/v4/core").$ZodBranded<import("zod").ZodInt, "Integer">;
3
+ positiveInteger: () => import("zod/v4/core").$ZodBranded<import("zod").ZodInt, "PositiveInteger">;
3
4
  };
4
5
  export { number };
@@ -1,6 +1,8 @@
1
1
  import { integer } from "./integer.js";
2
+ import { positiveInteger } from "./positive-integer.js";
2
3
  const number = {
3
4
  integer,
5
+ positiveInteger,
4
6
  };
5
7
  export { number };
6
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/number/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,MAAM,GAAG;IACb,OAAO;CACR,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/number/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,MAAM,GAAG;IACb,OAAO;IACP,eAAe;CAChB,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ declare const schema: z.core.$ZodBranded<z.ZodInt, "PositiveInteger">;
3
+ export type PositiveInteger = z.infer<typeof schema>;
4
+ export declare const positiveInteger: () => z.core.$ZodBranded<z.ZodInt, "PositiveInteger">;
5
+ export {};
@@ -0,0 +1,4 @@
1
+ import { z } from "zod";
2
+ const schema = z.int().min(0).brand("PositiveInteger");
3
+ export const positiveInteger = () => schema;
4
+ //# sourceMappingURL=positive-integer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positive-integer.js","sourceRoot":"","sources":["../../../src/number/positive-integer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAIvD,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC"}
@@ -1 +1,2 @@
1
1
  export { Integer } from "./integer.js";
2
+ export { PositiveInteger } from "./positive-integer.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infra-blocks/zod-utils",
3
- "version": "0.26.0",
3
+ "version": "0.27.0-alpha.0",
4
4
  "description": "Extensions to the zod package.",
5
5
  "keywords": [
6
6
  "zod",