You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-2Lines changed: 9 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
<img src="https://raw.githubusercontent.com/GauBen/formgator/refs/heads/main/formgator.jpg" alt="Ali, the friendly alligator that guards your forms" width="200" height="200">
3
3
</div>
4
4
5
-
# formgator
5
+
# Formgator
6
6
7
7
A validation library for JavaScript `FormData` and `URLSearchParams` objects.
8
8
@@ -187,9 +187,16 @@ If some fields were accepted nonetheless, the `error` object will have an `accep
187
187
188
188
## Usage with SvelteKit
189
189
190
+
Formgator can be used in SvelteKit to validate form data and query parameters. Because formgator imports `@sveltejs/kit` internally, you need to bundle it with your application to avoid weird runtime behaviors:
191
+
192
+
- Move `formgator` from `dependencies` to `devDependencies` in your `package.json`.
193
+
- Add `ssr: { noExternal: ['formgator'] }` to the root of `vite.config.{js|ts}`.
194
+
195
+
This will ensure that formgator use the bundled version of `@sveltejs/kit` instead of an external one. This also means that formgator will be tree-shaken in your production build, and no longer imported from `node_modules` at runtime.
196
+
190
197
### Form actions
191
198
192
-
`formgator` exposes a SvelteKit adapter that can be used to validate form data in SvelteKit [form actions](https://kit.svelte.dev/docs/form-actions).
199
+
Formgator exposes a SvelteKit adapter that can be used to validate form data in SvelteKit [form actions](https://kit.svelte.dev/docs/form-actions).
0 commit comments