yera.dsl.forms

Present structs as forms and collect validated submissions.

Symbols

def present_form — Collect a validated instance of a model through a form.

present_form

present_form(
    model_type: type[ModelT],
    label: str | None = None,
) → ModelT

Collect a validated instance of a model through a form.

Rejected submissions are echoed with their errors and the form is presented again, pre-filled with the submitted values and secrets masked, until a submission validates.

Parameters

model_type
type: type[ModelT]

Model or struct class whose fields the form presents.

label
type: str | None = None

Optional question shown above the form.

Returns

type: ModelT

The validated instance built from the accepted submission.