Wt::WRegExpValidator Class Reference

A validator that checks user input against a regular expression. More...

#include <Wt/WRegExpValidator>

Inheritance diagram for Wt::WRegExpValidator:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 WRegExpValidator (WObject *parent=0)
 Create a new regular expression validator.
 WRegExpValidator (const boost::regex &rx)
 Create a new regular expression validator that accepts input that matches the given regular expression (deprecated).
 WRegExpValidator (const WString &expr, WObject *parent=0)
 Create a new regular expression validator that accepts input that matches the given regular expression.
 ~WRegExpValidator ()
 Delete the regexp validator.
void setRegExp (const WString &expr)
 Set the regular expression for valid input.
virtual State validate (WString &input, int &pos) const
 Validate the given input.
virtual void createExtConfig (std::ostream &config) const
 Provide Ext-compatible config options for client-side validation.
void setInvalidNoMatchText (const WString &text)
 Set the message to display when the input does not match.
WString invalidNoMatchText () const
 Returns the message displayed when the input does not match.

Protected Member Functions

std::string javaScriptValidate (const std::string &jsRef) const
 Creates a Javascript expression that validates the input.


Detailed Description

A validator that checks user input against a regular expression.

This validator checks whether user input is matched by the given (perl-like) regular expression.

The following perl features are not supported (since client-side validation cannot handle them):

This validator does not fully support unicode: it matches on the UTF8-encoded representation of the string.


Constructor & Destructor Documentation

Wt::WRegExpValidator::WRegExpValidator ( const boost::regex &  rx  ) 

Create a new regular expression validator that accepts input that matches the given regular expression (deprecated).

Deprecated:
Use WRegExpValidator(const WString&, WObject *) instead.

Wt::WRegExpValidator::WRegExpValidator ( const WString expr,
WObject parent = 0 
)

Create a new regular expression validator that accepts input that matches the given regular expression.

This constructs a validator that matches the perl regular expression expr.


Member Function Documentation

void Wt::WRegExpValidator::setRegExp ( const WString expr  ) 

Set the regular expression for valid input.

Sets the perl regular expression expr.

WValidator::State Wt::WRegExpValidator::validate ( WString input,
int &  pos 
) const [virtual]

Validate the given input.

The input is considered valid only when it is blank for a non-mandatory field, or matches the regular expression.

Reimplemented from Wt::WValidator.

void Wt::WRegExpValidator::setInvalidNoMatchText ( const WString text  ) 

Set the message to display when the input does not match.

The default value is "Invalid input".

WString Wt::WRegExpValidator::invalidNoMatchText (  )  const

Returns the message displayed when the input does not match.

See also:
setInvalidNoMatchText(const WString&)

std::string Wt::WRegExpValidator::javaScriptValidate ( const std::string &  jsRef  )  const [protected, virtual]

Creates a Javascript expression that validates the input.

The JavaScript expression should evaluate to an object with two fields: a boolean valid, and a message that indicates the problem if not valid.

Return an empty string if you are not provide the client-side validation.

See also:
inputFilter()

Reimplemented from Wt::WValidator.


Generated on Fri Sep 12 17:01:15 2008 for Wt by doxygen 1.5.6