airjp73 / rvf

Easy form validation and state management for React and Remix
https://rvf-js.io
MIT License
826 stars 66 forks source link

[Feature]: Always validate after submit #334

Closed sdriffill-tm closed 8 months ago

sdriffill-tm commented 10 months ago

What is the new or updated feature that you are suggesting?

I would like to be able to specify validation behaviour options such that validation happens:

  1. onSubmit
  2. and then onBlur after the 1st submit

Why should this feature be included?

Depending on the form, in many cases I find this a good level of user feedback. The user may initially jump around the form to the extent that validating onBlur from the outset is intrusive, but then after the 1st submit, we expect the form to be in a finalised state and can make our feedback more regular.

In conform this can be implemented via a combination of props:

shouldValidate: 'onSubmit',
shouldRevalidate: 'onBlur',
...
sdriffill-tm commented 10 months ago

Self-closing as have realised functionality is already implemented via combination of:

validationBehavior={{
  initial: 'onSubmit',
  whenTouched: 'onSubmit',
  whenSubmitted: 'onBlur',
}}