aov.ai-checkout-upsell
✅ Checkout Validations
Regex Validation

Regex Validation

Validate checkout fields against regex patterns to block orders with incorrectly formatted data. Use preset patterns from a built-in library or write your own custom regex.

Available on all Shopify plans. Regex Validation uses Shopify Functions — no Shopify Plus required.


What it does

Regex Validation lets you create pattern-matching rules that validate what buyers type into checkout fields. When a field value doesn't match the expected format, checkout is blocked and the buyer sees a clear error message.

  • Address formatting — ensure addresses contain both letters and numbers, block entries with special characters or emoji
  • Name validation — detect invalid characters like @, #, ! in name fields
  • Phone numbers — enforce international phone number formats
  • Postal codes — validate ZIP/postal code formats for specific countries (US, Canada, UK)
  • Email format — enforce valid email structure
  • Custom patterns — write your own regex for any validation scenario

Each rule targets one checkout field and shows a custom error message at a position you choose. To validate multiple fields, create multiple rules.


Step 1: Go to Checkout Validations

In the app sidebar, click Checkout Validations. You'll see the list of all validation rules.

List page overview

FeatureDescription
SearchFind rules by name
Status filterFilter by status (Active, Test mode, etc.)
TableShows rule name, type badge ("Regex validation"), status, summary, and actions
ActionsActivate/Deactivate, Edit, Delete for each rule
Bulk actionsSelect multiple rules to activate, deactivate, or delete

Step 2: Create a new rule

Click Create validation (top right), then select Regex validation. The editor opens with a 2:1 layout — settings on the left, summary and preview on the right.


Step 3: Set name and status

SettingDescription
Rule nameA descriptive name for your reference (e.g., "US ZIP code format")
StatusActive — rule applies at checkout. Test mode — only triggers when checkout email is [email protected]. Expired — rule is saved but not applied. (You can also pause a rule from the list page to stop it without deleting it.)

Tip: Start with Test mode to verify the rule works correctly before activating it for all customers.


Step 4: Choose the target field

Select the checkout field this rule will validate. Each rule applies to exactly one field.

Target field
First name
Last name
Company
Address line 1
Address line 2
City
ZIP/Postal code
Phone
Email

Step 5: Select the pattern source

Choose how to define your regex pattern using the two options:

OptionWhen to use
Use preset pattern (default)Pick from 13 ready-made patterns organized in 4 categories — no regex knowledge needed
Enter custom patternWrite your own regex for advanced or specific validation needs

Option A: Use a preset pattern

Click "Choose a pattern" (or "Change" if one is already selected) to open the Preset Pattern Library modal. The library contains 13 patterns in 4 categories:

Address Validation

PatternDescriptionValid examplesInvalid examples
Address validationLetters, numbers, spaces, commas, hyphens, dots only123 Main St, 45-B Oak Ave@#!, John@Home
Must contain letters and numbersValue must include at least one letter and one numberJohn123, 45B, Apartment 12A123, MainStreet
Not only numbersCannot be only numbers and spaces123 Main, Suite A123, 456 789
Complete street addressRequires both letters and numbers — ensures a full street address123 Main St., 45-47 Oak Ave123, Main Street

Text Validation

PatternDescriptionValid examplesInvalid examples
Name validationDetects invalid characters in names — blocks: | \ / . , ! @ # $ % ^ & * ?Jose Silva, O'Connor, Mary-AnneJohn@Doe, Jane#Smith
Only letters and spacesLetters, spaces, and hyphens onlyJohn Doe, Main StreetJohn123, Main St.
Only numbersDigits only12345, 999123abc, 12.34
Alphanumeric onlyLetters and numbers, no spaces or special charactersABC123, Product1ABC-123, Product 1

Note: The "Name validation" preset uses blocklist mode ("Must NOT match") by default — it blocks input that contains invalid characters. All other presets use allowlist mode ("Must match").

Contact Information

PatternDescriptionValid examplesInvalid examples
Valid email formatStandard email format[email protected]user@domain
Phone number (international)International phone number format+1234567890, 5551234567123abc, 12345

Postal Codes

PatternDescriptionValid examplesInvalid examples
US ZIP codeUS format: 12345 or 12345-678912345, 12345-67891234, 123456
Canadian postal codeCanadian format: A1A 1A1K1A 0A6, M5V3A812345, ABC123
UK postal codeUK format: SW1A 1AASW1A 1AA, M1 1AA12345, ABC

Each preset card shows the pattern name, regex expression, and valid/invalid examples so you can understand what it does without knowing regex. Click a card to select it, then click "Select pattern".

Tip: Postal code patterns work best when combined with a Shipping country condition (see Step 8) — for example, enforce the US ZIP code pattern only when shipping to the United States.

