Conditional Validation Support in Rudder CLI
Alpha
Enforce context-specific validation rules for your event schemas and custom data types.
Available Plans
enterprise
4 minute read
Date: Oct 1, 2025
RudderStack’s Tracking Plans enable data teams to apply type-safe governance to event schemas. While our governance features ensure consistency and predictability, real-world applications often require schemas to adapt based on business context.
With the release of Conditional Validation, you can now define validation rules that dynamically adjust based on discriminator properties. This powerful capability addresses a common challenge — maintaining strict data quality standards while accommodating legitimate variations in your event data structure.
With conditional validation, you can:
Define context-aware validation rules that adapt based on specific property values
Prevent event proliferation by consolidating similar events with varied requirements
Enforce granular validation on custom types that need to behave differently in different scenarios
Maintain data quality without sacrificing flexibility for legitimate business variations
You can leverage conditional validation both on the event schema level and within custom types, and manage everything via workspace configuration files using Rudder CLI.
Use cases
This section provides some examples of using the conditional validation feature.
Event-level conditional validation
Adaptive page tracking: Single Page Viewed event with different required properties based on page type — for example, search term for search pages, product details for product pages, checkout step for checkout pages
Context-aware form submissions: Different required fields based on form type or user journey stage
Dynamic feature usage tracking: Varying property requirements based on feature context or user role
See Event Rule Variants for more details on creating and managing event rule variants in your Tracking Plans using Rudder CLI.
Custom type conditional validation
Regional address formats: Different required fields for US addresses (state + ZIP) vs. UK addresses (postcode) vs. Japanese addresses (prefecture + district)
Manufacturer vs. marketplace products: Require MSRP and Manufacturer ID for direct products, and require Seller ID for marketplace items
Account tier-specific profiles: Different required profile fields for individual vs. business vs. enterprise accounts
See Custom Type Variants for more details on creating and managing custom type variants using Rudder CLI.
How it works
Conditional validation uses discriminator properties to determine which validation rules apply. A discriminator is a required property whose value triggers specific validation cases.
For example, in an ecommerce tracking scenario:
Discriminator property: page_type (enumerated list defined in Data Catalog)
Variant cases:
When page_type = search_page: Require the search_term property
When page_type = product: Require the product object property
Result: Same event handles both scenarios with appropriate validation.
Implementation
Conditional validation works at two levels:
Event rule variants
Define variants within your tracking-plans.yaml to create context-aware event validation:
version:"rudder/v0.1"kind:"tp"metadata:name:"ecommerce_tracking_plan"spec:id:"ecommerce_tracking_plan"display_name:"Ecommerce Store - Tracking Plan"description:"Comprehensive tracking plan for the casual apparel e-commerce demo site built with React TypeScript. Captures user behavior across product discovery, cart interactions, and purchase completion for analytics and optimization."rules:- type:"event_rule"id:"page_viewed_rule"event:$ref:"#/events/ecommerce_events/page_viewed"allow_unplanned:falseproperties:# Base properties required for all page views- $ref:"#/properties/ecommerce_properties/page_type"required:true- $ref:"#/properties/ecommerce_properties/page_name"required:false- $ref:"#/properties/ecommerce_properties/page_url"required:false# Conditional Validation Variantsvariants:- type:discriminatordiscriminator:"#/properties/ecommerce_properties/page_type"cases:- id:product_pagedisplay_name:"Product Detail Page"match:- "product"description:"When user is viewing a specific product page"properties:- $ref:"#/properties/ecommerce_properties/product"required:true- id:search_pagedisplay_name:"Search Results Page"match:- "search"description:"When user is on search or category pages"properties:- $ref:"#/properties/ecommerce_properties/search_term"required:true# Default case for home and other pages (only page_url required)default:- $ref:"#/properties/ecommerce_properties/page_url"required:true%
Custom type variants
Define variants within your custom-types.yaml to create reusable, context-aware object types:
version:"rudder/v0.1"kind:"custom-types"metadata:name:"ecommerce_types"spec:types:# Product Type - Consolidates all product-related properties with conditional MSRP validation- id:Product_Objectname:"Product_Object"description:"Custom type for product information with conditional manufacturer pricing validation"type:"object"properties:- $ref:"#/properties/ecommerce_properties/product_id"required:true- $ref:"#/properties/ecommerce_properties/product_sku"required:true- $ref:"#/properties/ecommerce_properties/product_name"required:true- $ref:"#/properties/ecommerce_properties/product_category"required:true- $ref:"#/properties/ecommerce_properties/product_price"required:true- $ref:"#/properties/ecommerce_properties/manufacturer_pricing"required:false# Conditional Validation Variants for Product Objectvariants:- type:discriminatordiscriminator:"#/properties/ecommerce_properties/manufacturer_pricing"cases:- id:with_manufacturer_pricingdisplay_name:"Product with Manufacturer Pricing"match:- truedescription:"Products that have manufacturer suggested retail price (MSRP)"properties:- $ref:"#/properties/ecommerce_properties/product_msrp"required:true
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.