Validation Rules are one of the most important tools in a Salesforce Admin’s toolkit. They enforce business logic at the point of data entry—ensuring data integrity and consistency across the platform.
In this complete guide, you’ll learn how to write effective validation rules, explore common use cases, discover troubleshooting techniques, and adopt best practices that boost data quality while improving the user experience.
Validation Rules verify that data entered into a record meets specific criteria before saving. If a rule’s condition evaluates to TRUE
, Salesforce prevents the record from being saved and displays an error message.
Each rule consists of:
TRUE
to trigger the errorISBLANK(Email)
If the Email field is blank, block the save and show an error.
ISBLANK(Phone) && ISPICKVAL(LeadSource, "Phone Inquiry")
Ensures phone number is provided when Lead Source is “Phone Inquiry”.
CloseDate < TODAY()
Prevents setting a Close Date in the past.
ISPICKVAL(Industry, "Other") && ISBLANK(Industry_Description__c)
Requires description when “Other” is selected.
$Profile.Name = "Sales Rep" && ISCHANGED(StageName)
Blocks Stage change for Sales Reps.
Use test data to validate your rule doesn’t block legitimate entries.
Avoid technical language. Provide guidance.
Bad: “Formula returns TRUE”
Good: “Phone Number is required when Lead Source is Phone Inquiry.”
Break complex logic into multiple rules if needed.
Use custom formula fields to simplify complex expressions.
Validation Rules can reference parent objects via lookup/master-detail.
Example: Prevent saving a Contact if the related Account is inactive:
Account.Status__c = "Inactive"
Note: You can’t go “up” more than one level, and child-to-parent only.
To manage exceptions during data loads or migrations:
Bypass_Validation__c
ISBLANK(Email) && NOT(BYPASS__c)
You can then check the bypass field via Data Loader or Flow during imports.
Tool | Purpose |
---|---|
Setup Menu | Create and manage rules |
Schema Builder | Visualize relationships |
Reports | Find rule errors over time |
Salesforce Optimizer | Identifies complex or unused rules |
Validation Rule Matrix | Track rules by object and purpose |
Create a report:
This helps you understand rule impact and where users struggle.
Scenario: Ensure that Sales Reps can’t offer more than 20% discount.
AND($Profile.Name = "Sales Rep",Discount__c > 0.20)
Error Message: “Sales Reps may not discount more than 20%. Contact a Sales Manager for approval.”
Mistake | Solution |
---|---|
Error message too vague | Use actionable language |
Complex all-in-one formulas | Split into smaller rules |
Not excluding system integrations | Use context variables |
No testing before deployment | Always test in sandbox |
$User
, $Profile
, $Permission
variables for context-based rulesREGEX()
for pattern matching (e.g., phone or email format)Validation Rules are a cornerstone of good Salesforce data hygiene. When used effectively, they protect data quality, improve reporting, and support your org’s business processes.
Need a library of pre-built validation rules? Drop a comment below and we’ll send you our top 50 formulas every Admin should know!
Quick Links
Legal Stuff