🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Parsed/OCLOperators constraints
This page was created by PageReplicator on 2025-09-01. Last edited by PageReplicator on 2025-09-01.

Template:Notice



This operator returns both meta information about a class's constraints and if it's currently broken.

The return value is a collection of <a href="/Documentation:Tuple" title="Documentation:Tuple" data-bs-title="Documentation:Tuple">Tuple</a> containing the following:

  1. Name
  2. Description
  3. IsDeleteConstraint: True/False
  4. ErrorLevel: #Information, #Warning or #Error
  5. Broken: Evaluated and <a href="/BestPractices:Subscribed" title="BestPractices:Subscribed" data-bs-title="BestPractices:Subscribed">Subscribed</a> state of the constraint

Examples[<a href="/index.php?title=Documentation:OCLOperators_constraints&veaction=edit&section=1" class="mw-editsection-visualeditor" title="Edit section: Examples" data-bs-title="Documentation:OCLOperators_constraints">edit</a> | <a href="/index.php?title=Documentation:OCLOperators_constraints&action=edit&section=1" title="Edit section: Examples" data-bs-title="Documentation:OCLOperators_constraints">edit source</a>]

To check if any constraint with error level Error is broken:

self.constraints->select(c|(c.ErrorLevel = #Error) and c.Broken)->isEmpty  -- Returns True if no errors

Returning a collection of Descriptions of broken Warning constraints:

self.constraints->select(c|(c.ErrorLevel = #Warning) and c.Broken)->collect(c|c.Description)

Please Note[<a href="/index.php?title=Documentation:OCLOperators_constraints&veaction=edit&section=2" class="mw-editsection-visualeditor" title="Edit section: Please Note" data-bs-title="Documentation:OCLOperators_constraints">edit</a> | <a href="/index.php?title=Documentation:OCLOperators_constraints&action=edit&section=2" title="Edit section: Please Note" data-bs-title="Documentation:OCLOperators_constraints">edit source</a>]

This operator earlier resulted in an array of booleans with the constraint result. To get the same functionality now, add .broken=false to the end of the previous expression.

Like this, used with <a href="/Documentation:OCLOperators_forAll" title="Documentation:OCLOperators forAll" data-bs-title="Documentation:OCLOperators_forAll">forAll</a>:

self.constraints->forAll(c|c.broken=false)
<a href="/File:2021-10-10_10h56_59.gif" class="image" data-bs-title="File:2021-10-10_10h56_59.gif" data-bs-filetimestamp="20211010085839"><img alt="2021-10-10 10h56 59.gif" src="/images/thumb/e/ea/2021-10-10_10h56_59.gif/715px-2021-10-10_10h56_59.gif" decoding="async" width="715" height="486" class="thumbimage" srcset="/images/e/ea/2021-10-10_10h56_59.gif 1.5x" /></a>
<a href="/File:2021-10-10_10h56_59.gif" class="internal" title="Enlarge"></a>

See also: <a href="/Training:Constraints" title="Training:Constraints" data-bs-title="Training:Constraints">Constraints</a>, <a href="/Documentation:OCLOperators_brokenConstraints" title="Documentation:OCLOperators brokenConstraints" data-bs-title="Documentation:OCLOperators_brokenConstraints">OCLOperators_brokenConstraints</a>