Contents > 8 Defining Custom Design Metrics and Rules > 8.3 Definition of Design Rules > 8.3.4 Valueset for Rules
8.3.4 Valueset for Rules
The valueset procedure for rules calculates a value set for a
model element (see Section 220.127.116.11 "Attribute "valueset""), and reports any elements
contained in there.
For example, assume we have a value set "AttrNameSet" defined for
classes, which is a multiset of the names of the attributes of the
class. We can then define a rule to check for duplicate names:
<rule name="DupAttrNames" domain="class" category="Correctness"
<description>The class has two or more attributes with
<valueset set="AttrNameSet" mincnt="2" />
The procedure evaluates the set expression for the class, and
reports all elements that occur at least twice. The value of the rule
is the value of the reported element in the value set; in our example
this is the duplicate attribute name.
In addition to the set attribute, the valueset procedure
accepts the attributes mincnt and precondition,
which have the same meaning as they have for rule projections (see
Section 8.3.3 "Projection for Rules").