[0.5.x] Improve async validation API #109
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The API when working with a form wizard is less than ideal. We have done a lot of work recently to make this experience better, but the API never felt right.
You currently need to call the
touch
method to ensure the current page's inputs are validated - even if the user has not interacted with them.It is also not possible to un-touch an input, which can cause issues with certain form wizard configurations.
This PR intends to make this API better while addressing the issue with not being able to un-touch inputs.
To achieve this we are exposing an
only
validation key as part of the documented public API. This configuration value already exists, but it is currently calledvalidate
and is not intended for public use.I'm renaming the key to
only
now that it is public, which makes it a more expected API name in the Laravel ecosystem. I've depreciatedvalidate
but kept support for it in case people have been using it.When specifying inputs in the
only
key, validation will only apply to those inputs. Those keys will also be "touched" to ensure their future validation behaviour is expected, including conditional and interdependent validation rules.