Sample Account Address Validation Rules
Rules to maintain valid account addresses.
Required Editions
| Available in: both Salesforce Classic and Lightning Experience |
| Available in: Contact Manager, Group, Professional, Enterprise, Performance, Unlimited, Developer, and Database.com Editions |
For more information on any of the formula functions used in these examples, see Formula Operators and Functions by Context.
Canadian Billing Postal Code
| Field | Value |
|---|---|
| Description: | Validates that the account Billing Zip/Postal Code is in the correct format if Billing Country is Canada. |
| Formula: | |
| Error Message: | Canadian postal code must be in A9A 9A9 format. |
| Error Location: | Billing Zip/Postal Code |
Billing Zip Code Is in Billing State
| Field | Value |
|---|---|
| Description: | Validates that the account Billing Zip/Postal Code is valid by looking up the first five characters of the value in a custom object called Zip_Code__c that contains a record for every valid ZIP code in the US. If the ZIP code isn’t found in the Zip_Code__c object, or the Billing State doesn’t match the corresponding State_Code__c in the Zip_Code__c object, an error is displayed. |
| Formula: | |
| Error Message: | Billing Zip Code doesn’t exist in specified Billing State. |
| Error Location: | Billing Zip/Postal Code |
US Billing Zip Code
| Field | Value |
|---|---|
| Description: | Validates that the account Billing Zip/Postal Code is in 99999 or 99999-9999 format if Billing Country is USA or US. |
| Formula: | This example uses the REGEX function; see Shipping Zip Code if you aren’t familiar with regular expressions. |
| Error Message: | ZIP code must be in 99999 or 99999-9999 format. |
| Error Location: | Billing Zip/Postal Code |
Shipping Zip Code
| Field | Value |
|---|---|
| Description: | Validates that the account Shipping Zip/Postal Code is in 99999 or 99999-9999 format if Shipping Country is USA or blank. |
| Formula: | This example interprets a blank country as the US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case-sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule isn’t enforced when the country is “usa.” You can also validate ZIP codes using a regular expression; for an example of a formula using a regular expression, see REGEX. |
| Error Message: | ZIP code must be in 99999 or 99999-9999 format. |
| Error Location: | Shipping Zip/Postal Code |
Valid Billing State (US)
Valid Billing Province (Canada)
| Field | Value |
|---|---|
| Description: | Validates that the account Billing State/Province is a valid two-character abbreviation if Billing Country is CA or CAN. |
| Formula: | |
| Error Message: | A valid two-letter province code is required. |
| Error Location: | Billing State/Province |
Valid Shipping State
| Field | Value |
|---|---|
| Description: | Validates that the account Shipping State/Province is a valid two-character abbreviation if Shipping Country is US, USA, or blank. |
| Formula: | This example interprets a blank country as the US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case-sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule isn’t enforced when the country is “usa.” |
| Error Message: | A valid two-letter state abbreviation is required. |
| Error Location: | Shipping State/Province |
Valid Shipping Province (Canada)
| Field | Value |
|---|---|
| Description: | Validates that the account Shipping State/Province is a valid two-character abbreviation, if Billing Country is CA or CAN. |
| Formula: | |
| Error Message: | A valid two-letter province abbreviation is required. |
| Error Location: | Shipping State/Province |
Valid Billing Country
| Field | Value |
|---|---|
| Description: | Validates that the account Billing Country is a valid ISO 3166 two-letter code. |
| Formula: | |
| Error Message: | A valid two-letter country code is required. |
| Error Location: | Billing Country |

