Wt::WValidator Class Reference

A WValidator is used to validate user input according to pre-defined rules. More...

#include <WValidator>

Inherits Wt::WObject.

Inherited by Wt::WDateValidator, Wt::WDoubleValidator, Wt::WIntValidator, and Wt::WRegExpValidator.

Inheritance diagram for Wt::WValidator:

Inheritance graph
[legend]
List of all members.

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.

Detailed Description

A WValidator is used to validate user input according to pre-defined rules.

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().

See also:
WFormWidget

WValidationStatus


Member Enumeration Documentation

enum Wt::WValidator::State

The state in which validated input can exist.

Enumerator:
Invalid  The input is invalid.
InvalidEmpty  The input is invalid (emtpy and mandatory).
Valid  The input is valid.


Constructor & Destructor Documentation

Wt::WValidator::WValidator ( bool  mandatory = false  ) 

Create a new validator.

Indicate whether input is mandatory.

See also:
setMandatory(bool)


Member Function Documentation

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.


The documentation for this class was generated from the following files:
Generated on Sun Jul 1 19:37:18 2007 for Wt by doxygen 1.4.7