Skip to content

v3.4.0

Compare
Choose a tag to compare
@iusehooks iusehooks released this 26 Jan 09:33
c22fda5

Improvement:

  • Enabling sync and async validation at form level
  • Improving documentation

Example:

 const graterThan10 = ({ values }) =>
    values && values['A'] + values['B'] > 10 ? undefined : 'A+B must be > 10'

function App() {
  const [status, validation] = useValidation([graterThan10])
  return (
    <Form touched {...validation}>
      <Collection object name="values">
        <Input type="number" name="A" value="1" />
        <Input type="number" name="B" value="2" />
      </Collection>
      {status.error && <label>{status.error}</label>}
      <button type="submit">Press to see results</button>
    </Form>
  );
}