GitHub

Reference machines

formField

interface 3 type 3 function 1
interface Interfaces 3

# FieldIssue

One validation issue. Aligns with Standard Schema's Issue shape so users can pipe result.issues straight in without remapping.

Members

message
readonly message: string
path?
readonly optional path?: readonly PropertyKey[]

# FormFieldContext

Type Parameters

T

Members

dirty
dirty: boolean

True when value differs from initialValue.

errors
errors: readonly FieldIssue[]
initialValue
readonly initialValue: T
touched
touched: boolean

True once the field has lost focus at least once.

validationToken
validationToken: number

Token emitted with each VALIDATE intent. The attachment uses it to guard async resolutions so a stale validator can't overwrite fresher state. Monotonically increasing across the field's lifetime.

value
value: T
type Type Aliases 3

# FormFieldEvent

FormFieldEvent<T> = { type: "FOCUS"; } | { type: "INPUT"; value: T; } | { type: "BLUR"; } | { type: "SUBMIT_REQUEST"; } | { issues: ReadonlyArray<FieldIssue>; token: number; type: "VALIDATION_RESOLVE"; } | { reason: unknown; token: number; type: "VALIDATION_REJECT"; } | { type: "RESET"; } | { type: "SET.VALUE"; value: T; }

Type Parameters

T
function Functions 1

# createFormFieldMachine ( )

createFormFieldMachine<T>(input): FormFieldMachine<T>

Construct a fresh FormField machine.

Type Parameters

T

Parameters

Returns

FormFieldMachine<T>