I have a page that needs to be validated when the submit button is clicked. A couple of these components require validations such as "if this checkbox is checked as well as this other checkbox is checked then make sure this textbox has a value", so nothing an validation rules could do I believe. So I wrote an apex function called 'validate()' that does all of these checks and it works fine. The only problem is where to call the function. Right now I have it in the 'submit()' function so that if 'validate' fails it pops up error messages and if it passes it submits/saves the object. Still so far so good. The only problem is it doesnt mix with the standard required fields error messages.
For example my page has a 'Project Number', and 'Name' standard required field. If I submit without filling out those fields and also filling it out so my custom error will trigger it pop up "Error: Must give value for Project Number and Name", and say nothing about my errors since the submit doesnt get called. Then if I fill out project number and name, submit does get called and my errors come up "Error with foo checkbox checked you must fill out bar".
So essentially if they leave the 2 standard required fields blank and my 2 custom required fields blank it will stop them at different times with different messages.
I need to call my validation function at the same time the default validation is called but i dont know when/how that is.