Only validate fields that are currently shown
See original GitHub issueI am making a field required by adding an attribute like validation: [['string'], ['required']]
to my schema. I am making the field conditionally shown using an attribute like showWhen: ['or', ['is', 'color', 'blue'], ['is', 'color', 'red]]
. It seems that even when the field is not shown, validation is being run, preventing me from submitting the form.
Would it make sense to only validate fields that are actually being shown? Or, alternatively, is there any way to include the showWhen
logic in the validation
statement?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Validate only fields that are visible - javascript
1 Answer 1 ... Take hidden field that contain action of radio button on change(if click on item one >> 'x', item >>'y')...
Read more >LiveValidation only validate fields that are visible?
I'm using LiveValidation to validate fields in a form before they are submitted. I have one option where the user can select “Married” ......
Read more >Validate only one field at a time · Issue #512
Formik validate function - pass the event's field name. It will allow the developer to validate only one field at a time.
Read more >Validation
Formik is designed to manage forms with complex validation with ease. Formik supports synchronous and asynchronous form-level and field-level validation.
Read more >Data Validation – How to Check User Input on HTML ...
We need form validation anytime we are accepting user input. We must ensure that the data entered is in the correct format, lies...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For anyone reading this thread if you are serializing your schema e.g. JSON.stringify and transporting it over the wire you will need to use some manual scheme to serialize your functions and then deserialize them when you read out your schema since Javascript functions are not valid JSON.
It does make sense to validate just the visible fields, but at this time that is possible only by using the
when
condition provided byyup
.Following might work for your case: