Skip to content

Commit 923cff1

Browse files
committed
[docs] Reorder integration guides
1 parent 878fef6 commit 923cff1

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

apps/docs/src/content/docs/integrations/generic-backend.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Generic backend
33
sidebar:
4-
order: 0
4+
order: 1
55
---
66

77
import { Card, Code } from '@astrojs/starlight/components'

apps/docs/src/content/docs/integrations/sveltekit.mdx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: SvelteKit
33
sidebar:
4-
order: 1
4+
order: 2
55
---
66

77
import { Code, Tabs, TabItem } from "@astrojs/starlight/components";
@@ -37,10 +37,27 @@ even if the user has `JavaScript` disabled.
3737
On the server side you should implement at least one [action](https://svelte.dev/docs/kit/form-actions)
3838
which will always return the result of `validateForm` function (`redirect` and `error` helpers are allowed).
3939

40+
If form data is passed via `FormData` you should create a parser for it.
41+
4042
```typescript
43+
import { makeFormDataParser, validateForm } from '@sjsf/sveltekit/server';
44+
45+
const validator = createValidator();
46+
47+
const parseFormData = makeFormDataParser({
48+
validator
49+
});
50+
4151
export const actions = {
4252
default: async (event) => {
43-
const form = validateForm({/* ... */})
53+
const form = validateForm({
54+
schema,
55+
validator,
56+
data: await parseFormData({
57+
schema,
58+
request,
59+
}),
60+
})
4461
if (!form.isValid) {
4562
return fail(400, { form });
4663
}
@@ -60,6 +77,8 @@ You can use any convenient name instead of `form`
6077
If you want to populate form from database, you can use `initForm` function inside the `load` function.
6178

6279
```typescript
80+
import { initForm } from '@sjsf/sveltekit/server';
81+
6382
export const load = async () => {
6483
const data = await getData();
6584
const form = initForm({ schema, validator, initialValue: data });
@@ -78,6 +97,8 @@ The name of the `initForm` function result should match the name from the `actio
7897
On the client side you should call `useSvelteKitForm`.
7998

8099
```typescript
100+
import { useSvelteKitForm, meta } from '@sjsf/sveltekit/client';
101+
81102
import type { PageData, ActionData } from './$types';
82103

83104
const { form, mutation, enhance } = useSvelteKitForm(
@@ -132,4 +153,4 @@ it may lead to ambiguous results if the following conditions are violated:
132153
- You may produce these checks at runtime with the `staticAnalysis` and other functions from `@sjsf/form/static-analysis` submodule.
133154
Functions from this submodule returns an iterable of errors, so you can:
134155
- Throw an error on the first error or list all errors (in a dev environment)
135-
- Check if the data in the server action is correct and save the original form data if there are errors (in a production environment)
156+
- Check if the schema and id separator is correct and save the original form data if there are errors (in a production environment)

apps/docs/src/content/docs/integrations/zod.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Zod
33
sidebar:
4-
order: 2
4+
order: 0
55
---
66

77
import { Code, Card } from '@astrojs/starlight/components';

0 commit comments

Comments
 (0)