Skip to content

Commit 8cd97c1

Browse files
committed
Typebox bump to 0.34.9
Fixes #511
1 parent 75086f4 commit 8cd97c1

File tree

7 files changed

+96
-8
lines changed

7 files changed

+96
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- All properties for object unions weren't added to the adapter defaults.
1313

14+
### Changed
15+
16+
- Typebox updated to require `^0.34.9` (hoping for a stable release soon).
17+
1418
## [2.20.1] - 2024-11-15
1519

1620
### Changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"peerDependencies": {
105105
"@effect/schema": "^0.75.3",
106106
"@exodus/schemasafe": "^1.3.0",
107-
"@sinclair/typebox": ">=0.32.30 <1",
107+
"@sinclair/typebox": "^0.34.9",
108108
"@sveltejs/kit": "1.x || 2.x",
109109
"@typeschema/class-validator": "^0.3.0",
110110
"@vinejs/vine": "^1.8.0 || ^2.0.0",
@@ -163,7 +163,7 @@
163163
"@effect/schema": "^0.75.3",
164164
"@exodus/schemasafe": "^1.3.0",
165165
"@gcornut/valibot-json-schema": "^0.31.0",
166-
"@sinclair/typebox": "^0.32.35",
166+
"@sinclair/typebox": "^0.34.9",
167167
"@typeschema/class-validator": "^0.3.0",
168168
"@vinejs/vine": "^2.0.0",
169169
"arktype": "^2.0.0-rc.23",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/routes/(v2)/v2/Navigation.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
'issue-485',
7272
'arktype',
7373
'effect',
74-
'issue-500'
74+
'issue-500',
75+
'typebox'
7576
].sort();
7677
</script>
7778

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { typebox } from '$lib/adapters/typebox.js';
2+
import { message, superValidate } from '$lib/server/index.js';
3+
import { schema } from './schema.js';
4+
import { fail } from '@sveltejs/kit';
5+
6+
export const load = async () => {
7+
const form = await superValidate(typebox(schema));
8+
return { form };
9+
};
10+
11+
export const actions = {
12+
default: async ({ request }) => {
13+
const formData = await request.formData();
14+
console.log(formData);
15+
16+
const form = await superValidate(formData, typebox(schema));
17+
console.log(form);
18+
19+
if (!form.valid) return fail(400, { form });
20+
21+
return message(form, 'Posted OK!');
22+
}
23+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<script lang="ts">
2+
import { superForm } from '$lib/client/index.js';
3+
import SuperDebug from '$lib/client/SuperDebug.svelte';
4+
import { typeboxClient } from '$lib/adapters/typebox.js';
5+
import { schema } from './schema.js';
6+
7+
export let data;
8+
9+
const { form, errors, tainted, message, enhance } = superForm(data.form, {
10+
taintedMessage: false,
11+
validators: typeboxClient(schema)
12+
//dataType: 'json',
13+
});
14+
</script>
15+
16+
<SuperDebug data={{ $form, $errors, $tainted }} />
17+
18+
{#if $message}<h4>{$message}</h4>{/if}
19+
20+
<form method="POST" use:enhance>
21+
<label>
22+
Name: <input
23+
name="name"
24+
bind:value={$form.name}
25+
aria-invalid={$errors.name ? 'true' : undefined}
26+
/>
27+
{#if $errors.name}<span class="invalid">{$errors.name}</span>{/if}
28+
</label>
29+
<label>
30+
Email: <input
31+
name="email"
32+
bind:value={$form.email}
33+
aria-invalid={$errors.email ? 'true' : undefined}
34+
/>
35+
{#if $errors.email}<span class="invalid">{$errors.email}</span>{/if}
36+
</label>
37+
<div>
38+
<button>Submit</button>
39+
</div>
40+
</form>
41+
42+
<style lang="scss">
43+
form {
44+
margin: 2rem 0;
45+
46+
input {
47+
background-color: #dedede;
48+
}
49+
50+
.invalid {
51+
color: crimson;
52+
}
53+
}
54+
</style>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Type } from '@sinclair/typebox';
2+
3+
export const schema = Type.Object({
4+
name: Type.String({ minLength: 2 }),
5+
email: Type.String({ format: 'email' })
6+
});

0 commit comments

Comments
 (0)