Skip to content

Commit 8553d70

Browse files
committed
Test updated
1 parent 0c262c5 commit 8553d70

File tree

2 files changed

+39
-36
lines changed

2 files changed

+39
-36
lines changed

src/routes/(v2)/v2/issue-484/+page.svelte

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,40 @@
33
import { schemasafe } from '$lib/adapters/schemasafe.js';
44
import { loginJSONSchema } from './schemas.js';
55
6-
const { form, errors, message, enhance } = superForm(defaults(schemasafe(loginJSONSchema)), {
7-
SPA: true,
8-
validators: schemasafe(loginJSONSchema),
9-
onUpdate({ form }) {
10-
if (form.valid) {
11-
// TODO: Call an external API with form.data, await the result and update form
12-
}
13-
}
14-
});
6+
const { form, errors, message, constraints, enhance } = superForm(defaults(schemasafe(loginJSONSchema)), {
7+
SPA: true,
8+
validators: schemasafe(loginJSONSchema),
9+
onUpdate({ form }) {
10+
if (form.valid) {
11+
// TODO: Call an external API with form.data, await the result and update form
12+
}
13+
}
14+
});
1515
</script>
1616

1717
<h1>Edit user</h1>
1818

1919
{#if $message}<h3>{$message}</h3>{/if}
2020

2121
<form method="POST" use:enhance>
22-
<label>
23-
Name<br />
24-
<input aria-invalid={$errors.name ? 'true' : undefined} bind:value={$form.name} />
25-
</label>
26-
{#if $errors.name}<span class="invalid">{$errors.name}</span>{/if}
22+
<label>
23+
Name<br />
24+
<input
25+
aria-invalid={$errors.name ? 'true' : undefined}
26+
bind:value={$form.name}
27+
{...$constraints.name} />
28+
</label>
29+
{#if $errors.name}<span class="invalid">{$errors.name}</span>{/if}
2730

28-
<label>
29-
E-mail<br />
30-
<input
31-
type="email"
32-
aria-invalid={$errors.email ? 'true' : undefined}
33-
bind:value={$form.email}
34-
/>
35-
</label>
36-
{#if $errors.email}<span class="invalid">{$errors.email}</span>{/if}
37-
<br />
38-
<button>Submit</button>
39-
</form>
31+
<label>
32+
E-mail<br />
33+
<input
34+
type="email"
35+
aria-invalid={$errors.email ? 'true' : undefined}
36+
bind:value={$form.email}
37+
{...$constraints.email} />
38+
</label>
39+
{#if $errors.email}<span class="invalid">{$errors.email}</span>{/if}
40+
<br />
41+
<button>Submit</button>
42+
</form>

src/routes/(v2)/v2/issue-484/schemas.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import { z } from 'zod';
22
import type { JSONSchema } from '$lib/index.js';
33

44
export const loginZodSchema = z.object({
5-
name: z.string().min(5).default('Superform'),
6-
email: z.string().email()
5+
name: z.string().min(5).default('Superform'),
6+
email: z.string().email()
77
});
88

99
export const loginJSONSchema = {
10-
type: 'object',
11-
properties: {
12-
name: { type: 'string', minLength: 5, default: 'Superform' },
13-
email: { type: 'string', format: 'email' }
14-
},
15-
required: ['name', 'email'],
16-
additionalProperties: false,
17-
$schema: 'http://json-schema.org/draft-07/schema#'
10+
type: 'object',
11+
properties: {
12+
name: { type: 'string', minLength: 5, default: 'Superform' },
13+
email: { type: 'string', format: 'email' }
14+
},
15+
required: ['name', 'email'],
16+
additionalProperties: false,
17+
$schema: 'http://json-schema.org/draft-07/schema#'
1818
} as const satisfies JSONSchema;

0 commit comments

Comments
 (0)