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:
- Only components of a group can have component rules. Components of a category cannot have component rules.
- A component rule cannot be longer than 32K.
- If a component is optional and does not appear in the data, the component rule is evaluated after determining that the data is missing. In a component rule, you can specify relationships that depend on existence or nonexistence of data.
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.