FormStore
Coordinates form state, validation, transforms and submission.
Table of contents
Category
Value
Import
jsimport { FormStore } from "valyrian.js/forms";Public signature
tsnew FormStore<TState extends FormState>(options: FormOptions<TState>): FormStore<TState>API form
FormStore is a class. Construct it with initial state and a schema, then bind forms through v-form and controls through v-field or call its methods directly.
Options
tstype FormOptions<TState> = {
state: TState;
schema: Record<string, unknown>;
clean?: Partial<Record<keyof TState | string, (value, state) => unknown>>;
format?: Partial<Record<keyof TState | string, (value, state) => unknown>>;
onSubmit?: (values: TState) => Promise<void> | void;
};State properties
tsreadonly state: TState
readonly validationErrors: Record<string, string>
readonly submitError: unknown
readonly success: boolean
readonly isInflight: boolean
readonly isDirty: boolean
readonly hasValidationErrors: boolean
readonly hasSubmitError: boolean
static readonly schemaShield: SchemaShieldEssential methods
tssetField(name: string, rawValue: unknown): void
formatValue(name: string, value: unknown): unknown
validate(): boolean
submit(event?: Event): Promise<boolean>
setSuccess(success: boolean, event?: Event): void
reset(): voidSubmission outcomes
submit() resolves false for validation failure, an active submission or an onSubmit error, and resolves true after success. onSubmit errors are stored in submitError. reset() restores initial state and clears validation, submission and inflight state.