-
Notifications
You must be signed in to change notification settings - Fork 0
/
+page.svelte
35 lines (30 loc) · 993 Bytes
/
+page.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<script lang="ts" context="module">
import { validateSchema } from "@felte/validator-zod";
import { z } from "zod";
import { createForm } from "felte";
</script>
<script lang="ts">
const schema = z.object({
email: z.string().email(),
'traits.email': z.string().email(),
password: z.string()
});
const { form, errors } = createForm({
onSubmit: (values) => {
// ...
},
validate: validateSchema(schema)
});
</script>
{console.log(JSON.stringify($errors))}
<form use:form>
<!-- This works as expected -->
<input type="text" name="email" />
{($errors['email'] ?? []).join("")}
<!-- When the name of the field contains dot, This does not work. The errors object was incorrectly broken down -->
<!-- {"email":null,"traits":{"email":null},"password":null} -->
<input type="text" name="traits.email" />
{($errors['traits.email'] ?? []).join("")}
<input type="password" name="password" />
<button type="submit">Sign In</button>
</form>