Wt
4.12.0
|
A validator that combines multiple validators. More...
#include <Wt/WStackedValidator.h>
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... | |
![]() | |
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 | |
![]() | |
typedef ValidationState | State |
Typedef for enum Wt::ValidationState. | |
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.
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.
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.
|
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:
message
that indicates the problem if not valid.Returns an empty string if the validator does not provide a client-side validation implementationq.
Reimplemented from Wt::WValidator.
|
overridevirtual |
Validates the given input.
Reimplemented from Wt::WValidator.