0.1.8 • Published 1 year ago

@wilkins-software/react-constraint-api v0.1.8

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@wilkins-software/react-constraint-api

This is a typescript library which wraps the HTML5 constraint validation API. The library provides a simple and easy-to-use interface for working with form constraints in react projects.

Installation

To install the library, simply run the following command:

npm install @wilkins-software/react-constraint-api

Usage

Here is a simple example of how to use the library to add some basic validation to form elements:

import { Input } from '@wilkins-software/react-constraint-api'

const MyForm = () => {
  return (
    <Input 
    checker={(value) => value.endsWith('!')} 
    errorMessage={(value) => `${value} is invalid! The value must end in "!"`}
    
    />
  )
}

Which will produce the below (chrome): An example

License

This library is licensed under the MIT License.