All Projects → zackify → Validify

zackify / Validify

Licence: mit
Simple-as-possible React form validation

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Validify

grav-plugin-form
Grav Form Plugin
Stars: ✭ 48 (-82.29%)
Mutual labels:  form, form-validation
Formvuelar
Vue form components with server-side validation in mind
Stars: ✭ 263 (-2.95%)
Mutual labels:  form-validation, form
antd-react-form-builder
Example
Stars: ✭ 74 (-72.69%)
Mutual labels:  form, form-validation
svelte-form
JSON Schema form for Svelte v3
Stars: ✭ 47 (-82.66%)
Mutual labels:  form, form-validation
dropzone-ui-react
The most complete React Library Component for drag’n’drop files. Image and video previews. File validation. Multilanguage. Server side support.
Stars: ✭ 122 (-54.98%)
Mutual labels:  form, form-validation
ATGValidator
iOS validation framework with form validation support
Stars: ✭ 51 (-81.18%)
Mutual labels:  form, form-validation
form-data-json
A zero dependency, cross browser library to easily get or set/manipulate form input values as/from a json object.
Stars: ✭ 37 (-86.35%)
Mutual labels:  form, 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 (-11.81%)
Mutual labels:  form-validation, form
jquery.niceform
The jQuery plugin for validation and post form data to server
Stars: ✭ 16 (-94.1%)
Mutual labels:  form, form-validation
autoform
🤖📝 AutoForm is the simplest way to automatically generate fast, beautiful and standards/WCAG compliant HTML forms based on an Ecto Schema in a Phoenix Web Application to *significantly* speed up Web App Development. 🚀
Stars: ✭ 18 (-93.36%)
Mutual labels:  form, form-validation
react-inputs-validation
A react component for form inputs validation. Online demo examples
Stars: ✭ 48 (-82.29%)
Mutual labels:  form, form-validation
formalizer
React hooks based form validation made for humans.
Stars: ✭ 12 (-95.57%)
Mutual labels:  form, 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, form-validation
ember-validity-modifier
Ember Octane addon to add custom validity (form validation) to form fields
Stars: ✭ 28 (-89.67%)
Mutual labels:  form, form-validation
Final Form
🏁 Framework agnostic, high performance, subscription-based form state management
Stars: ✭ 2,787 (+928.41%)
Mutual labels:  form-validation, form
react-useForm
World's simplest React hook to manage form state
Stars: ✭ 30 (-88.93%)
Mutual labels:  form, form-validation
Material Singleinputform
A single EditText instead of a classical form. Library that implements flavienlaurent's singleinputform
Stars: ✭ 202 (-25.46%)
Mutual labels:  form-validation, form
Resolvers
📋 Validation resolvers: Zod, Yup, Joi, Superstruct, and Vest.
Stars: ✭ 222 (-18.08%)
Mutual labels:  form-validation, form
react-cool-form
😎 📋 React hooks for forms state and validation, less code more performant.
Stars: ✭ 246 (-9.23%)
Mutual labels:  form, form-validation
vue-use-form
✅ A Vue.js composition API function to validate forms
Stars: ✭ 97 (-64.21%)
Mutual labels:  form, form-validation

React Validify

single dependency, simplest way to validate and manage form state with hooks in React + React Native! With full test coverage and TS support.

Contents

Install

npm install react-validify lodash

Getting Started

This api has been carefully thought out over the past year. It's been in use on multiple React websites and React Native mobile applications. Using the library is simple. Include the Form component, and wrap your input's and submit buttons.

import Input from "./input";
import Submit from "./submit";
import { Form, rules } from "react-validify";

const { required, email } = rules;

const App = () => {
  let [values, setValues] = React.useState({
    email: "test",
    nested: { test: "this is nested" },
  });

  return (
    <Form values={values} onValues={setValues}>
      <Input name="email" rules={[required, email]} />
      <Input name="name" rules={[required]} />
      <Input name="date1" rules={[greaterThanDate2]} />
      <Input name="date2" />
      <Input name="nested.test" />
      <Submit />
    </Form>
  );
};

Add useField to your own inputs inside the Form wrapper. This allows you to use the library with any type of input field. It just needs to support a handleChange handleBlur and value prop. This is the Input component you see in the first example. Don't forget to pass the field name to the hook.

import React from "react";
import { useField, UseFieldProps } from "react-validify";

const Input = ({ name, rules }: UseFieldProps) => {
  let { handleChange, handleBlur, value, errors } = useField({ name, rules });

  return (
    <div>
      {errors ? <p>{errors[0]}</p> : null}
      <input
        name={name}
        value={value}
        onBlur={handleBlur}
        onChange={(event) => handleChange(event.target.value)}
      />
    </div>
  );
};

Add useSubmit to trigger submitting or validating:

import React from "react";
import { useSubmit } from "react-validify";

const Submit = (props) => {
  let { canSubmit, handleSubmit } = useSubmit();

  return (
    <div
      onClick={() => handleSubmit((values) => console.log("submit!", values))}
      style={{ opacity: canSubmit ? 1 : 0.5 }}
    >
      Submit Form
    </div>
  );
};
export default Submit;

The callback passed to handleSubmit will only be triggered if validation is passing.

Create rules:

const testRule: RuleFn = (value, values) =>
  value.length > values.date2.length ? "Date can't be longer" : null;

Rules get a value and values arguments. This means you can validate an input, or validate it against other form values.

Rules are guaranteed to run on a field after the first time the field is blurred, and then any time an error is present, they will run onChange.

TypeScript Support

With TS enabled, you can create a type for your form values, like so:

type Values = {
  email: string;
  date1?: string;
  name?: string;
};

Now when we use the form, it looks like this:

let [values, setValues] = useState<Values>({
    email: 'test',
  });

  return (
    <Form
      values={values}
      onValues={setValues}
    >
      <Input name="email" rules={[required, email]}/>
    </Form>
  )
}

Contributors

Thanks goes to these wonderful people (emoji key):


Zach Silveira


Ryan Castner

This project follows the all-contributors specification. Contributions of any kind welcome!

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