Skip to content

Commit b58ab2c

Browse files
committed
Added test fixed in 2.12.6
1 parent e694414 commit b58ab2c

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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>

0 commit comments

Comments
 (0)