Defining component rules

A component rule is an expression about one or more components. It indicates what must be true for that component to be valid. For given data, it evaluates to either "true" or "false". A component rule is similar to a test. If the data does not pass the test, it is invalid.

Component rules are used for validating data. Some important points about component rules are:

Sometimes components have relationships among each other. For example, an address field in purchase order data is preceded by a qualifier field which tells whether the address is a bill-to or a ship-to address. If the value of the qualifier field is BT, the address field following it is a bill-to address. If the value is ST, the following address is a ship-to address.

The qualifier and address fields are dependent on each other. They only make sense as a pair. If one of these fields is optional and is missing, the other field is not meaningful. If the qualifier is missing, you do not know whether the address is a bill-to or a ship-to. If the address is missing, the qualifier does not qualify anything!

You might want to define this kind of relationship and other relationships among data objects. To do this, use a component rule. For example, use a rule on the address field component to indicate that the qualifier must be present if the address is present.