How to Build Validation Rules?
In this article, we're going to explore the Rules Builder and learn how to build validation rules for campaigns.
Contents
- How does it work?
- Create validation rules with Validation Rules Manager
- Create validation rules with Campaign Manager
- Create validation rules with metadata
- Create validation rules with event metadata
This article shows how to build a validation rule and add validation rules to a campaign. Visit this article to see a complete list of limits and rules that you can create with the Validation Rules Builder.
How does it work?
Rules Builder overview
There are two ways you can access the Rules Builder and create validation rules:
Validation Rules Manager | Campaign Manager |
---|---|
The dedicated Validation Rules section in the dashboard lets you prepare rules for future use. |
When creating/editing campaigns in the Campaign Manager, you can create validation rules and assign them to the campaign upon saving the campaign. |
Rules Builder overview
|
Rules Builder overview
|
You can create limits for redemptions and earning rules using the basic or advanced Builder. Choose the basic Builder to see a shortcut to the most common rules and create popular limits. Choose the advanced Builder to see all possible validation rules you can create.
Visit this article to see a complete list of limits and rules that you can create with the Validation Rules Builder.
Basic Builder | Advanced Builder |
---|---|
Contains a subset of available rules. |
Contains entire list of possible rules. |
Available options
|
Available options
|
Basic rules builder
Choose a rules category and define the limit by using available conditions. You may notice that some rules are unavailable (greyed out). This is because they are context-specific. For example, rules that only make sense to be applied on bulk code campaigns are not available for standalone codes.
Validation Rules available in Basic Rules Builder | |
---|---|
Customer activity that enables you to target specific customer segments and/or exclude particular segments from your promotion.
|
|
Attributes match – order and redemption metadata. In this section, you can build limits based on custom metadata attributes. Please note that you should define these attributes in the metadata schema first. Click here to learn more. |
|
Budget rules that set the limits on total amounts and redemptions; the basic rule builder contains a subset of these Budget Constraints.
|
|
Order-related rules that model a required cart structure and total amount.
|
Expand the rules from the category you're interested in and build a restriction using available operators.
Advanced rules builder
Define the logic between rules (1). Additionally, you can specify a fallback error message that will be used when there is no error message defined for the particular rule (2).
You may notice that some rules are unavailable. This is because they are context-specific. For example, rules that only make sense to be applied on bulk code campaigns are not available for standalone codes.
Validation Rules available in Advanced Rules Builder | |
---|---|
Audience - enables you to target specific customer segments/loyalty tiers and/or exclude particular segments/loyalty tiers from your promotion. Customers enter or leave a segment based on filter criteria. Customers enter or leave a loyalty tier based on the loyalty points balance on their loyalty card. Their loyalty tier can be prolonged if the expiration date is set to a custom date.
|
|
Order structure - lets you create rules based on properties of items or the metadata property of the order
|
|
Order volume - lets you create rules based on order volume, prices, and amount of the order
|
|
Budget constraints - lets you create rules based on a variety of constraints
|
|
Advanced - lets you create rules based on advanced constraints
|
Expand the rules from the category you're interested in and build a restriction using available operators. To define the error message for a particular rule, you can use the Add error message option.
Confirm each rule with Add. All active rules will be visible on the grey background below each category.
Create validation rules with validation rules manager
In this section, you'll see how to use the Rules Builder and create validation rules.
First navigate to Validation Rules manager and click the plus .
Step 1: Name the rules
Add a name for your validation rule/set of rules. They will be automatically saved in the dashboard.
Step 2: Choose between basic and advanced builder
The Builder has two modes: basic and advanced. Choose the basic Builder to see a shortcut to the most common rules and create popular limits. Choose the advanced Builder to see all possible validation rules you can create.
Step 3: Define the context
Validation rules context defines the purpose of validation rules and their future usage. If you want to use the rules in more than one context or campaign type, choose General Usage.
Step 4: Create validation rules
Create limits that need to be met to make a successful redemption or earn loyalty points.
Validation rules limiting redemptions
Validation rules can be assigned to incentives (discounts, coupons, gift cards, digital rewards, referral codes), and earning rules.
- If you attach validation rules to discounts or campaign codes, they will limit their redemptions.
- If you assign validation rules to the earning rules in your loyalty campaign, they will define circumstances that trigger the assignment of new loyalty points. Read more here on creating validation rules for earning new loyalty points.
You can create limits for redemptions and earning rules using the basic or advanced Builder.
Visit this article to see a complete list of limits and rules that you can create with the Validation Rules Builder.
Basic Builder | Advanced Builder |
---|---|
Contains a subset of available rules. |
Contains entire list of possible rules. |
Basic rules builder
Choose a rules category and define the limit by using available conditions. You may notice that some rules are unavailable (greyed out). This is because they are context-specific. For example, rules that only make sense to be applied on bulk code campaigns are not available for standalone codes.
Expand the rules from the category you're interested in and build a restriction using available operators.
Advanced rules builder
Define the logic between rules (1). Additionally, you can specify a fallback error message that will be used when there is no error message defined for the particular rule (2).
You may notice that some rules are unavailable. This is because they are context-specific. For example, rules that only make sense to be applied on bulk code campaigns are not available for standalone codes.
Expand the rules from the category you're interested in and build a restriction using available operators. To define the error message for a particular rule, you can use the Add error message option.
Confirm each rule with Add. All active rules will be visible on the grey background below each category.
Step 5: Confirm and save rules
When rules are added, click Next Step, and then click Save to confirm. Saved rules will be visible in the main list in the Validation Rules.
You can edit or remove created validation rules by clicking on the three dots to the right.
Deleting rules
Note that deleting the rules is not possible as long as they're attached to any of your existing campaigns or rewards. You first need to detach a validation rule by going to the campaign manager or the specific voucher. Then you will have the option of deleting the validation rule from the list.
Create validation rules with campaign manager
In this section, you'll see how to use the Rules Builder and create validation rules.
Step 1: Choose to create a new rule or use an existing rule
- New: Create rule from scratch; continue to step 2 and the then with the remaining steps listed below
- Existing: Choose predefined rule; continue with step 4 and then with the Campaign Manager steps, the remaining steps can be skipped
Step 2: Choose between basic and advanced builder
The Builder has two modes: basic and advanced. Choose the basic Builder to see a shortcut to the most common rules and create popular limits. Choose the advanced Builder to see all possible validation rules you can create.
In the Campaign Manager, you'll see the basic Builder chosen by default. You can switch to the advanced mode to see all available rules.
Step 3: Name the rule
Add a name for your validation rule/set of rules.
Step 4: Define discounted (included) and excluded products
This step is context specific. There are two components in the Rules Builder within the Campaign Manager when you choose to apply a rule on an item level versus a whole cart level.
- The first lets you select which items the discount or gift card can be applied to and which items the discount/gift card can't be applied to. Read more.
- The second component enables you to create limits that need to be met to make a successful redemption or earn loyalty points. Read more.
Select discounted (included) and excluded products
Selecting discounted or excluded items doesn't define required cart items, but defines which items the discount or gift card will be applied to if all validation rules are met.
How to define discounted (included) items?
First, you can choose between Discount Each or Discount Selected. If you choose to discount each, a discount or gift card will be applied to every order line item in the cart, except for the items defined in excluded products.


