A validation rule is a formula that runs when a record is saved. If the formula evaluates to TRUE, the save is blocked and the user sees an error message of your choosing. It’s the simplest way to enforce data quality on the platform — no code, no automation engine, just an expression.
The mental model
Validation rule formula evaluates to TRUE = “this record is invalid” = save fails.
This trips up many beginners. You’d think TRUE means “valid”, but it’s the opposite: the formula describes the error condition.
A canonical example
A rule on Opportunity that prevents users from closing-won without an Amount:
AND(
ISPICKVAL(StageName, "Closed Won"),
OR(ISBLANK(Amount), Amount <= 0)
)
Error message: “You can’t close-win an Opportunity with no Amount.”
The user sees the error, can’t save, fixes the data, retries.
Where to display the error
Two choices when configuring the rule:
| Location | When to use |
|---|---|
| Top of page | Cross-field errors that don’t belong to one specific field |
| Field-specific | Tied to a single field; the error appears next to that field on the form |
How validation rules fit in the order of execution
Validation rules run before triggers, before workflow, before flow updates — they’re one of the very first things to fire on save. This means:
- They can block bad data from ever entering downstream automation.
- They cannot reference values set by
before insert/updatetriggers. The trigger hasn’t run yet.
When NOT to use a validation rule
- For automation that changes a value — use a Flow or trigger instead. Validation rules can only block saves, not modify data.
- For complex business logic spanning multiple records — use Apex.
- For “warn but don’t block” patterns — there’s no warning level; consider a flow that posts a Chatter post instead.
Common interview follow-ups
- Can validation rules prevent deletion? — No. They only fire on insert and update.
- Can we bypass a validation rule? — Yes, via custom permissions and a
$Permission.Xcheck in the formula. - Can we run the rule only on insert? — Yes, wrap the condition in
ISNEW().
Verified against: Salesforce Help — Define Validation Rules. Last reviewed 2026-05-17 for Spring ‘26 release.