Action ReferencesValidationAction
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

FieldTypeNotes
descriptionTextHuman explanation of the rule.
shouldBeTrueBooleanDefaults to true. If the script’s result ≠ shouldBeTrue, validation fails.
checkTypeApiCheckTypeliveCheck (throw error immediately) or storedCheck (write result to context).
validationScriptMScriptReturns boolean.
errorMessageStringMessage if liveCheck fails.
errorStatusErrorStatusImportant: 401/403 = authorization error (absolute roles bypass); 400 = business rule (absolute roles do not bypass).

Behavior & absolute roles

  • If errorStatus is 401/403, failures are treated as authorization; users with absolute roles bypass.
  • If errorStatus is 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