Introduction
Maintaining accurate and consistent data is essential for every Salesforce organization.
Incorrect field values, incomplete records, and duplicate customer information can affect reporting, automation, and business decisions.
Salesforce provides two important tools to help administrators improve data quality:
- Validation Rules
- Duplicate Rules
Although both features help control data quality, they serve different purposes.
Validation Rules check whether record data meets specific business requirements, while Duplicate Rules identify potential duplicate records and determine whether users should be warned or blocked.
In this blog, we’ll explore Salesforce Validation Rules vs Duplicate Rules, their differences, practical examples, configuration steps, and best practices.
What Are Validation Rules in Salesforce?
A Validation Rule is a Salesforce feature that checks record data against a formula-based condition before allowing a record to be saved.
When the validation formula evaluates to TRUE, Salesforce displays an error message and prevents the record from being saved.
Validation Rules help enforce business requirements and maintain consistent information.
Example of a Validation Rule
Suppose a company requires every Opportunity marked as Closed Won to have a Close Date.
A validation rule can prevent users from saving an Opportunity without this information.
Example Formula:
AND(
ISPICKVAL(StageName, "Closed Won"),
ISBLANK(CloseDate)
)
When the condition is TRUE, Salesforce displays an error message.
Error Message: A Close Date is required for Closed Won opportunities.
Note: Close Date is already a standard required field on Opportunities. This example illustrates the formula concept; the requirement is normally enforced without a custom validation rule.
Key Features of Validation Rules
- Use Salesforce formulas to evaluate record data.
- Enforce business-specific data requirements.
- Prevent invalid records from being saved.
- Display customized error messages.
- Support conditional logic involving field values.
What Are Duplicate Rules in Salesforce?
Duplicate Rules help identify and manage records that may already exist in Salesforce.
They work together with Matching Rules, which define how Salesforce determines whether records are potential duplicates.
A Matching Rule identifies possible matches, while a Duplicate Rule determines what happens when those matches are found.
Depending on the configuration, Salesforce can block the operation or allow it, potentially displaying an alert.
Example of a Duplicate Rule
Imagine a sales representative creates a new Contact with the following details:
Name: Rahul Sharma
Email: rahul@example.com
A Contact with the same email address already exists.
If the organization has configured an appropriate Matching Rule and Duplicate Rule, Salesforce can identify the potential duplicate.
The system may display a warning or block the new record, depending on the rule configuration.
Key Features of Duplicate Rules
- Detect potential duplicate records.
- Work with Matching Rules.
- Support duplicate prevention during record creation and editing.
- Allow configurable blocking or warning behavior.
- Help maintain cleaner customer and prospect data.
Salesforce Validation Rules vs Duplicate Rules: Key Differences
| Feature | Validation Rules | Duplicate Rules |
|---|---|---|
| Primary Purpose | Validate field data | Detect potential duplicate records |
| Evaluation | Formula conditions | Matching Rules |
| Main Focus | Data correctness | Record uniqueness |
| Action | Block save when formula is TRUE | Block or allow, with configurable alerts |
| Error Message | Custom validation error | Duplicate warning or error |
| Common Use | Required business fields, value restrictions | Duplicate Leads, Contacts, Accounts |
| Configuration | Object Manager → Validation Rules | Setup → Duplicate Rules |
| Related Feature | Formula functions | Matching Rules |
Key Difference: Validation Rules enforce business conditions on record data, while Duplicate Rules check for potential matches against existing records.
How Validation Rules Work in Salesforce
Validation Rules use formulas that return TRUE or FALSE.
When a record is created or updated, Salesforce evaluates the active validation rules at the appropriate point in its save process.
If a rule returns TRUE, the record fails validation.
Example: Prevent Negative Discount Values
Suppose a custom field named Discount__c stores a discount percentage.
The business wants to prevent users from entering negative values.
Validation Formula:
Discount__c < 0
Error Message: Discount cannot be negative.
This ensures that users cannot save records with invalid negative discounts through operations where the validation rule is enforced.
Example: Require a Reason for High Discounts
A company requires a justification when the discount exceeds 20%.
Validation Formula:
AND(
Discount__c > 20,
ISBLANK(Discount_Reason__c)
)
Error Message: Please provide a reason for discounts above 20%.
This example assumes Discount_Reason__c is a text field.



