Invalid
Fail form submissions with typed, field-addressed validation errors.Every Form handler receives an invalid proxy next to the validated data. Calling a path on the proxy produces an Effect that fails with a
typed FormError addressed to that exact field, which SvelteKit routes back
to the form as a field issue.
Reject a field
items.remote.ts
import { Form } from "svelte-effect-runtime";
import { Effect, Schema } from "effect";
export const CreateItem = Form(ItemSchema, ({ data, invalid }) =>
Effect.gen(function* () {
if (data.items[0]?.label === "blocked") {
return yield* invalid.items[0]!.label("Blocked labels are rejected.");
}
return { message: `saved:${data.name}` };
}),
);The proxy mirrors the shape of the validated input, so paths are fully typed: invalid.email("Use an email address.") for a flat field, invalid.items[0]!.label("...") for nested collections. The produced
failure lands on the Form's error channel as a FormError, and the message
appears on the matching field in the browser.
On this page