Skip to content

Element <sourceConstraints>

Purpose: Filter source rows before generated fields are evaluated.

Why: Use it to reject loaded source rows before generated fields and mappings run.

Example

1
<sourceConstraints if="country == 'DE'" require="is_adult"/>

Decision guide

Business value: Rejects invalid input rows before they can influence transformation logic.

  • Use when

    • A loaded source row must satisfy a pre-transformation business rule.
  • Choose another approach when

    • The rule depends on fields created later in the generated product.
  • Prerequisites

    • Use it in a source-driven product where the named source fields are in scope.
  • Alternatives

Complete examples

Filter, transform, and validate source rows in explicit phases

Use source constraints before transformation, mappings in document order, and target constraints only on the completed output row.

rule-pipeline/data/customers.json
1
2
3
4
5
6
[
  {"customer_id": "C-100", "active": true,  "income": 120000, "credit_score": 780},
  {"customer_id": "C-200", "active": false, "income": 90000,  "credit_score": 760},
  {"customer_id": "C-300", "active": true,  "income": 60000,  "credit_score": 700},
  {"customer_id": "C-400", "active": true,  "income": 18000,  "credit_score": 650}
]
rule-pipeline/datamimic.xml
1
2
3
4
5
6
7
8
9
<setup numProcess="1">
    <generate name="eligible_customers" count="4" source="data/customers.json" target="LogExporter">
        <sourceConstraints if="active == False" require="False"/>
        <mapping if="income >= 100000 and credit_score >= 750" set="segment = 'premium'"/>
        <mapping if="not (income >= 100000 and credit_score >= 750)" set="segment = 'standard'"/>
        <mapping if="True" set="monthly_budget = income / 12"/>
        <targetConstraints if="30000 > income" require="False"/>
    </generate>
</setup>

Rules and invalid combinations

E005 — Rule Eval Failed

Failed to evaluate {kind} '{expr}' for <{element_tag}>{descriptor}{cause_clause}

Why: A runtime error was classified in this top-level error category.

Resolution: Inspect the nested issue code and descriptor context for the actionable resolution.

Full rule

Allowed parents / Allowed children

Allowed parents: else, else-if, generate, if, iterate, nestedKey, while

Allowed children:

None

  • Structured Data and Rule Pipelines — Shows how composite output shapes and the ordered source-filter, mapping, and target-filter pipeline work together without hiding phase boundaries.

Attributes

Show all 2 attributes

if

Condition selecting rows to which the constraint applies.

required; string.

require

Requirement expression evaluated for rows selected by if.

required; string.