useForm

Form
stable

Orchestrates form-level validation by aggregating results from all child field components. Registers/unregisters fields automatically via provide/inject, tracks the overall valid state as a v-model:modelValue, and exposes validate(), reset(), and resetValidation() methods.

API

Signature

Signature TypeScript complète extraite du fichier du composable.

typescript

Interfaces consommées

IFormProps
IFormField
IFormProvide
IValidationFieldResult

API

Paramètres

Paramètres d'entrée acceptés par ce composable.

props
requis
IFormProps
Form component props: disabled, readonly, fastFail, validateOn, modelValue, rules, errorMessages, hint, messages, scrollToError.

API

Valeurs de retour

Propriétés et méthodes exposées par l'objet retourné par le composable.

isValid
Bound to v-model:modelValue. true = all fields valid, false = at least one invalid, null = indeterminate (some fields not yet validated).
errors
Array of { id, errorMessages } for each field that failed the last validate() call.
isDisabled
Propagated down to all child fields via inject. When true, every registered field is disabled.
isReadonly
Propagated down to all child fields via inject. When true, every registered field is read-only.
isValidating
True while the async validate() loop is running. Use to show a loading indicator.
items
Live list of all registered child fields with their current isValid state and errorMessages.
validate
Triggers validation on every registered field sequentially (respects fastFail). Returns the aggregate result.
reset
Calls reset() on all registered fields, clearing their values and validation state.
resetValidation
Calls resetValidation() on all registered fields — clears error messages without resetting values.

Usage

Exemples

Extraits de code prêts à coller.

Form with programmatic validation

vue

Fast-fail form

vue