Skip to content

Element <targetConstraints>

Purpose: Validate, filter, or amend generated rows before export.

Why: Use it to reject a completed generated row immediately before export.

Example

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

Decision guide

Business value: Prevents a completed invalid product row from reaching its exporter.

  • Use when

    • A rule depends on final generated or mapped output fields.
  • Choose another approach when

    • The rule concerns only the original loaded source row.
  • Prerequisites

    • Place it after the fields and mappings whose results it checks.
  • Alternatives

    • Use sourceConstraints to reject rows before transformation. (See: <sourceConstraints>)
    • Use assert for a run-level hard invariant. (See: <assert>)

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.