[SalesForce] Field’s validation rules in a Visualforce page

Is there a way to re-use the validation rules applied to some fields in Salesforce to a Visualforce page automaticaly?

I have a CustomController right now supporting the saving process of a field, but some required fields in the default object are not required in the Visualforce (unless I set them manually).

Thanks.

Best Answer

Validation Rules only execute when a database commit occurs (update/ insert/ upsert)

You cannot explicitly reference Validation Rules in Visualforce.

However you can logic you've already written in Validation Rules by including the apex:pageMessages tag in your VisualForce page, and letting the validation rules kick in on save - if any failures occur, they will be displayed on the VisualForce page.

Related Topic