Salesforce Validation Rules: Stopping Bad Data at the Door
Every Salesforce admin has seen it: an opportunity saved with a close date in the past, a lead with no phone number, a case assigned to a queue that no longer exists. Bad data does not announce itself — it quietly spreads until a report is wrong, an automation misfires, or a rep loses trust in the system. Validation rules are the simplest way to stop bad data at the door, before it ever becomes a record.
What a Validation Rule Actually Does
A validation rule is a formula that runs when a user saves a record. If the formula evaluates to true, Salesforce blocks the save and shows your error message. That is the whole mechanism — one formula, one message, enforced every single time, no matter whether the record comes from the UI, an import, or an API call.
The most common mistake is thinking of validation rules as data-quality polish. They are not polish; they are a contract. A close date cannot be in the past. A discount above 20% needs a reason. An email field must actually look like an email. Each rule encodes one business decision that used to live in someone's head.
Writing Rules People Can Live With
1. Start with the fields users already get wrong. Look at your messiest reports and work backwards. If half your opportunities are missing a next step, that is your first rule — not a clever formula nobody asked for. The goal is fewer corrections later, not more red text now.
2. Keep the error message human. "Error: FIELD_CUSTOM_VALIDATION_EXCEPTION" tells a user nothing. "Close date can't be in the past — pick a future date" tells them exactly what to fix. Write the message as if you are standing next to the person who triggered it, because in a sense you are.
3. Make the rule as narrow as possible. A rule that fires on every record type or every stage will annoy people into workarounds — and workarounds are worse than the bad data you started with. Scope rules by record type, stage, or profile where it makes sense. If a rule should not apply to system admins doing a data fix, say so in the formula.
4. Pair rules with required fields, not instead of them. A required field guarantees a value exists; a validation rule guarantees the value makes sense. They solve different problems. If you are deciding which one to use for a field like phone number, this guide to making fields required covers the required-field side of the pair.
5. Test with real data, not perfect data. Before activating a rule, run it against your existing records in a sandbox. A rule that would have blocked 40% of last month's saves is not a quality win — it is a sign the rule is too strict or your users need a different process. The same "clean the data first" logic applies to any AI or automation project — rules cannot fix data that is already wrong.
Common Gotchas Worth Knowing
- Validation rules fire on imports too. A bulk load that trips a rule will fail row by row. That is usually what you want — but warn whoever runs the import first, or their job will look broken.
- Rules do not run on every save. They fire on insert and update, but some system processes and certain API operations can bypass them. Do not treat a validation rule as your only line of defence for critical data.
- Order matters with Flows. A record-triggered Flow that updates a field can itself trip a validation rule and fail. If an automation suddenly starts erroring, check the validation rules on the object before you debug the Flow.
- Too many rules is a smell. If an object has twenty validation rules, the real problem is usually an unclear process, not twenty separate data problems. Consolidate where you can, and retire rules that no longer match how the team works.
The Bottom Line
Validation rules are the cheapest data-quality tool Salesforce gives you: no code, no package, no maintenance burden beyond the formula itself. Write a few good ones, keep the messages human, test against real data before you activate them, and your reports — and your automations — will quietly get more trustworthy.
Originally published at Way2Force. Rohan Mehta is a Salesforce writer at Way2Force — practical guides on Salesforce Flow, automation, and CRM.
Top comments (0)