Rules and validation
Express business conditions without scripts in views.
Declare a condition
Rules express conditions on values, relations or Query results. The Model uses them for validation, Action availability or transitions. Views present the decision without becoming a second business authority.
| Condition | Expected values | Purpose |
|---|---|---|
| Presence | Field reference | Check required information |
| Comparison | Field, admitted operator and typed value | Compare an amount or status |
| Membership | Field and admitted values | Accept several states |
| Relation | Type, direction and cardinality | Require a linked client |
| Query | Declared Query and admitted parameters | Check a collection or aggregate |
| Combination | Bounded boolean expressions | Combine conditions |
Useful messages
A failed rule explains what is missing and where to correct it. “Select a client before finalizing” guides the user. Contract names or technical errors do not replace that message.
Example
Finalizing a quote requires a linked client, positive amount and approval. The record can show missing conditions, but the service checks again at confirmation. A disabled button is not an authorization control.
Expression trees are declarative and bounded. Their reference describes admitted variants; rules do not execute JavaScript or SQL supplied by a view.
Applied examples : Check before confirming
One rule requires a company; another rejects a zero or negative amount.
Configuration
Fragment placed in rules[]. Properties and accepted values.
{
"contract": "WorkspaceRule@1",
"key": "company-required",
"label": "Company provided",
"expression": {
"kind": "present",
"field": {
"definitionPath": "workspace/clients/surface/client",
"fieldKey": "company"
}
}
}
Variation and connection
Fragment placed in rules[]. Properties and accepted values.
{
"contract": "WorkspaceRule@1",
"key": "positive-amount",
"label": "Positive amount",
"expression": {
"kind": "compare",
"field": {
"definitionPath": "workspace/quotes/surface/quote",
"fieldKey": "amount"
},
"operator": "gt",
"value": 0
}
}
UI layout example
The illustrative layout below places this configuration in the Clients/Quotes app. Insert each fragment at the stated location, with Field, Query and Action references matching the Model declarations.
- Company *
- Status *
- Notes
- Create client
Add notes to the record after creation.