import React from 'react' import ReactDOM from 'react-dom' import { useForm } from '../' const Index: React.FC = () => { const { auto, form, errors, isValid } = useForm({ username: '', email: '', password: '' }, { username: value => value.length > 3, email: { validator: /@/, message: 'Must contain an @', }, password: [ { validator: /[A-Z]/, message: 'Must contain an uppercase letter' }, { validator: /[\d]/, message: 'Must contain a digit' }, ] }) return (
{ e.preventDefault() if (isValid) console.log(form) }}>

Errors & Validation

{errors.username && 'Must be longer than 3'} {errors.email} {errors.password}
) } ReactDOM.render(, document.getElementById('errors'))