All Projects → Albert-Gao → veasy

Albert-Gao / veasy

Licence: MIT license
A comprehensive react form solution which aims to eliminate all tedious logic.

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to veasy

Resolvers
📋 Validation resolvers: Zod, Yup, Joi, Superstruct, and Vest.
Stars: ✭ 222 (+616.13%)
Mutual labels:  form
Final Form
🏁 Framework agnostic, high performance, subscription-based form state management
Stars: ✭ 2,787 (+8890.32%)
Mutual labels:  form
react-input
A single component for building forms in React
Stars: ✭ 44 (+41.94%)
Mutual labels:  form
React Hooks Helper
A custom React Hooks library that gives you custom hooks for your code.
Stars: ✭ 227 (+632.26%)
Mutual labels:  form
Fui
Add CLI & form interface to your program. Docs: https://docs.rs/fui
Stars: ✭ 244 (+687.1%)
Mutual labels:  form
react-plough
A library to help tend your react form fields
Stars: ✭ 31 (+0%)
Mutual labels:  form
Vue Dynamic Form Component
Vue dynamic nested form component, support nested Object/Hashmap/Array. Vue动态多级表单组件,支持嵌套对象/Hashmap/数组。
Stars: ✭ 220 (+609.68%)
Mutual labels:  form
form-bunch
Form-bunch is a component like plugin that make it easier to write form, you could add the most of components what you want to form-bunch for build various form.
Stars: ✭ 18 (-41.94%)
Mutual labels:  form
Django Bootstrap Modal Forms
A Django plugin for creating AJAX driven forms in Bootstrap modal.
Stars: ✭ 244 (+687.1%)
Mutual labels:  form
react-apollo-form
Build React forms based on GraphQL APIs.
Stars: ✭ 195 (+529.03%)
Mutual labels:  form
Jh flutter demo
a flutter demo
Stars: ✭ 229 (+638.71%)
Mutual labels:  form
Form bloc
🔥 Dart and Flutter Package 🔥 Easy Form State Management using BLoC pattern 🔥 Wizard/stepper forms, asynchronous validation, dynamic and conditional fields, submission progress, serialization and more! 🔥
Stars: ✭ 239 (+670.97%)
Mutual labels:  form
WP-Media-Uploader
Easily create a custom media upload button in WordPress admin dashboard that you can use in your plugin
Stars: ✭ 25 (-19.35%)
Mutual labels:  form
Learn To Send Email Via Google Script Html No Server
📧 An Example of using an HTML form (e.g: "Contact Us" on a website) to send Email without a Backend Server (using a Google Script) perfect for static websites that need to collect data.
Stars: ✭ 2,718 (+8667.74%)
Mutual labels:  form
antd-form-mate
📦 基于 ant design 的表单组件,配置化实现表单功能。
Stars: ✭ 14 (-54.84%)
Mutual labels:  form
Simple React Form
The simplest way to handle forms in React
Stars: ✭ 224 (+622.58%)
Mutual labels:  form
Vue Form Json Schema
Create forms using JSON schema. Bring your components!
Stars: ✭ 253 (+716.13%)
Mutual labels:  form
mobx-react-form-devtools
DevTools for MobX React Form
Stars: ✭ 30 (-3.23%)
Mutual labels:  form
musicWebTemplate
Free website template built for musicians / artists to promote their music and connect to their audience.
Stars: ✭ 26 (-16.13%)
Mutual labels:  form
elderform
💪🏽 Form creation made easy, backed by state machines
Stars: ✭ 30 (-3.23%)
Mutual labels:  form

Veasy.js

Veasy.js

npm version npm Build Status Coverage Status

A comprehensive react form solution which aims to eliminate all tedious logic.

Documentation

Features

  • Field validation (We handle the validation logic!)
  • Form status (check whether all fields ready or not)
  • Generate initial state with default value
  • Get fields value for submitting
  • Auto update fields props according to validation result
  • Auto binding fields props
  • Support chaining validation, field A reliesOn field B with different rules
  • onBlur: trigger validation automatically
  • onChange: trigger validation automatically
  • onReset: reset form to default state
  • Need more features? Raise an issue :)

Why use

  • Declarative way to define your validation rule
  • Comprehensive validation rule set and easy to extend
  • Progressive validation mechanism.
  • Highly customizable: error message, default state, whatever you want.
  • Clean JSX hierarchy, use your own field item component.
  • Promise based architecture.
  • Handle all the tedious logic without learning too much.

Install

npm install --save veasy

A quick 2 steps how to

Suppose you have a form field component:

<FieldItem name="title" />

Step 1: You can write a schema using json

import VeasyForm, {createInitialState} from 'veasy';

// `title` here should match the name of the field
const formSchema = {
  title: {
    minLength: 10,
    maxLength: 20,
    exclude: 'bad words'
  }
};

// Then setup the initial state in the component's constructor
// Find out add your own state in the doc
this.state = createInitialState(formSchema);

Step 2: Auto bind the props

Then wrap using our <VeasyForm> component:

<VeasyForm
  schema={formSchema}
  allState={this.state}
  update={(fieldState) => {this.setState(fieldState);}}
>
  <FieldItem name="title" />
</VeasyForm>

Congrats! Now you automatically get the following features:

  1. Your FieldItem will get the following props at runtime:
    • status: For changing the look, ('normal', 'ok' and 'error')
    • errorText: For showing the error message.
    • value: Like how you bind the value for every controlled component :)
    • onChange: A change handler for handling the validation when user changing the value.
  2. Anytime the user changes something, the above 3 props will auto updated by Veasy
  3. OnChange and onBlur will auto trigger the validation as well.
  4. isFormOK will be true when all fields's status equals to ok.
  5. onReset has been handled for resetting the state to initial state, you just need to add a plain form reset button ( < button type='reset' > ).

There is even a getFieldsValue() method for you to get all the fields value, even you don't include all the fields in the schema, we cover that case for you :)

Check the working code example at here.

Tip: There is an extra isFormOK prop at the root level of state to indicate the status of the form according to all the fields defined in the schema.

Now you get it! Let's take several minutes to go through our documentation.

Chaining rules and Progressive validation mechanism

  • Rules in schema are processed one-by-one.
  • Unless the value passes the first rule, Veasy won't bother checking the next.

Many forms in the wild display all errors at once, which can be many! That's scary!

Instead, we guide the user through the form by validating each rule one-by-one. As a very simple example, consider this field which expects an int, min and max.

Your schema is like this:

{
  age: {
    isInt: true,
    min: [16, 'should be older than 16'],
    max: 99
  }
}

If the user enters one, veasy will stop at first rule and let the user know that it should be a number. If they then enter 1, veasy will inform them that they should be older than 16, and so on until all rules are valid.

This example is simple, you can chain all the rules to build your own. And thanks to React, it all happens immediately. All you need to do is to declare a schema.

Gitter channel

https://gitter.im/veasyjs/Lobby

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].