Action References
ValidationAction
ValidationAction
Purpose Perform a domain-specific boolean check via MScript (quotas, object states, feature flags, plan limits, etc.).
When to use it
afterCheckParameters(input sanity/business rules)afterFetchInstance/afterCheckInstance(state-based rules: locked, archived, protected)- Anywhere a domain invariant must be upheld
Key fields
| Field | Type | Notes |
|---|---|---|
description | Text | Human explanation of the rule. |
shouldBeTrue | Boolean | Defaults to true. If the script’s result ≠ shouldBeTrue, validation fails. |
checkType | ApiCheckType | liveCheck (throw error immediately) or storedCheck (write result to context). |
validationScript | MScript | Returns boolean. |
errorMessage | String | Message if liveCheck fails. |
errorStatus | ErrorStatus | Important: 401/403 = authorization error (absolute roles bypass); 400 = business rule (absolute roles do not bypass). |
Behavior & absolute roles
- If
errorStatusis 401/403, failures are treated as authorization; users with absolute roles bypass. - If
errorStatusis 400, failure is a business rule; no bypass—even for absolute roles. - With
storedCheck, result is put on context (e.g.,this.validation_<name>), and the flow continues.
Example — forbid updates to protected items as business logic
{
"id": "a200-validate-protected",
"name": "preventProtectedUpdate",
"description": "Protected items cannot be modified.",
"validationScript": "this.instance?.isProtected === false",
"shouldBeTrue": true,
"checkType": "liveCheck",
"errorMessage": "This item is protected and cannot be modified.",
"errorStatus": "400"
}
Example — treat as authorization (allow absolute roles to bypass)
{
"id": "a201-validate-approval-role",
"name": "requireApproverRole",
"description": "Only approvers may change this state.",
"validationScript": "this.session.roles?.includes('approver')",
"shouldBeTrue": true,
"checkType": "liveCheck",
"errorMessage": "Approver role required.",
"errorStatus": "403"
}
Was this page helpful?
Built with Documentation.AI
Last updated Jan 3, 2026