vee-validate

Template-based form validation for Vue 3 — schema validation, error messages, and field-level state with Zod/Yup integration.

vee-validate

Vue

Template-based form validation for Vue 3 — schema validation, error messages, and field-level state with Zod/Yup integration.

Fit

Bundle (gzip)

13.0 kB

43.2 kB raw

Install size includes transitive dependencies. Bundle size is gzipped browser payload.

Freshness

The Problem

Validating Vue forms means managing error state for every field, handling async validators, showing/hiding error messages at the right time, and integrating with schema validation libraries — all of which requires significant boilerplate.

What It Does

vee-validate provides useForm, useField, and <Field> / <ErrorMessage> components that track touched, dirty, and valid state per field. It integrates directly with Zod, Yup, and Valibot via adapters so your existing schema doubles as the validation logic.

Installation

bash
npm install vee-validate @vee-validate/zod zod

Usage Example

vue
<script setup lang="ts">
import { useForm } from 'vee-validate';
import { toTypedSchema } from '@vee-validate/zod';
import { z } from 'zod';

const { handleSubmit, errors } = useForm({
  validationSchema: toTypedSchema(
    z.object({ email: z.string().email(), password: z.string().min(8) })
  ),
});

const onSubmit = handleSubmit((values) => console.log(values));
</script>

<template>
  <form @submit="onSubmit">
    <Field name="email" type="email" />
    <ErrorMessage name="email" />
    <button type="submit">Login</button>
  </form>
</template>

Related packages