Option B: Enter a custom pattern

Select "Enter custom pattern" and type your regex directly into the pattern input field. The field uses a monospace font for readability.

The regex pattern is checked as you type. If the expression is invalid, you'll immediately see an inline error: "Invalid regex pattern. Please check your expression." The field also shows a hint — for custom patterns: "Enter a valid JavaScript regular expression"; for presets: "Auto-filled from preset. You can edit the pattern directly."


Step 6: Set the match mode

Choose how the pattern is applied:

ModeBehaviorUse case
Input must match this pattern (default)Allowlist — checkout is blocked if the field value does NOT match the patternEnforce a specific format (e.g., US ZIP code must be 5 digits)
Input must NOT match this patternBlocklist — checkout is blocked if the field value DOES match the patternBlock invalid characters (e.g., names containing @, #, !)

When using "Must NOT match" mode, a yellow warning box explains: "Checkout is blocked if the field value DOES match the pattern (blocklist mode)." This helps avoid confusion about the reversed logic.


Step 7: Test your pattern

Before saving, use the built-in test tool to verify your pattern works as expected. This section appears below the pattern settings.

  1. Enter a sample value in the text input (e.g., "John123", "+84901234567", "90210")
  2. Click "Test"
  3. See the result:
    • Would pass (green check) — the buyer can complete checkout with this input
    • Would be blocked (red X) — the buyer would see the error message with this input

The test runs entirely in your browser — no server call, instant results.

Example:

  • Pattern: "Only letters and spaces" (^[a-zA-Z\s-]+$), Match mode: "Must match"
  • Sample input: "John123" → Would be blocked (contains numbers)
  • Sample input: "John Smith" → Would pass

The Test button is disabled when the regex pattern field is empty or contains an invalid expression.


Step 8: Configure error message and position

Error message

Enter the message buyers will see at checkout. A default message is generated based on your target field and match mode — you can customize it.

Examples of default messages:

  • "Please enter a valid ZIP/postal code."
  • "Please enter a valid phone number."
  • "This format is not allowed in the first name field."

Keep messages clear and actionable — tell buyers what format is expected.

Editing the message: By default the message field may be read-only and show a banner: "Want to customize your checkout error message? Contact us to update for free." Click Contact us to have the team enable custom messages for your store. When you change the target field or match mode, the default message updates automatically.

Error position

Choose where the error message appears on the checkout page:

PositionDisplay
Top of the checkout pageRed banner at the top of the page — most visible
First nameInline error below the First name field
Last nameInline error below the Last name field
CompanyInline error below the Company field
Address line 1Inline error below Address line 1
Address line 2Inline error below Address line 2
CityInline error below the City field
Email or phone numberInline error below the Email/Phone field
Delivery phoneInline error below the Delivery phone field
ZIP / Postal codeInline error below the ZIP code field
CountryInline error below the Country dropdown
Province / StateInline error below the Province/State dropdown

Recommended: Set the error position to match the target field. For example, if you're validating the ZIP/Postal code field, place the error at "ZIP / Postal code" so buyers know exactly which field to fix.


Step 9: Set additional conditions (optional)

By default, the rule applies to all checkouts. To narrow the scope, expand the Additional Conditions section at the bottom of the editor and select "Set conditions".

ConditionDescription
Included product (or variant)Rule only applies when the cart contains this product
Excluded product (or variant)Rule does NOT apply when the cart contains this product
Customer tagRule only applies when the customer has (or doesn't have) this tag
Shipping countryRule only applies for orders shipping to a specific country

All conditions use AND logic — the regex pattern AND every additional condition must be satisfied for the rule to trigger.

Common combinations:

  • US ZIP code pattern + Shipping country = United States
  • UK postal code pattern + Shipping country = United Kingdom
  • Name validation + Customer tag = "B2B"

Step 10: Preview and save

The right sidebar shows a live summary of your rule configuration and a preview of how the error message will appear.

Summary

The summary card displays your current settings at a glance:

RowExample value
ConditionAll checkouts
Target fieldZIP/Postal code
PatternUS ZIP code
Match modeMust match
PositionZIP / Postal code

Checkout preview

Click "Preview" to open a full-screen modal showing the complete checkout layout with your error message rendered at the correct position.

When everything looks good:

  1. Set the Status to your preferred option
  2. Click Save in the top bar

The rule takes effect at checkout immediately.


Test your rule with Test Mode

Before activating a rule for all customers, test it first:

  1. Set the rule Status to Test mode and save
  2. Go to your store and add products to the cart
  3. Proceed to checkout
  4. Enter [email protected] as the checkout email
  5. In the target field, enter a value that should be blocked by your pattern
  6. Complete the checkout form and click "Pay now" or "Continue to shipping"
  7. Verify the error message appears at the correct position
  8. Once verified, change the status to Active

Test mode only works with the email [email protected]. All additional conditions (if any) must also be satisfied for the rule to take effect.


App failure fallback

The editor includes an App Failure Fallback toggle (enabled by default):

SettingDefaultDescription
Allow customer to complete checkout if the app failsOnIf the app encounters an error or times out, the buyer can still complete checkout — prevents accidentally blocking all orders due to a technical issue

We recommend keeping this toggle on to avoid blocking buyers due to unexpected app errors.


Manage existing rules

Toggle status

Use the Pause / Start action on any rule to quickly toggle its status without opening the editor.

Edit a rule

Click the edit icon (pencil) in the Actions column, or click the rule name to open the editor.

Delete rules

  • Single rule: Click the delete icon (trash) in the Actions column
  • Bulk delete: Select multiple rules with checkboxes → click Delete rules

Other bulk actions: Activate rules, Deactivate rules.

Deletion is permanent. The rule cannot be recovered.


Tips

  • Start with Test mode — verify the rule works correctly before activating for all customers
  • Use preset patterns first — the built-in library of 13 patterns covers most common needs, no regex knowledge required
  • Match error position to target field — place the error at the same field you're validating so buyers know exactly what to fix
  • Combine with shipping country — pair postal code patterns with a Shipping country condition to enforce the right format per country
  • Test both valid and invalid inputs — use the built-in Test tool to check multiple sample values before saving
  • Keep messages actionable — tell buyers the expected format (e.g., "Please enter a 5-digit ZIP code" instead of "Invalid input")
  • One field per rule — to validate multiple fields, create separate rules for each
  • Need more rules? — the free plan includes 1 validation rule (shared across all checkout-validation types). Use the Contact us link in the app to have more rules unlocked

FAQs

General

Q: Do I need Shopify Plus for Regex Validation? A: No. Regex Validation uses Shopify Functions, which are available on all Shopify plans.

Q: Do I need to know regex to use this feature? A: No. The Preset Pattern Library provides 13 ready-made patterns with descriptions and examples. Select one and it works immediately. Custom regex is only needed for advanced use cases.

Q: How many rules can I have? A: The free plan includes 1 validation rule, counted across all checkout-validation types (Custom Rules, Geo Restriction, Address Validation, Regex, VAT, and Order Limits combined — active, paused, and test-mode rules all count). To create more, use the Contact us link in the app to have additional rules unlocked.

Q: Do rules take effect immediately after saving? A: Yes. Once a rule is set to Active and saved, it applies to all new checkouts immediately.

Q: Can I validate multiple fields with one rule? A: No. Each rule targets one field. Create separate rules for each field you want to validate.

Patterns and matching

Q: What's the difference between "Must match" and "Must NOT match"? A: "Must match" (allowlist) blocks checkout when the input does NOT match the pattern — use it to enforce a specific format. "Must NOT match" (blocklist) blocks checkout when the input DOES match the pattern — use it to block specific characters or formats.

Q: What happens if my custom regex pattern is invalid? A: The app validates your regex when you save. If it's invalid, you'll see an error and the rule won't be saved. If an invalid pattern somehow reaches checkout, the rule is skipped — it won't block any buyers.

Q: Does the regex support Unicode characters (accents, Asian scripts)? A: Yes. The regex engine supports Unicode, so patterns work with accented characters, Asian scripts, and other non-ASCII text.

Q: Is the regex case-sensitive? A: Yes, by default. To match both uppercase and lowercase letters, use [A-Za-z] in your pattern instead of just [A-Z] or [a-z].

Checkout behavior

Q: What happens if the buyer leaves a field empty? A: The rule does not trigger for empty fields. It only validates when the buyer has entered content. Empty fields always pass regex validation.

Q: What happens if multiple rules trigger at the same time? A: All matching rules display their error messages. Buyers must resolve all errors before completing checkout.

Q: Does the error block checkout or just show a warning? A: The error blocks checkout — buyers cannot complete their purchase until they correct the field value.

Q: Can I use different languages in the error message? A: Yes. Enter the message in any language you prefer — it will display exactly as typed.

Conditions

Q: What does "No condition" mean for additional conditions? A: It means the regex rule applies to every checkout. Any buyer whose field input fails the pattern check will see the error.

Q: Can I apply a postal code rule only to specific countries? A: Yes. Use the Shipping country additional condition. For example, set the US ZIP code preset and add a condition for "United States" — buyers shipping to other countries won't be affected.

Product
Install AppWebsiteAvada Apps
Resources
DocumentationFAQPrivacy Policy
Company
Avada GroupContact
© 2026 Avada Group. All rights reserved.