#include <WValidator>
Inherits Wt::WObject.
Inherited by Wt::WDateValidator, Wt::WDoubleValidator, Wt::WIntValidator, and Wt::WRegExpValidator.
Inheritance diagram for Wt::WValidator:

Public Types | |
| Invalid | |
| The input is invalid. | |
| InvalidEmpty | |
| The input is invalid (emtpy and mandatory). | |
| Valid | |
| The input is valid. | |
| enum | State { Invalid, InvalidEmpty, Valid } |
| The state in which validated input can exist. More... | |
Public Member Functions | |
| WValidator (bool mandatory=false) | |
| Create a new validator. | |
| void | setMandatory (bool how) |
| Set if input is mandatory. | |
| bool | isMandatory () const |
| Returns if input is mandatory. | |
| virtual void | fixup (WString &input) const |
| This function attempts to change input to be valid according to the validator's rules. | |
| virtual State | validate (WString &input, int &pos) const |
| Evaluate the validness of the given input. | |
A WValidator can be associated with a WFormWidget, using WFormWidget::setValidator.
This WValidator only checks that mandatory fields are not empty. This class is reimplemented in WIntValidator, WDoubleValidator, and WRegExpValidator, which perform checks on the input as well.
If these validators are not suitable, you can inherit from this class, and provide a suitable implementation to validate() and fixup().
| Wt::WValidator::WValidator | ( | bool | mandatory = false |
) |
| void Wt::WValidator::fixup | ( | WString & | input | ) | const [virtual] |
This function attempts to change input to be valid according to the validator's rules.
In general the function needs not to change the input into a valid input. The default implementation does nothing. But it may help the user in getting its input right.
| void Wt::WValidator::setMandatory | ( | bool | how | ) |
Set if input is mandatory.
When an input is not mandatory, then an empty field is always valid.
| WValidator::State Wt::WValidator::validate | ( | WString & | input, | |
| int & | pos | |||
| ) | const [virtual] |
Evaluate the validness of the given input.
This function returns the current state of the input.
The function can change both input and pos (the cursor position) if required.
Reimplemented in Wt::WDateValidator, Wt::WDoubleValidator, Wt::WIntValidator, and Wt::WRegExpValidator.
1.4.7