I have a quite complicated, multi-page form within my ruby on rails application (built with wicked gem). My model have two fields which are being validated against each other -
driving_licence_since (there must be at least 17 years between those dates).
Now the problem is that those fields are on different form pages. This means that customer is able to:
- Provide his date of birth first.
- Progress to next page (date of birth saved in database)
- Fill and submit valid at this point
- Navigate back to the first page
- Change his date of birth so it is invalid.
We have written our validation the way that the customer is not able to save invalid date of birth at any point (all the page specific validations are being run against the model once given page has been reached regardless on what page customer is currently on), however at the moment no error message is being displayed (as the error is attached to the 'licence_since' field which is not being displayed at the current page). Even though it would be easy to display the error message, this doesn't seem to be the perfect solution.
So far we have considered a number of options, but none of those is working for us:
Allowing customer to progress and stop him on the next page - this creates possibility to pass by validations using browser back button.
date of birthis submitted - same issue as above.
My favourite: When an invalid date is supplied, display an extra field below it to alter
licence_sincefield as well.
Redirect customer to the page with
licence_sincefield with message that he can't change date of birth without altering
licence_since- this is just rude.
So my question is - are there any standard way of dealing with cross-pages validation issues? What solution would you propose to the problem?