Optional validations and inputs

React Reform comes with some validations and wrapped inputs out of the box. They are not included in the main bundle. I.e. if you don't explicitely require them they won't be added to your build.

Also there's no magic in here. Have a look at the sources to learn what's going on here.


You can require them via react-reform/opt/inputs. Take a look below at all the inputs in use:

import {Form, ReformContext} from 'react-reform'
import {Text, Textarea, Password, Select, Checkbox} from 'react-reform/opt/inputs'


<Form onSubmit={this.handleSubmit}>
  <Text name="name" isRequired/>
  <Textarea name="comment" hasMaxlength={140}/>
  <Password name="password" isRequired/>
  <Select name="fruit">
    <option value="apple">Apple</option>
    <option value="orange">Orange</option>
  <Checkbox name="agreeToTos" isRequired/>

Note: there's no default Radio input. This is because there's no unopionated way of handling those in react. It's recommended wrapping a package like react-radio-group.


React Reform also offers some typical validations. Here's a list of them


<Text name="..." isRequired/>


<Text name="..." isEmail/>


<Text name="..." hasMinlength={6}/>


<Text name="..." hasMaxlength={140}/>


<Text name="..." hasPattern={/^\d+(\.\d+)?$/}/>
React Reform is brought to you by Codecks. Suggest edits for these pages on GitHub