Validation Rule
Term 164 of 175 · Technology
In one sentence
A validation rule is a Salesforce condition that checks a record's data when it is saved and blocks the save with an error message if the data does not meet a criterion, ensuring data quality and consistency.
Reviewed by Juan Manuel Garrido
Co-founder of VantegrateLinkedIn
Validation Rule definition
A validation rule is a piece of Salesforce configuration that checks a record's data at the moment it is saved and, if a condition you define is met, prevents the save and displays an error message. It makes sure the information entering the system follows your business rules before it is stored.
The logic is written as a formula that returns true or false: when it returns true, Salesforce treats the data as invalid and blocks the operation. For example, a rule can require the "Amount" field to be greater than zero, a phone number to have the right format, or an Opportunity not to be marked as won without a close date. It is one of the most widely used declarative (no-code) tools in Salesforce for maintaining data quality.
Unlike a required field, which only demands that a value exists, a validation rule can check complex relationships across several fields and apply conditional criteria based on the record's context.
How it works under the hood
A validation rule is defined on an object (Account, Opportunity, Case, a custom object, etc.) and has three parts: a condition formula that returns true or false, a user-friendly error message, and the error location (at the top of the page or next to a specific field). Salesforce evaluates the formula every time someone tries to save a record, whether from the user interface, a bulk load, an API or an automation. If the formula returns true, the save is canceled entirely and the user sees the message; if it returns false, the record is saved normally.
The key detail is that the condition is written the opposite way from what intuition suggests: the formula describes the unwanted state. If you want to make sure a discount never exceeds 30%, the condition is `Discount__c > 0.30`. When that expression is true, the data is invalid and the save is blocked. Rules use functions such as `ISBLANK`, `ISPICKVAL`, `ISCHANGED`, `PRIORVALUE`, `REGEX` and logical operators to build sophisticated criteria.
Why it matters for the business
The value of a validation rule is that it moves quality control to the point where data enters the system, instead of discovering errors later in reports or in a broken integration. Dirty data, such as zero amounts, inconsistent sales stages or documents with no tax ID (CUIT), contaminates dashboards, automations and the sales forecast. A well-designed rule prevents that problem without writing a single line of code and without relying on the team's manual discipline. That is why it is a core piece of data governance and consistency in the CRM.
A concrete example in Argentina
A consumer goods distributor in Buenos Aires uses Salesforce to log Opportunities. The sales team sometimes marked deals as "Closed Won" without entering the customer's purchase order number, which broke invoicing further down the line. The administrator created a validation rule with the condition `AND(ISPICKVAL(StageName, "Closed Won"), ISBLANK(Purchase_Order__c))` and the message "You cannot close the deal without entering the customer's purchase order". Since then, no Opportunity reaches invoicing without that information, and the back office stopped chasing sales reps for missing data.
Common mistakes when implementing them
- Inverting the logic: writing the condition to describe valid data instead of invalid data makes the rule block always or never.
- Blocking bulk loads and integrations: an overly strict rule can stop data imports or API syncs that load legitimate but incomplete records.
- Cryptic error messages: a text like "Validation error 23" frustrates the user; the message should say what to fix.
- Too many overlapping rules: piling up dozens of undocumented rules makes it impossible to know why a record will not save.
- Not accounting for existing records: activating a new rule can prevent editing old records that already violated the condition; it is a good idea to use `ISCHANGED` or `ISNEW` to narrow its scope.
How it differs from other tools
It is easy to confuse a validation rule with other declarative Salesforce mechanisms. The difference lies in when each one acts and what it is for.
| Tool | When it acts | What it does |
|---|---|---|
| Validation rule | On save, before the record is written | Blocks the save if the data is invalid |
| Required field | On save | Only requires the field to have some value |
| Flow | Before or after save | Automates actions, can create or update records |
| Apex trigger | Before or after save | Advanced programmatic logic and complex validations |
As a rule of thumb, validation is the first choice when the goal is simply to prevent incorrect data: it is declarative, quick to create and easy to audit. When the logic goes beyond what a formula can express, or needs to look up other records, you turn to a Flow or to Apex. Knowing how to pick the right tool is part of the craft of a good Salesforce administrator.
FAQs about Validation Rule
What is a validation rule in Salesforce?
What is a validation rule in Salesforce?
It is a configurable condition that Salesforce evaluates every time someone tries to save a record. If the condition is met, the system blocks the save and shows the user an error message. Its goal is to make sure the data follows business rules before it is stored, ensuring the quality and consistency of the information in the CRM.
How does a validation rule formula work?
How does a validation rule formula work?
The formula returns true or false and describes the unwanted state of the data. When the formula returns true, Salesforce interprets the data as invalid and blocks the save; when it returns false, the record is saved normally. For example, to require an amount to be positive, the condition would be that the amount is less than or equal to zero, because that is the case you want to prevent.
What is the difference between a validation rule and a required field?
What is the difference between a validation rule and a required field?
A required field only demands that some value exists in that field. A validation rule is much more flexible: it can check relationships between several fields, apply conditional criteria based on the record's context and validate specific formats such as a tax ID (CUIT) or an email address. The required field answers whether there is a value; the rule answers whether that value is correct.
Can a validation rule stop a bulk data load?
Can a validation rule stop a bulk data load?
Yes. Validation rules apply both in the user interface and in bulk loads and API integrations. If an import tries to load records that violate an active rule, those records will be rejected. That is why it is a good idea to review existing rules before a data migration and, if needed, narrow their scope with functions such as ISNEW or ISCHANGED so they do not block legitimate operations.
When should you use a validation rule and when a Flow or Apex?
When should you use a validation rule and when a Flow or Apex?
A validation rule is the best option when you only need to prevent incorrect data from being saved, because it is declarative, quick to create and easy to audit. If instead you need to run actions, create or update other records, or apply logic that looks up information outside the record, a Flow is the better fit or, for very complex cases, Apex code.
We bring this to your Salesforce
Salesforce implementation, integration and support for LatAm companies, focused on the team actually using it instead of going back to spreadsheets. Tell us where your org stands.
Related terms
- Salesforce FlowFlow is Salesforce's declarative automation tool: it lets you build business processes (updating records, sending alerts, calling logic) with a visual drag-and-drop editor, without writing code, inside the platform.
- ApexApex is Salesforce's proprietary, object-oriented programming language, similar to Java, that runs on Salesforce's servers. It lets you add custom business logic (triggers, classes and integrations) when declarative tools such as Flow are not enough.
- Salesforce AdministratorA Salesforce Administrator is the person who configures, maintains and customizes the platform without coding: they manage users, permissions, objects, automations and reports so that sales, marketing and service teams work on reliable data.
- Data QualityData quality is the degree to which an organization's data is fit for its intended use. It is measured through dimensions such as accuracy, completeness, consistency, timeliness and uniqueness. When it is high, decisions, reports and AI models can be trusted.
- WebhookA webhook is an automatic HTTP notification that one system sends to another system's URL the moment an event happens, in real time. It lets applications integrate without one having to ask the other for updates every so often.
- APIAn API (application programming interface) is a contract that lets two software systems exchange data and functions without knowing each other's internal code. It defines, in a standard way, which requests you can make and which responses to expect.
Related questions
Salesforce
Salesforce implementation, integration and support for LatAm companies, focused on real team adoption.
How Salesforce solves itFive AI products that work on top of the CRM you already use. They don't replace your system: they add the layer you do by hand today.





