Validation Groups

Navigation:  Components >

Validation Groups

Previous pageReturn to chapter overviewNext page

Overview

 

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 TNGValidationEntity (via TNGCustomValidationGroup) 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 TNGCustomValidationGroup.

 

Properties

 

Name

Type

Description

Validators

TNGValidators

The collection of validators which are included into the group. TNGValidatorsis a descendant of TCollection class, its items are of type TNGValidatorItem which descends from TCollectionItem. The main property of TNGValidatorItem is Validator of TNGValidationEntity type which can refer to a Validator or a validation group component.

Providers

TNGErrorProviders

The collection of Error Providers which are available for error indication. TNGErrorProviders is a descendant of TCollection class, its items are of type TNGErrorProviderItem which descends from TCollectionItem. The main property of TNGErrorProviderItem is Provider of TNGCustomErrorProvider type which can refer to an Error Provider or an Error Providers Group component.

FirstErrorOnly

Boolean

When FirstErrorOnly is set to True then Validate method stops after detecting the first error (first non-zero ErrorLevel returned by a validator). So only the first error is indicated by ErrorProviders. Otherwise all the validators are queried and all the returned errors are indicated.