Skip to content

Introduction

Regle (from the French word for "rule") is a TypeScript-first form validation library made for Vue 3. I'm a lover and long-time user of Vuelidate API, so Regle's is greatly inspired by it.

Regle is about bringing type safety and great DX for both simple and complex forms. It's entirely data-driven and headless, allowing the validation logic to mirror your data structure, enabling a clear separation between the UI and validation logic.

Declare your form rules inside a component or a Pinia store and use it wherever you like.

Installation

Prerequisites

Required

Optional


sh
pnpm add @regle/core @regle/rules
sh
npm install @regle/core @regle/rules
sh
yarn add @regle/core @regle/rules
sh
bun add @regle/core @regle/rules

Quick usage

App.vue
vue
<template>
  <
input
v-model='
r$
.
$fields
.
email
.
$value
'
:
class
="{
error
:
r$
.
$fields
.
email
.
$error
}"
placeholder
='Type your email'
/> <
ul
>
<
li
v-for="
error
of
r$
.
$fields
.
email
.
$errors
"
:
key
='
error
'>
{{
error
}}
</
li
>
</
ul
>
</template> <script setup lang='ts'> import {
useRegle
} from '@regle/core';
import {
required
,
minLength
,
email
} from '@regle/rules';
const {
r$
} =
useRegle
({
email
: '' }, {
email
: {
required
,
minLength
:
minLength
(4),
email
}
}) </script>

Result:

TIP

You can jump directly to core concepts to learn usage.

Released under the MIT License. Logo by Johannes Lacourly