Wt  4.12.0
Public Member Functions | List of all members
Wt::WStackedValidator Class Reference

A validator that combines multiple validators. More...

#include <Wt/WStackedValidator.h>

Inheritance diagram for Wt::WStackedValidator:
[legend]

Public Member Functions

 WStackedValidator ()
 Creates an empty stacked validator.
 
virtual ~WStackedValidator ()
 Destructor.
 
void addValidator (const std::shared_ptr< WValidator > &validator)
 Adds a validator. More...
 
void insertValidator (int index, const std::shared_ptr< WValidator > &validator)
 Inserts a validator to the given index. More...
 
void removeValidator (const std::shared_ptr< WValidator > &validator)
 Removes the given validator.
 
int size () const
 Returns the number of validators.
 
void clear ()
 Removes all the validators.
 
Result validate (const WString &input) const override
 Validates the given input. More...
 
std::string javaScriptValidate () const override
 Creates a Javascript object that validates the input. More...
 
- Public Member Functions inherited from Wt::WValidator
 WValidator (bool mandatory=false)
 Creates a new validator. More...
 
virtual ~WValidator ()
 Destructor. More...
 
void setMandatory (bool how)
 Sets if input is mandatory. More...
 
bool isMandatory () const
 Returns if input is mandatory.
 
void setInvalidBlankText (const WString &text)
 Sets the message to display when a mandatory field is left blank. More...
 
WString invalidBlankText () const
 Returns the message displayed when a mandatory field is left blank. More...
 
virtual WString format () const
 Returns the validator format. More...
 
virtual std::string inputFilter () const
 Returns a regular expression that filters input. More...
 

Additional Inherited Members

- Public Types inherited from Wt::WValidator
typedef ValidationState State
 Typedef for enum Wt::ValidationState.
 

Detailed Description

A validator that combines multiple validators.

This validator allows you to combine multiple validators into a single one.

For a value to be considered valid by this validator, it must be valid for all of the validators added to it. In case the value is invalid for multiple validators, the validator used to generate the error message is the one with the lowest index.

Member Function Documentation

◆ addValidator()

void Wt::WStackedValidator::addValidator ( const std::shared_ptr< WValidator > &  validator)

Adds a validator.

This adds a validator at the last index if the validator is not already present in the list of validators.

◆ insertValidator()

void Wt::WStackedValidator::insertValidator ( int  index,
const std::shared_ptr< WValidator > &  validator 
)

Inserts a validator to the given index.

This inserts a validator at the given index, or at last index if the given index is bigger than the number of validators. Does nothing if the validator is already present in the list of validators.

◆ javaScriptValidate()

std::string Wt::WStackedValidator::javaScriptValidate ( ) const
overridevirtual

Creates a Javascript object that validates the input.

The JavaScript expression should evaluate to an object which contains a validate(text) function, which returns an object that contains the following two fields:

  • fields: a boolean valid,
  • a message that indicates the problem if not valid.

Returns an empty string if the validator does not provide a client-side validation implementationq.

See also
inputFilter()

Reimplemented from Wt::WValidator.

◆ validate()

Wt::WValidator::Result Wt::WStackedValidator::validate ( const WString input) const
overridevirtual

Validates the given input.

Note
The signature for this method changed in Wt 3.2.0.

Reimplemented from Wt::WValidator.