Introduction β
What is Regle? β
If you've ever built a forms and wrote repetitive validation logic, struggling with complex error states, or losing type safety along the way, Regle is the perfect solution.
Regle is a type-safe, headless form validation library that lets you write validation rules that mirror your data structure. Think of it as the perfect evolution of Vuelidate, but with modern TypeScript support and a more intuitive API.
Why Choose Regle? β
- π Type Safe: Full TypeScript inference means autocomplete everywhere and catch errors at compile time
- π³ Model-Based: Your validation tree matches your data modelβno mental gymnastics required
- π Headless: Works with any UI framework, CSS library, or design system
- π¦ Modular: Use built-in rules or create custom ones that fit your exact needs
- β‘ Performance: Efficient reactivity system that only updates what changed
- π Developer Experience: If you've used Vuelidate, you'll feel right at home
Basic example β
Here's a real form that you can copy and use right away:
<template>
<input
v-model='r$.$value.email'
:class="{ error: r$.email.$error }"
placeholder='Type your email'
/>
<li v-for="error of r$.$errors.email" :key='error'>
{{ error }}
</li>
</template>
<script setup lang='ts'>
import { useRegle } from '@regle/core';
import { required, minLength, email } from '@regle/rules';
const { r$ } = useRegle({ email: '' }, {
email: { required, email, minLength: minLength(4)}
})
</script>
From r$
, you can build any UI you want. The validation logic is completely separate from your presentation layer.
Live Result:
What's Next? β
Ready to dive deeper? Here's your learning path:
- Installation - Get Regle set up in your project
- Core Concepts - Understand how
useRegle
works - Built-in Rules - Explore all available validation rules
- Examples - See Regle in action with real-world scenarios
Coming from Vuelidate?
Regle's API is intentionally similar to Vuelidate's. Check out our comparison guide to see what's changed and what's stayed the same.