### useForm with Initial Values Configuration
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-form.mdx
Example of configuring useForm with initial values for the form fields. This sets the starting state of the form when it is initialized.
```javascript
const { ... } = useForm({
initialValues: {
email: 'example@gmail.com',
password: 'p@$$w0rd',
}
});
```
--------------------------------
### Installation
Source: https://github.com/logaretm/vee-validate/blob/main/packages/rules/README.md
Install the @vee-validate/rules package using Yarn or npm.
```APIDOC
## Installation
Use the following commands to install the package:
### Yarn
```sh
yarn add @vee-validate/rules
```
### npm
```sh
npm install @vee-validate/rules
```
```
--------------------------------
### Initialize Project Environment
Source: https://github.com/logaretm/vee-validate/blob/main/CONTRIBUTING.md
Commands to clone the repository and install necessary dependencies using pnpm.
```shell
git clone https://github.com/logaretm/vee-validate.git
pnpm i
```
--------------------------------
### Run Documentation Locally
Source: https://github.com/logaretm/vee-validate/blob/main/CONTRIBUTING.md
Command to start the development server for the project documentation.
```shell
pnpm docs:dev
```
--------------------------------
### Install VeeValidate via Package Managers
Source: https://github.com/logaretm/vee-validate/blob/main/README.md
Commands to install the VeeValidate library into your project using common JavaScript package managers like yarn or npm.
```shell
yarn add vee-validate
npm install vee-validate --save
```
--------------------------------
### Install VeeValidate Nuxt module
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/integrations/nuxt.mdx
Commands to install the @vee-validate/nuxt package using various package managers like npm, pnpm, or yarn.
```shell
npm i @vee-validate/nuxt
pnpm add @vee-validate/nuxt
yarn add @vee-validate/nuxt
```
--------------------------------
### Install @vee-validate/i18n
Source: https://github.com/logaretm/vee-validate/blob/main/packages/i18n/README.md
Commands to install the localization package using yarn or npm package managers.
```shell
yarn add @vee-validate/i18n
npm install @vee-validate/i18n
```
--------------------------------
### Form Component Usage
Source: https://context7.com/logaretm/vee-validate/llms.txt
Demonstrates the basic setup and usage of the `
` and `` components into a Vue template. It replaces native input and form elements with VeeValidate's equivalents and sets up a simple submit handler.
```vue
```
--------------------------------
### Vee-Validate Composition API Form Setup
Source: https://github.com/logaretm/vee-validate/blob/main/packages/vee-validate/README.md
Demonstrates setting up a form using Vee-Validate's Composition API with `useForm`, `defineField`, and `handleSubmit`. It includes a basic 'required' validation rule and shows how to bind input fields and display errors.
```vue
{{ errors.field }}
```
--------------------------------
### Initialize Form Values with useForm
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/composition-api/handling-forms.mdx
Sets the starting values for form fields using the initialValues option. This prevents fields from defaulting to undefined, which can cause issues with external validators.
```javascript
const { defineInputBinds } = useForm({
initialValues: {
email: 'test@example.com',
password: 'p@$$w0rd',
},
});
```
--------------------------------
### Implement Form Validation with Composition API
Source: https://github.com/logaretm/vee-validate/blob/main/README.md
Demonstrates how to use the useForm, defineField, and handleSubmit functions to manage form state and validation logic within a Vue 3 script setup block.
```vue
{{ errors.field }}
```
--------------------------------
### Implement Dynamic Field Arrays with useFieldArray
Source: https://context7.com/logaretm/vee-validate/llms.txt
This example demonstrates how to use the useFieldArray composable to manage a list of team members. It includes validation using yup, and provides methods for pushing, removing, moving, and duplicating items in the array.
```vue
{{ errors.teamName }}
{{ errors.members }}
```
--------------------------------
### useForm with Form Name Configuration
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-form.mdx
Example of setting a custom name for the form using the name option. This name is used for identification in the Vue Devtools.
```javascript
const { ... } = useForm({
name: 'LoginForm', // Defaults to "Form"
});
```
--------------------------------
### Dynamic Field Configuration with Vee-Validate
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/composition-api/getting-started.mdx
Demonstrates how to pass a function to defineField to dynamically configure validation behavior based on field state. This example makes validation 'eager' after the first error.
```vue
```
--------------------------------
### useField with Different Validation Rule Types
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-field.mdx
Provides examples of using `useField` with various types of validation rules. This includes globally defined rules using `defineRule` (Laravel-like syntax), rule objects, simple validation functions, and Yup schemas.
```javascript
// Globally defined rules with `defineRule`, Laravel-like syntax
useField('password', 'required|min:8');
// Globally defined rules object
useField('password', { required: true, min: 8 });
// Simple validation function
useField('password', value => {
if (!value) {
return 'password is required';
}
if (value.length < 8) {
return 'password must be at least 8 characters long';
}
return true;
});
// Yup validation
useField('password', yup.string().required().min(8));
```
--------------------------------
### TypeScript Usage with useField
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-field.mdx
Shows how to leverage TypeScript with the `useField` function for type safety. The example demonstrates defining the type for the field's value and how TypeScript enforces correct type assignments during value updates and field resets.
```typescript
const { value, resetField } = useField('email', yup.string().email());
value.value = 1; // ⛔️ Error
value.value = 'test@example.com'; // ✅
resetField({
value: 1, // ⛔️ Error
});
resetField({
value: 'test@example.com', // ✅
});
```
--------------------------------
### Vee-Validate Declarative Components Form Setup
Source: https://github.com/logaretm/vee-validate/blob/main/packages/vee-validate/README.md
Illustrates form creation using Vee-Validate's declarative components, `Field` and `Form`. It shows how to register these components and apply a simple 'required' validation rule to a field, including error display.
```vue
{{ errors.field }}
```
--------------------------------
### Basic useField Usage in Vue
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-field.mdx
Demonstrates the fundamental usage of the `useField` function within a Vue component. It shows how to bind the field's value to an input element and display any validation error messages. This example uses a simple function for validation.
```vue
{{ errorMessage }}
```
--------------------------------
### Basic Usage of useFieldArray in Vue
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-field-array.mdx
Demonstrates the basic implementation of useFieldArray within a Vue component. It shows how to manage a list of dynamic fields (like URLs) in a form, allowing users to add, remove, and submit them. This example utilizes VeeValidate's Field component and form handling.
```vue
```
--------------------------------
### Basic defineField Usage for HTML Inputs (TypeScript)
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/composition-api/getting-started.mdx
Demonstrates the fundamental usage of `defineField` to get a value model and input bindings for an 'email' field. This setup automatically updates form values as the user types.
```typescript
import { useForm } from 'vee-validate';
const { defineField } = useForm();
const [email, emailAttrs] = defineField('email');
```
--------------------------------
### Build and Test Project
Source: https://github.com/logaretm/vee-validate/blob/main/CONTRIBUTING.md
Commands to build the project bundles, execute unit tests, and check test coverage.
```shell
pnpm build
pnpm test
pnpm cover
```
--------------------------------
### Implementing Renderless Forms
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/form.mdx
Shows how to set the 'as' prop to an empty string to create a renderless form, useful for custom form markup.
```vue-html
Sign up form
{{ values }}
```
--------------------------------
### Adding items with push and prepend
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-field-array.mdx
Demonstrates adding items to the end or beginning of an array using the push and prepend methods.
```javascript
const { push } = useFieldArray('links');
const myPushFunction = () => { push({ url: '' }); };
const { prepend } = useFieldArray('links');
const myPrependFunction = () => { prepend({ url: '' }); };
```
--------------------------------
### configure() Function
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/configuration.mdx
The configure function allows developers to update global settings for VeeValidate at runtime, affecting subsequent field initializations.
```APIDOC
## configure(options)
### Description
Updates the global configuration for VeeValidate. Changes take effect for new Field components and useField hooks initialized after the call.
### Parameters
#### Request Body
- **bails** (boolean) - Optional - Whether to run validations to completion or quit on the first error.
- **generateMessage** (function) - Optional - A message generator function for i18n libraries.
- **validateOnBlur** (boolean) - Optional - Trigger validation on blur event (Field component only).
- **validateOnChange** (boolean) - Optional - Trigger validation on change event (Field component only).
- **validateOnInput** (boolean) - Optional - Trigger validation on input event (Field component only).
- **validateOnModelUpdate** (boolean) - Optional - Trigger validation on model update (Field component only).
### Request Example
{
"bails": false,
"validateOnBlur": true
}
### Response
#### Success Response (void)
- Returns nothing, updates internal state.
```
--------------------------------
### Mocking Form and Field Contexts
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/testing.mdx
Demonstrates how to import injection keys and provide mocked FormContext and FieldContext objects using Vue's `provide` API.
```APIDOC
## Mocking Form and Field Contexts
This section covers the process of mocking `FormContext` and `FieldContext` objects in Vee-Validate, primarily for unit testing components that rely on these contexts via Vue's `provide/inject` API.
### Method
`provide` (Vue API)
### Endpoint
N/A (This is a client-side mocking technique)
### Parameters
N/A
### Request Example
```js
import { provide } from 'vue';
import { FormContextKey, FieldContextKey } from 'vee-validate';
// Assume MockedForm and MockedField are your custom mock objects
const MockedForm = { /* ... implementation ... */ };
const MockedField = { /* ... implementation ... */ };
provide(FormContextKey, MockedForm);
provide(FieldContextKey, MockedField);
```
### Response
N/A (This is a client-side setup, not an API response)
### Further Information
For detailed implementation of mock objects, refer to the Vee-Validate source code for the typescript interfaces of [`FormContext`](https://github.com/logaretm/vee-validate/blob/main/packages/vee-validate/src/types.ts#L145) and [`FieldContext`](https://github.com/logaretm/vee-validate/blob/main/packages/vee-validate/src/types.ts#L66).
```
--------------------------------
### Get Form Submit Count with useSubmitCount
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/composition-helpers.mdx
Returns a computed reference to the number of times the form has been submitted. This can be used for tracking submission attempts.
```javascript
import { useSubmitCount } from 'vee-validate';
const count = useSubmitCount();
count.value;
```
--------------------------------
### Build Specific Packages
Source: https://github.com/logaretm/vee-validate/blob/main/CONTRIBUTING.md
Commands to build the entire monorepo or target specific packages by their folder name.
```shell
pnpm build
pnpm build vee-validate
pnpm build rules
pnpm build zod
```
--------------------------------
### Handling Form Submissions (Native)
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/components/handling-forms.mdx
Illustrates how to configure the `Form` component for native HTML form submissions, ensuring validation before submission.
```APIDOC
## Handling Form Submissions (Native)
### Description
Configure the `
` component for native HTML form submissions. Vee-validate ensures that the form is only submitted if all fields are valid, preventing submission otherwise.
### Method
POST (or other as defined by `method` prop)
### Endpoint
`/api/users` (or as defined by `action` prop)
### Parameters
#### Form Component Props
- **method** (String) - The HTTP method for the form submission (e.g., 'post').
- **action** (String) - The URL to submit the form data to.
- **:validation-schema** (Object) - The validation schema to use for the form.
### Request Example
```vue-html
```
### Response
#### Success Response (200)
N/A (Page reload or redirect based on server response)
#### Response Example
N/A (Typically a page redirect or reload)
```
--------------------------------
### Configure @vee-validate/nuxt Module Options
Source: https://github.com/logaretm/vee-validate/blob/main/packages/nuxt/README.md
Example of configuring vee-validate Nuxt module options, including disabling auto-imports and customizing component names.
```typescript
export default defineNuxtConfig({
// ...
modules: [
//...
[
'@vee-validate/nuxt',
{
// disable or enable auto imports
autoImports: true,
// Use different names for components
componentNames: {
Form: 'VeeForm',
Field: 'VeeField',
FieldArray: 'VeeFieldArray',
ErrorMessage: 'VeeErrorMessage',
},
},
],
],
});
```
```typescript
export default defineNuxtConfig({
// ...
modules: [
//...
'@vee-validate/nuxt',
],
veeValidate: {
// disable or enable auto imports
autoImports: true,
// Use different names for components
componentNames: {
Form: 'VeeForm',
Field: 'VeeField',
FieldArray: 'VeeFieldArray',
ErrorMessage: 'VeeErrorMessage',
},
},
});
```
--------------------------------
### Get Form Validating State with useIsValidating
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/composition-helpers.mdx
Returns a computed reference to the form's current validation status. This indicates whether any fields are currently being validated.
```javascript
import { useIsValidating } from 'vee-validate';
const isValidating = useIsValidating();
isValidating.value; // true or false
```
--------------------------------
### Configure Field Options
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-field.mdx
Demonstrates passing configuration options like label and initialValue to the useField composable.
```vue
{{ errorMessage }}
```
--------------------------------
### Get Form Values with useFormValues
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/composition-helpers.mdx
Returns a computed reference to an object containing all current values of the form's fields. This is useful for accessing the complete form state.
```javascript
import { useFormValues } from 'vee-validate';
const values = useFormValues();
values.value;
```
--------------------------------
### Field Configuration Options
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-field.mdx
Configuration options available when initializing a field with useField.
```APIDOC
## Field Options
### Description
Additional configuration options to customize field behavior.
### Options
- **type** (string) - Optional - Field type (e.g., 'checkbox', 'radio').
- **label** (string) - Optional - Human-readable label for the field.
- **initialValue** (any) - Optional - The starting value of the field.
- **validateOnMount** (boolean) - Optional - Whether to validate on component mount.
- **bails** (boolean) - Optional - Whether to stop validation on the first error.
- **standalone** (boolean) - Optional - Whether the field is independent of a parent form.
- **validateOnValueUpdate** (boolean) - Optional - Whether to validate when the value changes.
- **keepValueOnUnmount** (boolean) - Optional - Whether to persist the value when the component is unmounted.
- **syncVModel** (boolean) - Optional - Whether to sync with v-model.
- **checkedValue** (any) - Optional - Value when checked (checkbox/radio only).
- **uncheckedValue** (any) - Optional - Value when unchecked (checkbox/radio only).
```
--------------------------------
### Define All Rules from @vee-validate/rules
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/global-validators.mdx
Shows how to import all available rules from the @vee-validate/rules package and define them globally in one go.
```javascript
import { defineRule } from 'vee-validate';
import { all } from '@vee-validate/rules';
Object.entries(all).forEach(([name, rule]) => {
defineRule(name, rule);
});
```
--------------------------------
### Get Field Value with useFieldValue
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/composition-helpers.mdx
Returns a computed reference to the current value of a specified form field. If no field name is provided, it attempts to find the nearest parent field.
```javascript
import { useFieldValue } from 'vee-validate';
const currentValue = useFieldValue('fieldName');
currentValue.value;
```
```javascript
import { useFieldValue } from 'vee-validate';
// Will look for the first parent that used `useField`
const currentValue = useFieldValue();
```
--------------------------------
### Get Form Submitting State with useIsSubmitting
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/composition-helpers.mdx
Returns a computed reference to the form's submission status. This is useful for disabling submit buttons or showing loading indicators during form submission.
```javascript
import { useIsSubmitting } from 'vee-validate';
const isSubmitting = useIsSubmitting();
isSubmitting.value; // true or false
```
--------------------------------
### Enable v-model Syncing with useField
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/composition-api/custom-inputs.mdx
Demonstrates how to use the syncVModel option in useField to automatically handle v-model updates, reducing boilerplate code for custom input components.
```javascript
const props = defineProps({
modelValue: String,
});
const { value, errorMessage } = useField('fieldName', undefined, {
syncVModel: true,
});
```
```javascript
const props = defineProps({
text: String,
});
const { value, errorMessage } = useField('fieldName', undefined, {
syncVModel: 'text',
});
```
--------------------------------
### Initialize Vue Component Structure
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/tutorials/basics.mdx
The base template for a Vue 3 single-file component before adding validation logic.
```vue
```
--------------------------------
### Basic Yup Schema Validation with Vee-Validate
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/components/validation.mdx
Demonstrates how to define a Yup validation schema and integrate it with the Vee-Validate Form component. This setup allows for declarative validation rules for form fields.
```javascript
const schema = yup.object({
email: yup.string().required().email(),
name: yup.string().required(),
password: yup.string().required().min(8),
});
```
```vue
```
--------------------------------
### Inserting and updating array items
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-field-array.mdx
Demonstrates how to insert a new item at a specific index and how to update an existing item's value.
```javascript
const { insert } = useFieldArray('links');
const myInsertFunction = () => { insert(1, { url: '' }); };
const { update } = useFieldArray('links');
const myUpdateFunction = () => { update(1, { url: '' }); };
```
--------------------------------
### useForm with Generic Type for Typing
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-form.mdx
Demonstrates how to use a generic type with useForm to get type information for form fields and their values. This enhances type safety for properties and methods like setErrors and setFieldValue.
```typescript
import { useForm } from 'vee-validate';
interface LoginForm {
email: string;
password: string;
}
// in your setup
const { errors } = useForm();
```
--------------------------------
### Using handleSubmit for Manual Form Submission
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/components/handling-forms.mdx
Demonstrates how to use the `handleSubmit` slot prop to manually handle form submissions. The provided callback is executed only if the form is valid.
```APIDOC
## POST /api/users (Example)
### Description
Handles form submission manually using the `handleSubmit` slot prop. The `onSubmit` function is called with form values upon successful validation.
### Method
POST
### Endpoint
/api/users (example)
### Parameters
#### Request Body
- **email** (string) - Required - The user's email address.
- **password** (string) - Required - The user's password.
### Request Example
```json
{
"email": "user@example.com",
"password": "password123"
}
```
### Response
#### Success Response (200)
- **message** (string) - A success message indicating the form was submitted.
#### Response Example
```json
{
"message": "Form submitted successfully!"
}
```
```
--------------------------------
### Define Rules with Arguments
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/global-validators.mdx
Demonstrates creating global rules that accept parameters, such as a minLength rule, by accessing the second argument of the validator function.
```javascript
import { defineRule } from 'vee-validate';
defineRule('minLength', (value, [limit]) => {
if (!value || !value.length) {
return true;
}
if (value.length < limit) {
return `This field must be at least ${limit} characters`;
}
return true;
});
```
--------------------------------
### Handling File Inputs with Vee-Validate - Vue
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/components/validation.mdx
Example of how to handle file inputs with Vee-Validate, specifically addressing the limitations of two-way binding for file values. It demonstrates listening to specific events like 'change' and 'blur'.
```vue
```
--------------------------------
### VeeValidate: Field Validation with Custom Function
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/composition-api/custom-inputs.mdx
Provides an example of using a custom validation function with VeeValidate's `useField`. This approach offers flexibility for complex or unique validation logic that may not fit standard schema libraries.
```vue
{{ errorMessage }}
```
--------------------------------
### Apply Rules with Arguments
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/global-validators.mdx
Shows how to pass arguments to global rules in the Field component using the colon syntax, including multiple comma-separated arguments.
```vue-html
```
--------------------------------
### useForm with Initial Touched Status Configuration
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-form.mdx
Shows how to configure the initial touched status for form fields using the initialTouched option. This allows pre-setting which fields are considered touched upon mounting.
```javascript
const { ... } = useForm({
initialTouched: {
email: true, // touched
password: false, // non-touched
}
});
```
--------------------------------
### Set Initial Form Values with Vee-Validate
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/components/handling-forms.mdx
Utilize the `initialValues` prop on the `
` component to provide starting values for form fields. This prop accepts an object where keys are field names and values are their initial states. Initial validation will be triggered.
```vue
```
--------------------------------
### FieldArray Component Usage Example
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/field-array.mdx
Demonstrates how to use the FieldArray component to manage a list of URL fields. It includes adding, removing, and submitting array data. The component requires a parent Form and uses v-slot to access manipulation functions.
```vue
```
--------------------------------
### Initialize useFieldArray with Array Path
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/composition-api/nested-objects-and-arrays.mdx
Demonstrates how to initialize the `useFieldArray` composable by providing the root path to the array within the form's state. This path can use dot notation for nested objects or indices for arrays.
```javascript
const { remove, push, fields } = useFieldArray('users');
```
```javascript
const { remove, push, fields } = useFieldArray('settings.dns.domains');
```
--------------------------------
### useField Value Binding and Update (JavaScript)
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-field.mdx
Demonstrates how to access and update the field's value using the `value` ref and the `setValue` method. It also shows how to bind the value with `v-model` for two-way data binding and validation.
```javascript
const { value } = useField('field', value => !!value);
value.value = 'hello world'; // sets the value and validates the field
```
```javascript
const { setValue } = useField('field', value => !!value);
setValue('hello world') // sets the value and validates the field
```
--------------------------------
### Resetting Form with Initial Values
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-form.mdx
Demonstrates how to reset form values to a specified set of initial values using the `resetForm` function. It explains the default merge behavior and how to force a complete overwrite of all fields.
```javascript
const { resetForm } = useForm();
function onSubmit(values) {
// send values to the API
// ...
// Reset the form values
resetForm({
values: {
firstName: '',
lastName: '',
email: '',
password: '',
},
});
}
```
```javascript
const { values, resetForm } = useForm({
initialValues: { fname: '123', lname: '456' },
});
// values: { fname: 'test', lname: '456' }
resetForm({ values: { fname: 'test' } });
// values: { fname: 'test' }
resetForm({ values: { fname: 'test' } }, { force: true });
```
--------------------------------
### Field Reset Functionality (JavaScript)
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/api/use-field.mdx
Details the `resetField` and `handleReset` methods for resetting a field's validation state. `resetField` is more flexible, allowing partial state updates, while `handleReset` is a safe event handler alternative. Examples cover resetting meta, value, and errors.
```javascript
const { resetField } = useField('field', value => !!value);
// reset the field meta and its initial value and clears errors
resetField();
// reset the meta state, clears errors and updates the field value and its initial value
resetField({
value: 'new value',
});
// resets the meta state, resets the field to its initial value and sets the errors
resetField({
errors: ['bad field'],
});
// Marks the field as touched, while resetting its value and errors.
resetField({
touched: true,
});
// Changes the meta, initial and current values and sets the errors for the field
resetField({
value: 'new value',
touched: true,
errors: ['bad field'],
});
```
```vue
```
```javascript
const { handleReset } = useField('field', value => !!value);
// reset the field validation state and its initial value
handleReset();
```
--------------------------------
### Basic Custom Checkbox Integration with Vee-Validate
Source: https://github.com/logaretm/vee-validate/blob/main/docs/src/pages/guide/composition-api/custom-inputs.mdx
Provides a basic example of integrating a custom checkbox component with Vee-Validate. It demonstrates using the `handleChange` function returned by `useField` for managing checkbox state changes, which correctly handles toggling values and array management for checkbox groups.
```vue
```
--------------------------------
### useForm Composable
Source: https://context7.com/logaretm/vee-validate/llms.txt
Demonstrates how to use the `useForm` composable to manage form state, define validation schemas, and handle form submission with vee-validate.
```APIDOC
## useForm Composable
### Description
The `useForm` composable provides a flexible way to manage form state, including field values, validation errors, and submission status. It integrates with validation schema libraries like Yup.
### Method
Composable function
### Endpoint
N/A (Client-side composable)
### Parameters
#### Configuration Options
- **validationSchema** (object) - Required - The validation schema for the form (e.g., Yup schema).
- **initialValues** (object) - Optional - The initial values for the form fields.
#### Returned Values
- **defineField**: Function to define a form field, returning a model and props.
- **handleSubmit**: Function to handle form submission, including validation.
- **errors**: Object containing validation errors for each field.
- **values**: Object containing the current form field values.
- **meta**: Object containing form meta information (valid, dirty, touched).
- **resetForm**: Function to reset the form to its initial state.
- **setFieldError**: Function to manually set an error for a specific field.
- **setErrors**: Function to set multiple errors for fields.
- **setFieldValue**: Function to manually set the value of a field.
- **setValues**: Function to set multiple field values.
- **validate**: Function to manually trigger form validation.
- **isSubmitting**: Boolean indicating if the form is currently being submitted.
### Request Example
```javascript
// Inside a Vue component's