Newer Version Available
Validation Rules and Custom Controllers
If a user enters data on a Visualforce page that uses a custom controller, and that data causes a validation rule error, the error can be displayed on the Visualforce page. Like a page that uses a standard controller, if the validation rule error location is a field associated with an <apex:inputField> component, the error displays there. If the validation rule error location is set to the top of the page, use the <apex:messages> component within the <apex:page> to display the error. However, to get the information to the page, the custom controller must catch the exception.
For example, suppose you have the following page:
You need to write a custom controller like the following:
When the user saves the page, if a validation error is
triggered, the exception is caught and displayed on the page as they
are for a standard controller.