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
Full TypeScript signature sourced from the composable file.
Consumed interfaces
IFormProps
IFormField
IFormProvide
IValidationFieldResult
API
Parameters
Input parameters accepted by this composable.
- propsrequiredIFormProps
- Form component props: disabled, readonly, fastFail, validateOn, modelValue, rules, errorMessages, hint, messages, scrollToError.
API
Return values
Properties and methods exposed by the composable return object.
- 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
Examples
Ready-to-paste usage snippets.
Form with programmatic validation
Fast-fail form