Blog
>
RevOps
>
Salesforce Validation Rules: How They Work and When to Use Them
Table of Contents
See how Weflow enforces Salesforce data quality at the source, so your validation rules rarely need to fire.
Book a demo
Or use our free web app.

Salesforce Validation Rules: How They Work and When to Use Them

Updated
May 13, 2026
Validation rules catch bad data at entry — Weflow prevents it upstream by guiding reps to update Salesforce correctly.
See it live

What are Validation Rules?

Validation rules are important for any system, Salesforce included. They can prevent users from entering invalid data, which can cause errors and make your reports unreliable. Validation rules also prevent users from saving records if the rule returns an error, which helps ensure data integrity across objects in your Salesforce org.

Let's look at an example of how you might use a validation rule. Say you have a custom object that's related to your accounts, like "account history." When adding or updating information on this object, you always want to be sure that the user selects an account record as well (such as "account history"); otherwise things are going to get confusing fast! A validation rule will require users to include this information when adding a new record of type "account history," and it'll help ensure that all records have correct data moving forward.

Now that we've covered what a validation rule is and why it's useful, let's talk about how we create one in Salesforce!

How do Validation Rules Work?

Unlike workflow rules, which can only evaluate a record when it’s saved, validation rules are evaluated every time the record is saved, including both before and after triggers.

If a validation rule evaluates to true, Salesforce displays an error message defined in the rule. The record will not be committed to the database until the error is fixed and all validation rules have been evaluated as false.

But if your trigger or workflow field update formula is set to fire before a save, you may get an error that your field has been updated by another process—even though it hasn't been yet! To avoid this issue, make sure formulas are set to run after the record is saved.

When to Use Validation Rules in Salesforce

You can use validation rules in Salesforce when:

  • You want to make sure users are entering correct data. For example, if you want to ensure a user enters only numbers between 1 and 10,000 in a certain field.
  • You want to prevent duplicate records. For example, if you don't want two contacts with the same name or two leads with the same email address.
  • You want to prevent users from saving records unless they fulfill certain criteria. For example, if you don't want people to save an opportunity unless they provide information about what the lead wants.
  • You want to make sure data is entered in a certain field before users can save a record. For example, if your company has sales targets for each region that can't be saved without a value in the target amount field for that region.
  • You want to make sure data is entered in a specific format before users save records. For example, if you have phone numbers that need to be more than 10 digits long but less than 15 digits long (since some phone numbers may have an area code).

Examples of Validation Rules in Salesforce

As you've seen so far, validation rules can be used to ensure that a number is greater than a certain value, or that a date is after a certain date. They can also be used to ensure that a string (a series of characters) is the right length.

Ensure anyone who fills the contact form, must fill out their email address

Here's another scenario: you're putting together a contact form for your website, and you want to make sure that anyone who fills it out has entered their email address.

You could do this with the following validation rule:

AND(ISBLANK(Email), NOT(ISBLANK(Website)))

The logic is simple: if the Email field is blank and the Website field is not blank, allow the user to proceed. If either of those two things aren't true—if both fields are blank or if the Email field is not blank—the rule will throw an error telling the user that they need to enter their email address in order to continue.

Using LEN function

Here's another example of how you can use the LEN function in combination with the AND function to ensure that Account Name must always have more than 5 characters.

The AND function is one of the most common validation rules in Salesforce. To use it, you must combine it with a function like LEN (length) to indicate how many characters you want your string to be, and then include an error message that will pop up if someone doesn't meet the requirements.

AND(LEN(Name) > 5, false)

Salesforce validation rules let you enforce the integrity of your data when it's entered.

Salesforce validation rules let you enforce the integrity of your data when it’s entered.

Validation rules check the data that is entered into a record, and ensure that it meets the standards specified by your business before you save the record to Salesforce. This means that you can prevent users from entering incorrect data into your Salesforce org in the first place.

By
Weflow

Weflow is the Salesforce-native, modular Revenue AI platform for RevOps leaders and revenue teams, powering pipeline, forecasting, and deal inspection for 200+ B2B companies. The team behind Weflow also hosts the RevOps Lab podcast and runs RevOps Chat, the Slack community for 1,000+ RevOps practitioners.

More articles by
Weflow

Related articles

B2B Revenue Planning: How to Build Territories, Quotas, and Comp Plans

Learn how to build a B2B revenue plan with fair territories, realistic quotas, and comp plans.

RevOps Salary Benchmarks by Role, Region, and Experience (2023)

Use 2023 RevOps salary benchmarks by role, region, and experience to set pay bands or compare offers.

B2B SaaS Metrics: 35 KPIs and Benchmarks Across the Customer Journey

Learn 35 B2B SaaS metrics and benchmarks across the customer journey, from CAC and NRR to win rate.

CRO Metrics and Forecasting Framework for Predictable Revenue

Learn a CRO metrics and forecasting framework for predictable revenue and accurate forecasts.

B2B GTM Strategy Guide: Scaling RevOps to $100M ARR

Learn how to scale RevOps to $100M ARR with the right B2B GTM strategy, metrics, and controls.

Salesforce Architecture, Data Model, and Admin Features Explained

Learn how Salesforce architecture, data model, and admin features shape CRM design and governance.

RevOps Metrics, Models, and Benchmarks: A Complete Reference Guide

Learn RevOps metrics, operating models, maturity stages, and SaaS benchmarks in one reference guide.

30/60/90 Day RevOps Plan: Fix Data, Reporting, and Handoffs

Build a 30/60/90 day RevOps plan to fix CRM data, reporting trust, and team handoffs.

How to Run a QBR That Improves Forecast Accuracy

Learn how to run a QBR that improves forecast accuracy with the right data, roles, and follow-through.

30/60/90 Day CRO Plan: First 90 Days Framework for New CROs

Learn how to build a 30/60/90 day CRO plan for your first 90 days, from GTM audit to revenue gains.

How to Move from RevOps to COO: Skills, Cadences, and Metrics

Learn how to move from RevOps to COO with the skills, cadences, and metrics that matter

RevOps Metrics and Benchmarks to Track Growth, Efficiency, and Retention

Learn which RevOps metrics and benchmarks to track for growth, efficiency, and retention.