Prev Next

OCL Conformance

OCL Conformance rules are applied to validate an element, relationship or attribute against any defined constraints in the Object Constraint Language (OCL). OCL is used to describe expressions on UML models, and to express constraints free of side-effects. You can add OCL constraints to any element, relationship or attribute in Enterprise Architect.

Define OCL Constraints

You can add an OCL constraint to a model object by setting OCL as the Constraint type in the object 'Properties' dialog.

For

Detail

See also

An Element

Right-click on the element and select 'Properties | Properties Dialog'. Click on the 'Constraints' page; in the 'Type' field click on the drop-down arrow and select OCL.

To perform an OCL Validation:

  1. Select 'Design > Package > Edit > Validation > Configure Validation Rules' and select the 'Element: (OCL) Conformance' checkbox.
  2. Click on the element and select 'Design > Package > Edit > Validation > Validate Current Package'.

Any OCL syntax violations are recorded in the 'Model Validation' tab of the System Output window.

Model Validation Configuration Model Validation

A Relationship

On a diagram, right-click on the connector and select the 'Properties' option; select the 'Constraints' page, and in the 'Type' field click on the drop-down arrow and select 'OCL'.

To perform an OCL Validation:

  1. Select 'Design > Package > Edit > Validation > Configure Validation Rules' and select the 'Relationship: (OCL) Conformance' checkbox
  2. Click on the connector and select 'Design > Package > Edit > Validation > Validate Current Package'

Any OCL syntax violations are recorded in the 'Model Validation' tab of the System Output window.

An Attribute

Right-click on the element and select 'Attributes | Constraints'; in the 'Type' field click on the drop-down arrow and select 'OCL'.

To perform an OCL Validation:

  1. Select 'Design > Package > Edit > Validation > Configure Validation Rules' and select the 'Feature: (OCL) Conformance' checkbox.
  2. Click on the element and select 'Design > Package > Edit > Validation > Validate Current Package'.

Any OCL syntax violations are recorded in the 'Model Validation' tab of the System Output window.

Reported violations

Error ID

Description

See also

MVR040001

OCL violation: «violated OCL»

Information: The element's OCL constraint uses incorrect syntax.

MVR070001

OCL violation: «violated OCL»

Information: The relationship's OCL constraint uses incorrect syntax.

MVR0A0001

OCL violation: «violated OCL»

Information: The attribute's OCL constraint uses incorrect syntax.

Notes

  • To have a valid OCL constraint, the syntax must be correctly formed; if the expression is not correct, a message displays stating that the OCL constraint is not valid

Learn more