Awesome
<p align="center"> <a href="https://github.com/Mini-ghost/vorms"><img src="https://raw.githubusercontent.com/Mini-ghost/vorms/main/docs/public/logo.svg" alt="Vorms - Vue Form Validation with Composition API" width="240"> </a> <br> Vue Form Validation with Composition API </p> <p align="center"> <a href="https://www.npmjs.com/package/@vorms/core" target="__blank"><img src="https://img.shields.io/npm/v/@vorms/core?color=34A88C&label=" alt="NPM version"></a> <a href="https://vorms.mini-ghost.dev/" target="__blank"><img src="https://img.shields.io/static/v1?label=&message=docs&color=3D957F" alt="Documentations"></a> <a href="https://www.npmjs.com/package/@vorms/core" target="__blank"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/@vorms/core?color=00629E&label="></a> <br> <a href="https://github.com//Mini-ghost/vorms" target="__blank"><img alt="GitHub stars" src="https://img.shields.io/github/stars/Mini-ghost/vorms?style=social"></a> </p>Feature
- Type Strong: Written in TypeScript, with TSDoc.
- Lightweight: Only 12kb compressed (4kb compressed + gzip compressed) and fully tree-shaking.
- Easiest: Vorm uses the Composition API to give you a very seamless development experience.
- Flexible: Yup, Zod, Valibot and self-def validation are supported.
Install
npm install @vorms/core
CDN
<script src="https://unpkg.com/@vorms/core"></script>
It will be exposed to global as window.Vorms
Usage
setup script
import { useForm } from '@vorms/core'
const sugarOptions = ['no', 'light', 'half', 'standard']
const { register, handleSubmit, handleReset } = useForm({
initialValues: {
drink: '',
sugar: 'light',
},
onSubmit(data) {
console.log(data)
}
})
const { value: drink, attrs: drinkFieldAttrs } = register('drink')
const { value: sugar, attrs: sugarFieldAttrs } = register('sugar')
template
<form @submit="handleSubmit" @reset="handleReset">
<label>Drink</label>
<input v-model="drink" type="text" v-bind="drinkFieldAttrs">
<label>Sugar level</label>
<select v-model="sugar" v-bind="sugarFieldAttrs">
<option v-for="item in sugarOptions" :key="item" :value="item">
{{ item }}
</option>
</select>
<button type="reset">Reset</button>
<button type="submit">Submit</button>
</form>
Refer documentations for more details.
Examples
- Login
- Field Array
- Cross Field Validate
- Wizard Form
- Custom Components
- UI Library - Vuetify
- UI Library - Element Plus
- Validate With Yup
- Validate With Zod
Thanks
This project is heavily inspired by the following awesome projects.
Contributors
Thanks to the wonderful people who have already contributed to Vorms!
<a href="https://github.com/mini-ghost/vorms/graphs/contributors"> <img src="https://contrib.rocks/image?repo=mini-ghost/vorms" /> </a>Made with contrib.rocks.
License
MIT License © 2022-PRESENT Alex Liu