Higher Order Component for Validating Forms in React
Added updateErrors
and updateAsyncErrors
functions (see #41)
Updated spected
dependency to 0.5 to enable dynamic form field validations (see #26)
Added callback capability to onChange
to enable accessing validated form values after an onChange
update. (see #42)
Following Changes:
validateOnChange
: accepts a callback or a boolean value. Useful when needing from static to dynamic validation after an initial submit.
validateSingle
and validateOnChange
are set to false
by default now.
Added submitted
property, boolean value set to true
after the initial submit.
Added shortcut functions for updating and validating fields:
updateValue
validateValue
updateValueAndValidate
Changed asynchronous validation handling. Revalidation doesn't run any asynchronous validations against rules, this has been moved to user land.
onSubmit
(renamed from validateAll
) now runs any callback supplied wether the validation has been successful or not. Passes a calculated valid
(boolean) and the complete form state.
<button
onClick={() => onSubmit(({form, valid}) => valid ? submitCb(form) : console.log('not valid!'))}
>
Submit
</button>
Following Changes:
reValidaiton
prop has been renamed to revalidation
initialState
is missing.updateValute
to onChange
and pending
to loading
in revalidation
instantValidation
to validateOnChange.