Validation groups |
Top Previous Next |
Validation Group is a special type of Validator control which allows for grouping of several Validators which can be then used as one. Validation Group is a descendant of TLMDValidationEntity (via TLMDCustomValidationGroup) and implements Validate method in the following way: it sequentially calls Validate methods of all the Validators included in its Validators collection in decreasing order of their ErrorLevel values (so testing the validated value for more serious errors first) . Resulting ErrorLevel is the maximum of all the values returned by grouped Validators. Error messages from grouped Validators are then dispatched to the Error Providers included into the ErrorProviders collection according to their [MinErrorLevel;MaxErrorLevel] ranges. Validation Group introduces several properties for controlling validation process (see the table below).
As a Validation Group is technically a Validator, it can be included into another Validation Group. Number of levels of such nesting of Validation Groups is not limited. It provides a flexible way to form quite complex validation rules of more simple ones and to re-use pieces of validation logic. Warning: Loops should be avoided while nesting Validation Groups!
Validation logic described above is equivalent to combining logic variables represented by Validators with AND logic operator. More complex logic expressions with other logic operators and evaluation order modifiers (brackets) can be implemented in other descendants of TLMDCustomValidationGroup.
|