Wt
4.10.3
|
A basic validator for email input. More...
#include <Wt/WEmailValidator.h>
Public Member Functions | |
WEmailValidator () | |
Creates an email validator. | |
Result | validate (const WString &input) const override |
Validates the given input. | |
void | setInvalidNotAnEmailAddressText (const WString &text) |
Sets the message to display when the input is not a valid email address. | |
WString | invalidNotAnEmailAddressText () const |
Returns the message displayed when the input is not a valid email address. | |
void | setInvalidNotMatchingText (const WString &text) |
Sets the message to display when the input does not match the required pattern. | |
WString | invalidNotMatchingText () const |
Returns the message displayed when the input does not match the required pattern. | |
void | setMultiple (bool multiple) |
Sets whether multiple comma-separated email addresses are allowed. | |
bool | multiple () const |
Returns whether multiple comma-separated email addresses are allowed. | |
void | setPattern (const WString &pattern) |
Sets the pattern for the input validation. | |
WString | pattern () const |
Returns the pattern used for the input validation. | |
std::string | javaScriptValidate () const override |
Creates a Javascript object that validates the input. | |
![]() | |
WValidator (bool mandatory=false) | |
Creates a new validator. | |
virtual | ~WValidator () |
Destructor. | |
void | setMandatory (bool how) |
Sets if input is mandatory. | |
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. | |
WString | invalidBlankText () const |
Returns the message displayed when a mandatory field is left blank. | |
virtual WString | format () const |
Returns the validator format. | |
virtual std::string | inputFilter () const |
Returns a regular expression that filters input. | |
Additional Inherited Members | |
![]() | |
typedef ValidationState | State |
Typedef for enum Wt::ValidationState. | |
A basic validator for email input.
This validator does basic email validation, to check if an email address is formed correctly according to the WHATWG email input specification: https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email)
This validator can also be used for multiple email addresses.
A regex pattern can be specified to check that email addresses comply with this pattern.
WString Wt::WEmailValidator::invalidNotAnEmailAddressText | ( | ) | const |
Returns the message displayed when the input is not a valid email address.
WString Wt::WEmailValidator::invalidNotMatchingText | ( | ) | const |
Returns the message displayed when the input does not match the required pattern.
|
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.
bool Wt::WEmailValidator::multiple | ( | ) | const |
Returns whether multiple comma-separated email addresses are allowed.
WString Wt::WEmailValidator::pattern | ( | ) | const |
Returns the pattern used for the input validation.
The pattern is in ECMAScript style regex.
Sets the message to display when the input is not a valid email address.
The default message is "Must be a valid email address". This string is retrieved using tr("Wt.WEmailValidator.Invalid") if multiple() is false
, or tr("Wt.WEmailValidator.Invalid.Multiple") if multiple() is true
.
Sets the message to display when the input does not match the required pattern.
The default message is "Must be an email address matching the pattern '{1}'", with {1}
subsituted by the pattern. This string is retrieved using tr("Wt.WEmailValidator.NotMaching") if multiple() is false
, or tr("Wt.WEmailValidator.NotMaching.Multiple") if multiple() is true
.
Sets whether multiple comma-separated email addresses are allowed.
Sets the pattern for the input validation.
The pattern is in ECMAScript style regex.
Validates the given input.
The input is considered valid only when it is blank for a non-mandatory field, or represents a properly formed email address, or a list of email addresses, and matches the pattern() if non-empty.
Reimplemented from Wt::WValidator.