All Projects → llauderesv → react-form-validation

llauderesv / react-form-validation

Licence: MIT license
A simple and declarative way to validate your forms in React

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects
shell
77523 projects

Projects that are alternatives of or similar to react-form-validation

Validator
HTML form validation. Perfectly made for all scenerios, lightweight, semantic & easy to use
Stars: ✭ 209 (+770.83%)
Mutual labels:  form-validation
formz
A unified form representation in Dart used at Very Good Ventures 🦄
Stars: ✭ 262 (+991.67%)
Mutual labels:  form-validation
recaptcha2
Easy verifier for google reCAPTCHA version 2 for Node.js and Express.js
Stars: ✭ 48 (+100%)
Mutual labels:  form-validation
Resolvers
📋 Validation resolvers: Zod, Yup, Joi, Superstruct, and Vest.
Stars: ✭ 222 (+825%)
Mutual labels:  form-validation
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 (+895.83%)
Mutual labels:  form-validation
FrontendForms
A module for ProcessWire CMS to create and validate forms on the frontend easily using the Valitron library.
Stars: ✭ 0 (-100%)
Mutual labels:  form-validation
Material Singleinputform
A single EditText instead of a classical form. Library that implements flavienlaurent's singleinputform
Stars: ✭ 202 (+741.67%)
Mutual labels:  form-validation
FilterInputJs
Tiny and Powerful Library for limit an entry (text box,input) as number,string or more...
Stars: ✭ 37 (+54.17%)
Mutual labels:  form-validation
Final Form
🏁 Framework agnostic, high performance, subscription-based form state management
Stars: ✭ 2,787 (+11512.5%)
Mutual labels:  form-validation
ATGValidator
iOS validation framework with form validation support
Stars: ✭ 51 (+112.5%)
Mutual labels:  form-validation
Validate
A lightweight form validation script.
Stars: ✭ 227 (+845.83%)
Mutual labels:  form-validation
Svelte Forms Lib
📝. A lightweight library for managing forms in Svelte
Stars: ✭ 238 (+891.67%)
Mutual labels:  form-validation
Frontend-Learning-Journey
Tutorials, definitions, frameworks and some of the projects i made when starting to learn frontend web developement
Stars: ✭ 28 (+16.67%)
Mutual labels:  form-validation
Bouncer
A lightweight form validation script that augments native HTML5 form validation elements and attributes.
Stars: ✭ 224 (+833.33%)
Mutual labels:  form-validation
envalid
Envalid is a framework agnostic and fluent server side form validation package for PHP
Stars: ✭ 23 (-4.17%)
Mutual labels:  form-validation
Documentation
📋 Official documentation/website
Stars: ✭ 202 (+741.67%)
Mutual labels:  form-validation
laminas-form
Validate and display simple and complex forms, casting forms to business objects and vice versa
Stars: ✭ 65 (+170.83%)
Mutual labels:  form-validation
ember-validity-modifier
Ember Octane addon to add custom validity (form validation) to form fields
Stars: ✭ 28 (+16.67%)
Mutual labels:  form-validation
vue-formly-buefy
The declarative way to create and validate forms.
Stars: ✭ 18 (-25%)
Mutual labels:  form-validation
react-inputs-validation
A react component for form inputs validation. Online demo examples
Stars: ✭ 48 (+100%)
Mutual labels:  form-validation

React useForm Hooks

A simple and declarative way to validate your forms in React.

Example usage

Create your stateSchema

Your stateSchema is an object key value-pair contains the value of an input and the current error if any.

const stateSchema = {
  first_name: { value: '', error: '', },
  last_name: { value: '', error: '', },
  tags: { value: '', error: '',  },
};

Create validation in your stateSchema

Property should be the same in your stateSchema in-order validation works. validator prop accepts a func that you can be use to validate your state via regEx.

const stateValidatorSchema = {
  first_name: {
    required: true,
    validator: {
      func: value => /^[a-zA-Z]+$/.test(value),
      error: 'Invalid first name format.',
    },
  },
  last_name: {
    required: true,
    validator: {
      func: value => /^[a-zA-Z]+$/.test(value),
      error: 'Invalid last name format.',
    },
  },
  tags: {
    required: true,
    validator: {
      func: value => /^(,?\w{3,})+$/.test(value),
      error: 'Invalid tag format.',
    },
  },
};

Passed your stateSchema and stateValidatorSchema in useForm hooks. 3rd parameter is (optional) callback function to be called when you submit your form if all fields is valid.

const { 
   values, 
   errors, 
   handleOnChange, 
   handleOnSubmit, 
   disable 
 } = useForm(stateSchema, stateValidatorSchema, onSubmitForm);

Demo

Working demo here.

Contributing

Feel free to contribute in this project.

License

This project is under MIT License.

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].