A SERVICE OF

logo

with the validator object when processing key events and when called on to
validate itself.
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 OWLAPI\VALIDA E.T
Overriding validator member functions
Although the standard validator objects should satisfy most of your data
validation needs, you can also modify the standard validators or write your
own validation objects. If you decide to do this, you should be familiar with
the following list of member functions inherited from the base class
TValidator; in addition to understanding the function of each member
function, you should also know how edit controls use them and how to
override them if necessary.
Valid
IsValid
IsValidInput
Error
Member function Valid is called by the associated edit-control object to
Member function
verify that the data entered is valid. Much like the CanClose member
Valid
functions of interface objects, Valid is a Boolean function that returns TRUE
only if the string passed to it is valid data. One responsibility of an edit
control’ CanClose member function is calling the validator object’ Valids s
member function, passing the edit control’ current text.s
When using validators with edit controls, you shouldn’t need to call or
override the validator’ Valid member function; the inherited version ofs
Valid will suffice. By default, Valid returns TRUE if the member function
IsValid returns TRUE; otherwise, it calls Error to notify the user of the error
and then returns FALSE.
The virtual member function IsValid is called by Valid, which passes IsValid
Member function
the text string to be validated. IsValid returns TRUE if the string represents
IsValid
Chapter 14, Validator objects
331