Code Monkey home page Code Monkey logo

conform's Introduction

Conform · latest release GitHub license

Conform is a form validation library built on top of the Constraint Validation API.

  • Progressive Enhancement: It is designed based on the HTML specification. From validating the form to reporting error messages for each field, if you don't like part of the solution, just replace it with your own.
  • Framework Agnostic: The DOM is the only dependency. Conform makes use of native Web APIs exclusively. You don't have to use React / Vue / Svelte to utilise this library.
  • Flexible Setup: It can validates fields anywhere in the dom with the help of form attribute. Also enables CSS pseudo-classes like :valid and :invalid, allowing flexible styling across your form without the need to manipulate the class names.

Quick start

import { useForm, useFieldset } from '@conform-to/react';

export default function LoginForm() {
  const formProps = useForm({
    onSubmit(event) {
      event.preventDefault();

      const formData = new FormData(event.currentTarget);
      const value = Object.fromEntries(formData);

      console.log(value);
    },
  });
  const { email, password } = useFieldset(formProps.ref);

  return (
    <form {...formProps}>
      <label>
        <div>Email</div>
        <input type="email" name="email" required />
        <div>{email.error}</div>
      </label>
      <label>
        <div>Password</div>
        <input type="password" name="password" required />
        <div>{password.error}</div>
      </label>
      <button type="submit">Login</button>
    </form>
  );
}

Learn more about conform here

API References

Package Description Size
@conform-to/react View adapter for react package size
@conform-to/yup Schema resolver for yup package size
@conform-to/zod Schema resolver for zod package size

conform's People

Contributors

abenhamdine avatar brandonpittman avatar edmundhung avatar

Stargazers

 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.