|
3.4 How to Add Constraints Constraints can be applied to entity attributes - in the persistence tier - and dataview fields, which are discussed in detail in the next chapter on the service tier. Constraints limit the valid values on an item of data, over and above its fundamental type. The constraints are checked on entering data (for data-view-fields) or before storing (for attributes).
In RSA you can have up to two constraints on any attribute or field. When data is first entered via a page, it may be validated (see How to validate page data). The screen field (or widget) that is backed by a dataview field will validate against the dataview constraint. If that field is connected to an attribute, it will also validate against the attribute constraint. If the data enters the service layer unvalidated, the dataview will validate against its own constraints and those of any attribute that backs it. Unlike presentation layer checking, only the first failure is reported on a request to store a record. If the data is pushed down to the persistence layer, the entity will validate solely against the attributes constraints. As it is possible to manipulate data at any level through filters, expressions and runtime methods, all these layers of validation are required.
The name and description of the constraint are really there for documentation purposes. There are sensible default messages if the constraint fails but you can override these, using the message field. There are several constraint types:
RSA has no simple way to add constraints to attributes as separate units, so two groups of constraint fields have been added to the attribute and dataview field property lists. The Z in front of the property names is just to push them to the bottom of the property window. Top Tips:
Links:
Copyright © 2001-2006 New Technology / enterprise Ltd. | |||||||||||||||||||||