Skip to content

About

A library for using Effect with forms.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

effect-forms

Framework-neutral, Effect-native form validation and state, plus Svelte 5 (runes) bindings. Validation, nested errors, posted-value retention and native input constraints all derive from one Effect Schema, shared by server and browser.

Caution

Experimental and pre-1.0, largely written with Claude Code. The API may change between minor versions.

Install

pnpm add @thomasfosterau/effect-forms @thomasfosterau/effect-ext effect
pnpm add @thomasfosterau/effect-forms-svelte svelte   # Svelte bindings

effect, @thomasfosterau/effect-ext and svelte are peers: keep a single copy of each in your app.

Usage

import * as Effect from "effect/Effect";
import * as Schema from "effect/Schema";
import { Form } from "@thomasfosterau/effect-forms";

const Signup = Schema.Struct({ name: Schema.String.check(Schema.isMinLength(2)) });
const signupForm = Form.make(Signup, { id: "signup", defaults: { name: "" } });

const state = await Effect.runPromise(signupForm.validate(new URLSearchParams({ name: "A" })));
// state.isValid === false; state.errors.name holds the message; state.data keeps what was posted.

In a component, createForm(state, { schema: Signup }) from the Svelte bindings turns that state into a reactive store with progressive enhancement and client-side validation.

Packages

Package What it is
@thomasfosterau/effect-forms The framework-neutral core: validation, error trees, coercion, constraints
@thomasfosterau/effect-forms-svelte Svelte 5 runes bindings: form store, enhance action, tainted tracking; /kit for SvelteKit

More

MIT © Thomas Foster

About

A library for using Effect with forms.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages