@optique/valibot 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 +22 -5
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -38,13 +38,16 @@ address.
38
38
 
39
39
  ~~~~ typescript
40
40
  import { run } from "@optique/run";
41
+ import { object } from "@optique/core/constructs";
41
42
  import { option } from "@optique/core/primitives";
42
43
  import { valibot } from "@optique/valibot";
43
44
  import * as v from "valibot";
44
45
 
45
- const cli = run({
46
- email: option("--email", valibot(v.pipe(v.string(), v.email()))),
47
- });
46
+ const cli = run(
47
+ object({
48
+ email: option("--email", valibot(v.pipe(v.string(), v.email()))),
49
+ }),
50
+ );
48
51
 
49
52
  console.log(`Welcome, ${cli.email}!`);
50
53
  ~~~~
@@ -66,6 +69,7 @@ Common use cases
66
69
  ### Email validation
67
70
 
68
71
  ~~~~ typescript
72
+ import { option } from "@optique/core/primitives";
69
73
  import { valibot } from "@optique/valibot";
70
74
  import * as v from "valibot";
71
75
 
@@ -75,6 +79,7 @@ const email = option("--email", valibot(v.pipe(v.string(), v.email())));
75
79
  ### URL validation
76
80
 
77
81
  ~~~~ typescript
82
+ import { option } from "@optique/core/primitives";
78
83
  import { valibot } from "@optique/valibot";
79
84
  import * as v from "valibot";
80
85
 
@@ -88,6 +93,7 @@ const url = option("--url", valibot(v.pipe(v.string(), v.url())));
88
93
  > non-string types, since CLI arguments are always strings.
89
94
 
90
95
  ~~~~ typescript
96
+ import { option } from "@optique/core/primitives";
91
97
  import { valibot } from "@optique/valibot";
92
98
  import * as v from "valibot";
93
99
 
@@ -106,6 +112,7 @@ const port = option("-p", "--port",
106
112
  ### Enum choices
107
113
 
108
114
  ~~~~ typescript
115
+ import { option } from "@optique/core/primitives";
109
116
  import { valibot } from "@optique/valibot";
110
117
  import * as v from "valibot";
111
118
 
@@ -117,11 +124,12 @@ const logLevel = option("--log-level",
117
124
  ### Date transformations
118
125
 
119
126
  ~~~~ typescript
127
+ import { argument } from "@optique/core/primitives";
120
128
  import { valibot } from "@optique/valibot";
121
129
  import * as v from "valibot";
122
130
 
123
131
  const startDate = argument(
124
- valibot(v.pipe(v.string(), v.transform((s) => new Date(s))))
132
+ valibot(v.pipe(v.string(), v.transform((s: string) => new Date(s))))
125
133
  );
126
134
  ~~~~
127
135
 
@@ -132,6 +140,7 @@ Custom error messages
132
140
  You can customize error messages using the `errors` option:
133
141
 
134
142
  ~~~~ typescript
143
+ import { option } from "@optique/core/primitives";
135
144
  import { valibot } from "@optique/valibot";
136
145
  import { message } from "@optique/core/message";
137
146
  import * as v from "valibot";
@@ -155,11 +164,15 @@ CLI arguments are always strings. If you want to parse numbers, booleans,
155
164
  or other types, you must use explicit `v.transform()`:
156
165
 
157
166
  ~~~~ typescript
167
+ import { option } from "@optique/core/primitives";
168
+ import { valibot } from "@optique/valibot";
169
+ import * as v from "valibot";
170
+
158
171
  // ✅ Correct
159
172
  const port = option("-p", valibot(v.pipe(v.string(), v.transform(Number))));
160
173
 
161
174
  // ❌ Won't work (CLI arguments are always strings)
162
- const port = option("-p", valibot(v.number()));
175
+ // const port = option("-p", valibot(v.number()));
163
176
  ~~~~
164
177
 
165
178
  ### Async validations are not supported
@@ -168,6 +181,10 @@ Optique's `ValueParser.parse()` is synchronous, so async Valibot features like
168
181
  async validations cannot be supported:
169
182
 
170
183
  ~~~~ typescript
184
+ import { option } from "@optique/core/primitives";
185
+ import { valibot } from "@optique/valibot";
186
+ import * as v from "valibot";
187
+
171
188
  // ❌ Not supported
172
189
  const email = option("--email",
173
190
  valibot(v.pipeAsync(v.string(), v.checkAsync(async (val) => await checkDB(val))))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/valibot",
3
- "version": "1.0.0-dev.693+6ee99e0d",
3
+ "version": "1.0.0-dev.705+5cb74130",
4
4
  "description": "Valibot value parsers for Optique",
5
5
  "keywords": [
6
6
  "CLI",
@@ -57,7 +57,7 @@
57
57
  "valibot": "^1.2.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",