#ValidationRules

2024-10-30

Popular Validation Rules for Salesforce Flows including Phone, Email and Address Fields

Salesforce Flow validation rules are essential for ensuring data accuracy and consistency in automated workflows. By setting specific conditions that data must meet before it is saved or processed within a flow, these rules prevent erroneous or incomplete information from moving forward in the workflow. For instance, you might create a validation rule that requires certain fields, such as phone, email and address, to be filled out or ensures that a value falls within a specified range before the flow can continue. This not only enforces data quality standards but also helps avoid downstream errors that could disrupt business processes or lead to poor decision-making. With flow validation rules, Salesforce admins can maintain control over data integrity while enhancing user experience by proactively catching errors.

Below are a few popular flow validation rules I used in my projects

Name

Standard length for Name Fields is 40 for First Name, 20 for Middle Name and 80 for Last Name.

First Name

Error message:

Your entry needs to be shorter than 40 characters.

Validation rule:

LEN({!First_Name})<=40

Social Security Number (USA)

Error message:

Please enter 9 digits for the SSN field.

Validation rule (this rule allows for dashes):

OR( REGEX( {!Social_Security_Number} , "[0-9X\-]{11}"), REGEX( {!Social_Security_Number} , "[0-9]{9}") ) 

Address

Standard length for address fields are 256 for Street Address and 80 for City. The ZIP (Postal) code can be in XXXXX or in XXXXX-XXXX format (USA).

State Code

Error message example:

Please enter a State Code consisting of two capital letters.

Validation rule:

NOT(  AND(    NOT(ISBLANK({!State})),    OR(       LEN( {!State}) <> 2,       NOT(CONTAINS({!State}, UPPER({!State})))     )  ) ) 

ZIP (Postal) Code (USA)

Error message example:

ZIP code needs to be in XXXXX or in XXXXX-XXXX format.

Validation rule:

REGEX({!MailingZIP} , "\d{5}(-\d{4})?")

Revenue

Error message example:

Your entry needs to be shorter than 16 digits.

Validation rule (Currency upper limit):

{!Revenue}<10000000000000000

Email

Error message example:

Please enter a valid email address.

Validation rule:

REGEX({!Email_Address},"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}")

Phone number

Error message example:

Please enter a 10 digit phone number.

Validation rule:

AND( LEN({!Mobile_Phone})=10, NOT(REGEX({!Mobile_Phone} ,"^[a-z A-Z]*$"))) 
 

Incorporating Salesforce Flow validation rules into your automated workflows can be transformative for maintaining data accuracy and enforcing business standards. These rules not only ensure that critical data points like names, social security numbers, and contact information meet required formats but also prevent incomplete or invalid entries from progressing through your system. By using validation rules to define acceptable data criteria, you create a more reliable, error-resistant environment that supports both user confidence and data integrity. 

Explore related content:

6 Things You Can Do With The Transform Element

Top 9 Salesforce Winter 25 Flow Features

Enhance UX in Flow with Custom LWC Icon Selector

#Admin #Administrator #Developer #Email #HowTo #Phone #Revenue #Salesforce #SalesforceAdmin #SalesforceDeveloper #SalesforceTutorials #UseCases #ValidationRules

Validation Rules Blog Image

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst