function / @typed/ui/Form

StateSchema

Builds the serializable schema for a form’s hydrated state.

Learn this UI primitive →

Package version
1.0.0-beta.13
Category
Hydration schemas
Since
1.0.0

Import

import { StateSchema } from "@typed/ui/Form";

Signatures

export declare function StateSchema<const Fields extends FormFields>(codec: Schema.Struct<Fields>): Schema.Struct<{
    readonly values: Schema.Struct<Fields>;
    readonly defaultValues: Schema.Struct<Fields>;
    readonly errors: Schema.Struct<OptionalFields<Fields, Schema.String>>;
    readonly meta: Schema.Struct<OptionalFields<Fields, Schema.Struct<{
        readonly dirty: Schema.Boolean;
        readonly touched: Schema.Boolean;
    }>>>;
    readonly submitting: Schema.Boolean;
}>;

Examples

import { StateSchema } from "@typed/ui/Form"
import { Schema } from "effect"

const codec = Schema.Struct({ email: Schema.String })
const stateCodec = StateSchema(codec)

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source