Giter VIP home page Giter VIP logo

vorms's Introduction

Vorms - Vue Form Validation with Composition API
Vue Form Validation with Composition API

NPM version Documentations NPM Downloads
GitHub stars

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', '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

Thanks

This project is heavily inspired by the following awesome projects.

Contributors

Thanks to the wonderful people who have already contributed to Vorms!

Made with contrib.rocks.

License

MIT License © 2022-PRESENT Alex Liu

vorms's People

Contributors

mini-ghost avatar noah4520 avatar rock070 avatar smonist avatar reslear avatar sp0033212000 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.