OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Constructing and Assigning Validator Objects

Establishing the validation criteria

Because validator objects are not interface objects, their constructors require only enough information to establish the validation criteria. For example, a numeric-range validator object requires only two parameters: the minimum and maximum values in the valid range.

Every edit control object has a data member that can point to a validator object. This pointer's declaration looks like this:

TValidator *Validator

Assigning Validator Objects

Assign a validator by calling the edit control object's TEdit::SetValidator member function. The edit control automatically checks with the validator object when processing key events and when called on to validate itself.

Examples

The following code shows the construction of a validator and its assignment to an edit control. In this case, a filter validator that allows only alphabetic characters is used.

edit->SetValidator(new TFilterValidator("A-Za-z. "));

A complete example showing the use of the standard validators can be found in EXAMPLES\OWL\CLASSES\VALIDATE.

See Also