@@ -6,6 +6,7 @@ description: >-
6
6
contributors :
7
7
- fabian-hiller
8
8
- BastiDood
9
+ - EltonLobo07
9
10
---
10
11
11
12
import { Link } from ' @builder.io/qwik-city' ;
@@ -119,13 +120,13 @@ If you are only interested in the error messages of each issue to show them to y
119
120
import * as v from ' valibot' ;
120
121
121
122
const ObjectSchema = v .object ({
122
- key : v .string (' Value of "key " is missing.' ),
123
- nested : v .object ({
124
- key : v .string (' Value of "nested.key " is missing.' ),
123
+ foo : v .string (' Value of "foo " is missing.' ),
124
+ bar : v .object ({
125
+ baz : v .string (' Value of "bar.baz " is missing.' ),
125
126
}),
126
127
});
127
128
128
- const result = v .safeParse (ObjectSchema , { nested : {} });
129
+ const result = v .safeParse (ObjectSchema , { bar : {} });
129
130
130
131
if (result .issues ) {
131
132
console .log (v .flatten <typeof ObjectSchema >(result .issues ));
@@ -142,15 +143,16 @@ The `result` returned in the code sample above this text contains the following
142
143
input: undefined ,
143
144
expected: ' string' ,
144
145
received: ' undefined' ,
145
- message: ' Value of "key " is missing.' ,
146
+ message: ' Value of "foo " is missing.' ,
146
147
path: [
147
148
{
148
149
type: ' object' ,
149
150
origin: ' value' ,
150
151
input: {
151
- nested : {},
152
+ bar : {},
152
153
},
153
- key: ' key' ,
154
+ key: ' foo' ,
155
+ value: undefined ,
154
156
},
155
157
],
156
158
},
@@ -160,22 +162,23 @@ The `result` returned in the code sample above this text contains the following
160
162
input: undefined ,
161
163
expected: ' string' ,
162
164
received: ' undefined' ,
163
- message: ' Value of "nested.key " is missing.' ,
165
+ message: ' Value of "bar.baz " is missing.' ,
164
166
path: [
165
167
{
166
168
type: ' object' ,
167
169
origin: ' value' ,
168
170
input: {
169
- nested : {},
171
+ bar : {},
170
172
},
171
- key: ' nested ' ,
173
+ key: ' bar ' ,
172
174
value: {},
173
175
},
174
176
{
175
177
type: ' object' ,
176
178
origin: ' value' ,
177
179
input: {},
178
- key: ' key' ,
180
+ key: ' baz' ,
181
+ value: undefined ,
179
182
},
180
183
],
181
184
},
@@ -187,8 +190,8 @@ However, with the help of <Link href="/api/flatten/">`flatten`</Link> the issues
187
190
``` ts
188
191
{
189
192
nested : {
190
- key : [' Value of "key " is missing.' ],
191
- ' nested.key ' : [' Value of "nested.key " is missing.' ]
192
- }
193
- }
193
+ foo : [' Value of "foo " is missing.' ],
194
+ ' bar.baz ' : [' Value of "bar.baz " is missing.' ],
195
+ },
196
+ };
194
197
```
0 commit comments