File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
src/routes/(v2)/v2/array-errors2 Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ <script lang =" ts" >
2+ import { z } from ' zod' ;
3+ import { defaults , superForm } from ' $lib/index.js' ;
4+ import { zod } from ' $lib//adapters/zod.js' ;
5+
6+ const testArraySchema = z .array (z .string ()).min (1 );
7+
8+ const schema = z .object ({
9+ values: z .array (
10+ z .object ({
11+ testArray: testArraySchema
12+ })
13+ ),
14+ defaultValue: z .object ({
15+ testArray: testArraySchema
16+ })
17+ });
18+
19+ const defaultSchemaValue = {
20+ defaultValue: {
21+ testArray: []
22+ },
23+ values: [
24+ {
25+ testArray: []
26+ }
27+ ]
28+ };
29+ const entireForm = superForm (defaults (defaultSchemaValue , zod (schema )), {
30+ SPA: true ,
31+ dataType: ' json' ,
32+ validators: zod (schema ),
33+ onUpdate({ form }) {
34+ console .log (form .valid );
35+ }
36+ });
37+
38+ const { enhance, errors } = entireForm ;
39+ </script >
40+
41+ {JSON .stringify ($errors )}
42+
43+ <form method =" POST" use:enhance novalidate >
44+ <button type =" submit" >Submit</button >
45+ </form >
You can’t perform that action at this time.
0 commit comments