Before creating a new Constraint element, you must decide the Constraint type to create. The Constraint type defines a target for which the validation rule will be evaluated. There are three types of Constraints that can be evaluated: Constraints on Metaclasses. When a Constraint is placed on a metaclass (one of the classes in the UML Standard Profile > UML2 Metamodel), this Constraint is evaluated on all the model elements of that kind (e.g. if the Constraint is placed on the Actor metaclass, then this Constraint applies to all actor elements in the model). The following is an example of a rule (specified in OCL2.0) mandating that all actor names in the model must be capitalized. These Constraints are useful for specifying generic rules that must apply on all the model elements of a particular kind. Recommendation It is strongly recommend not to mix the Constraints from different metalevels into one validation suite. Learn more how to create validation suite >> Examples of Constraint types The examples of each Constraint type can be found in the model validation sample model. To open this sample do one of the following: You can create a new Constraint for : To create Constraint for a classifier or Stereotype To create Constraint for a metaclass Type its name. If you create a new Constraint for a metaclass, you must specify the Constrained Element property in the Constraint Specification window. How to specify Constrainted Element property >>context Actor inv capitalize:
let startswith:String = name.substring(1,1) in
startswith.toUpper() = startswith
The new Constraint is created in the model.
The new Constraint is created in the model.