Constraints
One container, automatic binding
Constraints are reusable validation rules attached through a single constraints container on Blocks and members — there is no target property, because the embedding context binds the constraint automatically.
Which branch fits which context
A constraint's branch must match the definition it is attached to — a value constraint binds to a Property's effective ValueType, while structural constraint branches bind to the Aggregation, Association, Capability, or Block definition that embeds them, and a mismatch is a checked error.
When a constraint is enforced
A constraint's optional validation property decides how a violation is reported — omitted, the constraint remains metadata for renderers and editors rather than a rule the BlockML validator enforces.
Constraining a Property's value
A Property can attach a value constraint whose generic type parameter binds automatically from the Property's own type — no target or type argument is authored explicitly.
<!-- Min's generic parameter T binds to Integer purely from context -->
<acme:Basket xmlns="http://blockml.org/bml"
xmlns:acme="com.acme.example"
xmlns:core="org.blockml.bml.core"
xmlns:type="org.blockml.bml.type"
xmlns:constraint="org.blockml.bml.constraint"
xmlns:validation="org.blockml.bml.validation">
<baseType>
core:Block
</baseType>
<properties>
<count type="type:Integer">
<value>3</value>
<constraints>
<constraint:Min value="0" validation="validation:Error" />
</constraints>
</count>
</properties>
</acme:Basket>
constraint:Min's generic parameter T binds to count's own type, Integer, purely from context — no target or type argument is written on Min itself. Its validation attribute, validation:Error, is what turns it from metadata into a rule the validator actually enforces, rejecting any count below 0.
What to carry into the next pages
After this page, readers should be able to attach the right constraint branch to a member and know when it is enforced, before Suggestions contrasts non-enforced guidance with what this page just covered.