@optique/zod 1.0.0-dev.693 → 1.0.0-dev.705

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 (2) hide show
  1. package/README.md +21 -4
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -30,13 +30,16 @@ address.
30
30
 
31
31
  ~~~~ typescript
32
32
  import { run } from "@optique/run";
33
+ import { object } from "@optique/core/constructs";
33
34
  import { option } from "@optique/core/primitives";
34
35
  import { zod } from "@optique/zod";
35
36
  import { z } from "zod";
36
37
 
37
- const cli = run({
38
- email: option("--email", zod(z.string().email())),
39
- });
38
+ const cli = run(
39
+ object({
40
+ email: option("--email", zod(z.string().email())),
41
+ }),
42
+ );
40
43
 
41
44
  console.log(`Welcome, ${cli.email}!`);
42
45
  ~~~~
@@ -58,6 +61,7 @@ Common use cases
58
61
  ### Email validation
59
62
 
60
63
  ~~~~ typescript
64
+ import { option } from "@optique/core/primitives";
61
65
  import { zod } from "@optique/zod";
62
66
  import { z } from "zod";
63
67
 
@@ -67,6 +71,7 @@ const email = option("--email", zod(z.string().email()));
67
71
  ### URL validation
68
72
 
69
73
  ~~~~ typescript
74
+ import { option } from "@optique/core/primitives";
70
75
  import { zod } from "@optique/zod";
71
76
  import { z } from "zod";
72
77
 
@@ -80,6 +85,7 @@ const url = option("--url", zod(z.string().url()));
80
85
  > always strings.
81
86
 
82
87
  ~~~~ typescript
88
+ import { option } from "@optique/core/primitives";
83
89
  import { zod } from "@optique/zod";
84
90
  import { z } from "zod";
85
91
 
@@ -91,6 +97,7 @@ const port = option("-p", "--port",
91
97
  ### Enum choices
92
98
 
93
99
  ~~~~ typescript
100
+ import { option } from "@optique/core/primitives";
94
101
  import { zod } from "@optique/zod";
95
102
  import { z } from "zod";
96
103
 
@@ -102,6 +109,7 @@ const logLevel = option("--log-level",
102
109
  ### Date transformations
103
110
 
104
111
  ~~~~ typescript
112
+ import { argument } from "@optique/core/primitives";
105
113
  import { zod } from "@optique/zod";
106
114
  import { z } from "zod";
107
115
 
@@ -117,6 +125,7 @@ Custom error messages
117
125
  You can customize error messages using the `errors` option:
118
126
 
119
127
  ~~~~ typescript
128
+ import { option } from "@optique/core/primitives";
120
129
  import { zod } from "@optique/zod";
121
130
  import { message } from "@optique/core/message";
122
131
  import { z } from "zod";
@@ -140,11 +149,15 @@ CLI arguments are always strings. If you want to parse numbers, booleans,
140
149
  or other types, you must use `z.coerce`:
141
150
 
142
151
  ~~~~ typescript
152
+ import { option } from "@optique/core/primitives";
153
+ import { zod } from "@optique/zod";
154
+ import { z } from "zod";
155
+
143
156
  // ✅ Correct
144
157
  const port = option("-p", zod(z.coerce.number()));
145
158
 
146
159
  // ❌ Won't work (CLI arguments are always strings)
147
- const port = option("-p", zod(z.number()));
160
+ // const port = option("-p", zod(z.number()));
148
161
  ~~~~
149
162
 
150
163
  ### Async refinements are not supported
@@ -153,6 +166,10 @@ Optique's `ValueParser.parse()` is synchronous, so async Zod features like
153
166
  async refinements cannot be supported:
154
167
 
155
168
  ~~~~ typescript
169
+ import { option } from "@optique/core/primitives";
170
+ import { zod } from "@optique/zod";
171
+ import { z } from "zod";
172
+
156
173
  // ❌ Not supported
157
174
  const email = option("--email",
158
175
  zod(z.string().refine(async (val) => await checkDB(val)))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/zod",
3
- "version": "1.0.0-dev.693+6ee99e0d",
3
+ "version": "1.0.0-dev.705+5cb74130",
4
4
  "description": "Zod value parsers for Optique",
5
5
  "keywords": [
6
6
  "CLI",
@@ -57,7 +57,7 @@
57
57
  "zod": "^3.25.0 || ^4.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@optique/core": "1.0.0-dev.693+6ee99e0d"
60
+ "@optique/core": "1.0.0-dev.705+5cb74130"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/node": "^20.19.9",