cl8dep / components-validatorjs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

High Component Order for ValidatorJS library

This library provides a High Component Order(HOC) for the real-time validation of React web form fields. The validation engine is using validatorjs package.

How use it

function MyComponent(props) {
  
    return (
      <div>
        <input name="name" onChange={props.onFormChange}
               value={props.formState.name.value}/>

        <button disabled={props.formState.isPristine || !props.formState.isValid}>
            Submit
        </button>
      </div>
    )
}

const WithFormHandler = FormHandler({
  name: "string|required"
})(MyComponent);

export default WithFormHandler

License

These libs and it's source code is distribute using MIT license. You can read the license here

Contributing

About

License:MIT License


Languages

Language:TypeScript 86.4%Language:HTML 10.6%Language:JavaScript 3.0%