# Salesforce - How to Create a Validation Rule in Salesforce

> To create a validation rule in Salesforce, navigate to Setup and open Object Manager. Select your desired object, open Validation Rules, and click New. Define the label, activate the rule, enter an error message and formula, then click Save to finish.

Canonical: https://livedemo.ai/tutorials/how-to-create-a-validation-rule-in-salesforce/
Apps: Salesforce
Updated: 2026-10-05
Interactive demo: https://story-api.livedemo.ai/workspaces/62255d3d3304f17b8f5e2d03/stories/692a389fab56e05a00fdeb87/preview?step=1

## Steps

1. Go to Setup on the top right.
2. Search for Object Manager in the Quick Find.
3. Select the object you want to enforce the rule on (Leads, Opportunities etc).
4. Find the Validation Rule s section and click on it.
5. Click New to initiate the creation of a new validation rule.
6. Start defining the rules for Labels and Error Condition Formula .
7. Label : Give your rule a clear name (e.g., "Opportunity Requires Amount").
8. Select Active to make the rule enforceable.
9. Error Message: Craft a clear message displayed to users when the validation fails (e.g., "Please enter an amount for Closed Won opportunities").
10. Error Condition Formula: This is the key part. Use the formula builder to define the criteria that must be met to avoid an error message. An example formula to ensure the amount is filled for opportunities marked as "Closed Won": ISPICKVAL(PRIORVALUE(StageName), "Closed Won") && Amount == null
11. Click Save to create the validation rule.
