Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Validation Rule entry
How-to guide

How to set up Validation Rule in Salesforce

Validation Rules block a save when their formula evaluates to TRUE — they're the platform's first line of defense against bad data. Setup lives under Object Manager, one rule at a time, scoped to a single object.

By Dipojjal Chakrabarti · Editor, Salesforce DictionaryLast updated Apr 20, 2026

Validation Rules block a save when their formula evaluates to TRUE — they're the platform's first line of defense against bad data. Setup lives under Object Manager, one rule at a time, scoped to a single object.

  1. Open Setup → Object Manager

    Top-right gear icon → Setup → Object Manager. Pick the object you want to validate (Account, Contact, custom — anything).

  2. Open the Validation Rules section

    From the object's left rail, click Validation Rules.

  3. Click New

    Top-right. Each rule is an independent record.

  4. Name and describe the rule

    Rule Name is API-safe (no spaces). Description is for fellow admins — explain *why*, not just *what*, because the formula will tell anyone what.

  5. Build the Error Condition Formula

    The formula must return TRUE when the data is *bad*. The Insert Field and Insert Operator buttons help you build it without typos.

  6. Set the Error Message and Location

    The message shown to the user when the rule blocks save. Location is either "Top of Page" or a specific field — field-level errors are more helpful.

  7. Activate

    Tick the Active checkbox at the top before saving the rule. Inactive rules don't fire.

Key options
Error Condition Formularemember

The Boolean formula. Returns TRUE → block save. The single most-confused part of validation rules — TRUE means "reject", not "accept".

Error Locationremember

"Top of Page" puts the message above the page-level error banner; "Field" attaches it inline next to the offending field. Field-level is friendlier when the rule is field-specific.

Activeremember

On = enforced; Off = saved but ignored. Useful for staging fixes before flipping the switch in production.

Gotchas
  • Validation rules fire on UI saves *and* on every API/Apex/Flow DML — a rule designed for the screen can break a nightly integration. Test against your bulk loads.
  • TRUE = reject is the inverse of what most people guess. Sanity-check by reading the formula as "reject when ___" out loud.
  • Validation rules run *after* before-save Flows and triggers but *before* after-save logic — a Flow that fixes the data still has to satisfy the rule on the saved record.

See the full Validation Rule entry

Validation Rule includes the definition, worked example, deep dive, related terms, and a quiz.