Validating OCL constraints in UML models

In UML models, you can validate the syntax of a constraint that was defined by using Object Constraint Language (OCL). You can also express the body of a constraint using a natural language such as English, a programming language, or a mathematical notation. For more information about OCL, read the Unified Modeling Language (UML) specification that is available on the Object Management Group (OMG) website.

About this task

The syntax and the expression of a constraint are validated if the constraint has the «metaConstraint» stereotype applied to it or if it is defined in a profile. Only the syntax of a constraint is validated if it does not have the «metaConstraint» stereotype applied to it and it is not defined in a profile.

To validate an OCL constraint, in the Project Explorer view, right-click a constraint; then click Validate.

Results

The results of the validation are displayed in the Console view.

Feedback