New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(validation): Add 'optional' prop #15191
feat(validation): Add 'optional' prop #15191
Conversation
bd54e69
to
6c34ccb
Compare
c62375c
to
c692f92
Compare
Could you provide markup for your use-case? |
I have a form with an optional email. I want the validation to evaluate to true either if the email is valid or the input is left blank. Hence this "optional" prop that automatically evaluates the validation to true if the input is blank. |
@carlesalbasboix by markup he means actual code showing how this is suppose to be used. In the PR template theres a section called |
0f42bc6
to
469895f
Compare
Ah, ok, I resolved the branch conflicts and provided the markup. |
@KaelWD how does this fit in with our conversation regarding lazy-validation last week? |
Hi, |
Maybe 3.1. We are pretty much locked for v3 release at this point. |
50e76f2
to
1057e25
Compare
b6aed82
to
ceaffe5
Compare
@johnleider Can we consider it now that v3 has been released? |
7c417af
to
070e2aa
Compare
Pulse check on this. |
7ce7b02
to
1adfeaa
Compare
bb07313
to
e5c1c07
Compare
7cd11a6
to
d0765f1
Compare
f931c2e
to
748056c
Compare
cd170f8
to
98e57dc
Compare
Description
Added a boolean prop called 'optional' to the validation composable. If the model value is empty (undefined, empty string or empty array) and optional is set, then the validation ignores the rules and returns true.
Useful for:
Motivation and Context
Right now when writing validation rules you must take into account whether you accept an empty string. Furthermore, an empty optional field will not be valid by default until the user changes it's value. This solves the problem of having optional fields that still require rules for when they are set.
How Has This Been Tested?
There are no tests yet. I want to wait and see whether the functionality is approved before writing tests.
Markup:
Types of changes
Checklist:
master
for bug fixes and documentation updates,dev
for new features and backwards compatible changes andnext
for non-backwards compatible changes).