-
-
Notifications
You must be signed in to change notification settings - Fork 623
Conditional Validation #439
Description
Hello, technocrats!
I'm facing a hard time implementing conditional validation. As per the new API version, validation checks are passed in the form of an array as a second parameter, well, this is what I could infer, to the routing methods. Lemme give you a scenario to make it clear.
I have a login page with two tabs defining Student Login and Teacher Login. Each tab has a Bootstrap Form with Student ID (or Teacher ID) input field, a Password input field, a hidden input with a fixed value for each (say SID for student and TID for teacher), and a submit button. The POST method for the page is defined in index.js.
Now, the issue is I need to check the value of the hidden input first and on the basis of that only I need to choose the right route for the student and the teacher. I need to check all the input validations also for respective fields in Student Login form and Teacher Login form. It's just like dealing with two forms in one POST method. Where should I be writing the conditional code for the route?
Any help is heartily appreciated.
Thank you
Arvind Jaiswal