Skip to content

Commit 66f6934

Browse files
committed
Fixed FormPathArrays test.
1 parent 216b546 commit 66f6934

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

src/routes/tests/array-component/+page.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export const actions = {
1313
console.log(formData);
1414

1515
const form = await superValidate(formData, schema);
16-
console.log('POST', form);
16+
console.dir(form, { depth: 5 });
1717

1818
if (!form.valid) return fail(400, { form });
1919

20-
return message(form, 'Posted OK!');
20+
return message(form, 'OK:' + form.data.sub.tags);
2121
}
2222
};

src/routes/tests/array-component/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
export let data: PageData;
88
99
const pageForm = superForm(data.form, {
10-
//dataType: 'json',
10+
dataType: 'json'
1111
//validators: schema
1212
});
1313
const { form, errors, message, enhance } = pageForm;
@@ -23,7 +23,7 @@
2323
{#if $message}<h4>{$message}</h4>{/if}
2424

2525
<form method="POST" use:enhance>
26-
<AutoComplete form={pageForm} field="tags2" {options} />
26+
<AutoComplete form={pageForm} field="sub.tags" {options} />
2727
<div>
2828
<button>Submit</button>
2929
</div>
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { z } from 'zod';
22

33
export const schema = z.object({
4-
tags: z.string().min(1).array().min(1),
5-
tags2: z
6-
.object({
7-
id: z.number().int(),
8-
name: z.string().min(1)
9-
})
10-
.array()
11-
.min(1)
4+
sub: z.object({
5+
tags: z.string().min(1).array().min(1)
6+
})
127
});

0 commit comments

Comments
 (0)