- Select existing products from your list.
- Create a products collection(s) that defines what criteria items have to match to qualify for a discount.
- Choose from an existing product collection(s).
- Choose the built-in collection All Products to choose all items that a customer provides in the cart.
After choosing products or collections, you can decide if the discount will be applied to all qualified items or only to the cheapest or most expensive of the qualified products.
Note that you can add another component defining discounted items and combine many effects. For example, the discount can be applied to the cheapest and most expensive product in the cart.
Likewise, you can use the same methods to define excluded products. As a result, the discount won't be applied to the selected items. Read more.
Important notes
- If you choose to discount a product collection and add one of its items to excluded products, the discount will be applied only to collection items that are not selected in excluded products.
- If the rules try to force both applying the discount and excluding the same product, the discount won't be applied to this item (it'll be excluded during the redemption). The excluded products rule has priority over included products rule.
-
Adding a product to the static collection is the same as adding all product SKUs to the static collection. When it comes to dynamic collections, if the product matches collection filters, only the product enters the collection; product SKUs are validated against filters and need to match them to enter the dynamic collection.
Step 5: Create validation rules
Create limits that need to be met to make a successful redemption or earn loyalty points.
Validation rules limiting redemptions
Validation rules can be assigned to incentives (discounts, coupons, gift cards, digital rewards, referral codes), and earning rules.
- If you attach validation rules to discounts or campaign codes, they will limit their redemptions.
- If you assign validation rules to the earning rules in your loyalty campaign, they will define circumstances that trigger the assignment of new loyalty points. Read more here on creating validation rules for earning new loyalty points.
You can create limits for redemptions and earning rules using the basic or advanced Builder.
Visit this article to see a complete list of limits and rules that you can create with the Validation Rules Builder.
Basic Builder | Advanced Builder |
---|---|
Contains a subset of available rules. |
Contains entire list of possible rules. |
Basic rules builder
Choose a rules category and define the limit by using available conditions. You may notice that some rules are unavailable (greyed out). This is because they are context-specific. For example, rules that only make sense to be applied on bulk code campaigns are not available for standalone codes.
Expand the rules from the category you're interested in and build a restriction using available operators.
Advanced rules builder
Define the logic between rules (1). Additionally, you can specify a fallback error message that will be used when there is no error message defined for the particular rule (2).
You may notice that some rules are unavailable. This is because they are context-specific. For example, rules that only make sense to be applied on bulk code campaigns are not available for standalone codes.
Expand the rules from the category you're interested in and build a restriction using available operators. To define the error message for a particular rule, you can use the Add error message option.
Confirm each rule with Add. All active rules will be visible on the grey background below each category. Continue on with the Campaign Manger steps.
Step 6: Confirm and save campaign
When rules are added, they do not automatically get created. You must go through the steps of the Campaign Manager and click Save to confirm. The rules are created when you save a campaign.
Custom validation rules with metadata
Metadata enables you to add custom attributes to your Voucherify project. Metadata added to products, order line items, customers, orders, and redemptions can be used when creating validation rules. Supporting many metadata types and validation operators gives you flexibility in creating custom limits and rules which aren't available out-of-the-box.
Before you start
All metadata attributes that you use in validation rules, should be added to your Project settings > Metadata schema first. Read more.
To create a custom limit with metadata follow the steps below:
- Add new metadata definition to the respective metadata schema. Read more.
- Open advanced Rules Builder in the Validation Rules menu or in the Campaign Manager.
- Expand the rules from a chosen category, build the rule with metadata and available conditions.
- Confirm with Add.
Take a look at the examples below to see popular validation rules with metadata. Navigate to the respective section by clicking on the link below.
Product metadata
Important
Remember that all metadata used in validation rules should be added to the Product schema.
Product metadata in the Rules Builder has two goals:
- What's in vs. what's out: You can define custom product attributes that qualify or disqualify a product from applying the discount or gift card. Go here for the detailed instructions.
Order Structure: You can also define the required cart structure. It comes down to defining the specific custom attributes that products in a customer's cart need to have or can't have to redeem the code/ earn loyalty points. In addition to metadata, you can set additional criteria for matching items, such as items count and subtotal. We’ll show you how to do this in the steps listed below.
Create order structure validation rules with metadata
Step 1: Go to the Rules Builder and expand Order structure validation rules.
Step 2: Decide if the metadata has to be attached to every, any, none of the order items or perhaps to the cheapest or most expensive of the order items. Mark the respective checkbox.
Step 3: Click to build filter(s) with metadata added previously to the Product metadata schema.
Step 4: When creating filters , you can combine many metadata and standard product attributes. After you add all filters, click
The collection will save the added filters to validate each product/SKU coming with requests. Only items that meet collection criteria will join the collection list.
Here's the instruction on how to build product filters with metadata.
Step 5: If you choose Every or Any order item, you can also define the quantity and subtotal of matching items.
You can also define the required price and quantity of every/any matching order line item.
Any order item
Please note that for rules, each sub-rule can be matched by a different order line item
Important note
"AND" means that both rules need to be met. "AND" doesn't mean both rules need to be met by the same order line item. If each rule will be met by a different order line item, validation will succeed.
Rules examples
- Every item in the cart needs to have a metadata category is spring_sale and metadata vendor Levi's or Guess.
- At least one item in the cart needs to have a metadata category is new_in_stock and the subtotal of matched items needs to be more than $100.
- None of the items in the cart can have a metadata category is premium.
Order line item metadata
Important
Remember that all metadata used in validation rules should be added to the Order line item schema.

