Setting up address format validation in Checkout Blocks
You can validate customer shipping addresses and block checkout for orders that contain addresses that don't match your required format. For example, you can block PO box addresses to ensure that orders can be fulfilled to physical locations, or restrict checkout for specific ZIP codes. Customers must fix invalid shipping address fields before they can continue with checkout. Billing address fields aren’t validated.
On this page
Set up address format validation with the Checkout Blocks app
Steps:
From your Shopify admin, go to Apps > Checkout Blocks.
Click Functions, and then click Create function.
In the Validation section, click Address format validation.
Enter a title for the validation rule.
Optional: In the Markets section, click Add a market to select specific region-based markets. By default, the validation applies to all markets. Only region markets are supported.
Turn on one or more validation rules. For each rule that you turn on, complete the following steps:
- In the Validated fields section, click the
+icon to select the address fields that the rule applies to. - Optional: For rules that support custom error messages, click the
icon next to the Error message field to customize the message that your customers receive at checkout. Keep error messages short and specific. Example: “Enter a street address (no PO boxes)."
- Configure any additional settings for the rule, such as character limits or patterns.
- In the Validated fields section, click the
Click Save.
After you set up address format validation, the function is saved as Inactive. To activate the function, select Active from the status dropdown, and then click Save.
Supported rules for address format validation
The following rules are available when setting up address format validation in the Checkout Blocks app.
| Rule | Description |
|---|---|
| Block specific address types | Prevent checkout for specific address types, including diplomatic, military, parcel locker, PO box, and USPS gopost®. |
| Block specific ZIP/postal codes | Block checkout for addresses that contain or don't contain specific ZIP/postal codes. Separate multiple codes with a comma. Use * as a wildcard, such as 100** for 10000–10099. |
| Enforce character counts | Set minimum or maximum character limits on address fields. Allow enough room for longer international addresses. |
| Require specific fields | Make optional fields required for checkout to proceed. |
| Custom validation | Block checkout when fields match a regular expression (regex) pattern. Patterns can be generated from a description or entered manually. Start with broad rules before adding regex. Overly strict patterns can block valid addresses. |
Limitations
At this time, only shipping addresses are validated. Billing address fields aren’t supported and can’t be targeted by rules.
Unsupported rules
The following rules from the deprecated Address Blocker aren't available in address format validation:
- Block non-ASCII characters: Checkout already prevents emojis, special symbols, HTML tags, and URLs in address fields. A separate rule isn't required.
- Require street number: Requiring a street number isn't supported in address format validation. You can require additional address fields in your checkout settings instead.