Each order line item can have its metadata attributes on top of which you can create validation rules. To create rules with order line item metadata, follow the steps below:
- Expand Order structure rules
- Mark Any order item if at least one order line item needs to match metadata rules or Every order item if all order line items need to match metadata rules. You can also choose the Cheapest of the order items or the Most expensive of the order items. Read more.
- Click
to choose a product collection. In this step, you can narrow down the list of items that will be checked against metadata rules. If you don't want to set additional filters, choose a predefined collection called All Products that gathers all order items. Read more.
- Choose
and define validation rules with the metadata attribute.
Customer metadata satisfy
Important
Remember that all metadata used in validation rules should be added to the Customer schema.
You can use attributes added to the Customer schema to create custom rules not available out-of-the-box. Using metadata-based segments or single attributes, you can limit redemptions to customers who share a specific metadata value(s). Customer metadata provides personalization, targeting, and geofencing in your promotions.
Click property and choose a pre-defined metadata property from the list of displayed properties or add a new definition by clicking the
option.
Rules examples
- Only customers whose metadata customer_lifetime_value is more than 2000 can redeem the discount.
- Customers whose metadata billing_unpaid is true cannot redeem the discount.
- Customers whose metadata subscription is premium can redeem gift cards from campaign X.
Order metadata satisfy
Important
Remember that all metadata used in validation rules should be added to the Order schema.
Orders enable you to pass your transactional data to Voucherify. Using order metadata and validation rules, you can define additional conditions that the customer's order has to match to redeem incentives or earn loyalty points.
Click property and choose a pre-defined metadata property from the list of displayed properties or add a new definition by clicking the
option.
Rules examples
- Voucher can be redeemed only if the metadata Shipping_postal_code starts with 43-.
- Customer gets 50 loyalty points if the order total amount is more than $100 and metadata shipped is true.
- Customers get - 50% if the order metadata takeaway is false and - 25% if the order metadata takeaway is true.
- Customers can redeem the code if the order was placed in July between 10 AM and 1 PM (metadata booking_date is within time-frame 6/1/2021 - 6/30/2021 Every day 10:00 AM to 1 PM).
Redemption metadata satisfy
Important
Remember that all metadata used in validation rules should be added to the Redemption schema first.
You can attach metadata to redemption requests. Redemption metadata in validation rules lets you define additional attributes that need to be passed to successfully redeem codes/promotions.
Click and choose a pre-defined metadata property from the list of displayed properties or add a new definition by clicking the
option.
Rules examples
- Voucher can be redeemed only if metadata payment_method is credit_card.
- Customers can redeem a $10 gift card if the metadata booking_channel is homepage.
- Customers get a free item X (unit discount) if redemption was made in July between 10 AM and 1 PM (metadata booking_date is within time-frame 6/1/2021 - 6/30/2021 Every day 10:00 AM to 1 PM).
Custom validation rules with custom events
Custom events are actions taken by your customers. You can use them to track clients' behavior and then build highly personalized campaigns. Voucherify enables you to create a validation rule for loyalty earning rules based on custom event metadata.
Before you start
All custom events that are used in validation rules, should be added to your Project settings > Event Schema first. Read more.
Custom event metadata satisfy
Important
Remember that all metadata used in validation rules should be added to the Event Schema schema first.
You can attach custom event metadata to a loyalty earning rule's validation rule. Custom event metadata in validation rules lets you define additional attributes that need to be passed to successfully earn loyalty points. Read more here.
Rules examples
- Loyalty points can be earned only if custom event entered_store metadata property customer_entered_store is true.
- Loyalty points can be earned only if custom event visit_website metadata property booking_channel is homepage.
- Loyalty points can be earned only if custom event page_view metadata property page_view_date is on Tuesday.