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

A validator that checks if a password is valid. More...

#include <Wt/WPasswordValidator.h>

Inheritance diagram for Wt::WPasswordValidator:
[legend]

Public Member Functions

 WPasswordValidator ()
 Creates a basic password validator.
 
void setMinLength (int chars)
 Specifies the minimum length of the password. More...
 
int minLength () const
 Returns the minimum length of the password. More...
 
void setInvalidTooShortText (const WString &text)
 Sets the message to display when the password is too small. More...
 
WString invalidTooShortText () const
 Returns the message displayed when the password is too small. More...
 
void setMaxLength (int chars)
 Specifies the maximum length of the password. More...
 
int maxLength () const
 Returns the maximum length of the password. More...
 
void setInvalidTooLongText (const WString &text)
 Sets the message to display when the password is too long. More...
 
WString invalidTooLongText () const
 Returns the message displayed when the password is too long. More...
 
virtual Result validate (const WString &input) const override
 Validates the given input. More...
 
virtual std::string javaScriptValidate () const override
 Creates a Javascript object that validates the input. More...
 
- Public Member Functions inherited from Wt::WRegExpValidator
 WRegExpValidator ()
 Sets a new regular expression validator.
 
 WRegExpValidator (const WString &pattern)
 Sets a new regular expression validator that accepts input that matches the given regular expression. More...
 
 ~WRegExpValidator ()
 Destructor.
 
void setRegExp (const WString &pattern)
 Sets the regular expression for valid input. More...
 
WString regExpPattern () const
 Returns the regular expression for valid input. More...
 
std::regex regExp () const
 Returns the regular expression for valid input.
 
void setFlags (WFlags< RegExpFlag > flags)
 Sets regular expression matching flags.
 
WFlags< RegExpFlagflags () const
 Returns regular expression matching flags.
 
void setInvalidNoMatchText (const WString &text)
 Sets the message to display when the input does not match. More...
 
WString invalidNoMatchText () const
 Returns the message displayed when the input does not match. 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 checks if a password is valid.

This validator validate an input like a browser supporting the attribute maxlength, minlength, required and pattern would.

Member Function Documentation

◆ invalidTooLongText()

WString Wt::WPasswordValidator::invalidTooLongText ( ) const

Returns the message displayed when the password is too long.

See also
setInvalidTooLongText(const WString&)

◆ invalidTooShortText()

WString Wt::WPasswordValidator::invalidTooShortText ( ) const

Returns the message displayed when the password is too small.

See also
setInvalidTooShortText(const WString&)

◆ javaScriptValidate()

std::string Wt::WPasswordValidator::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::WRegExpValidator.

◆ maxLength()

int Wt::WPasswordValidator::maxLength ( ) const

Returns the maximum length of the password.

See also
setMaxLength(int)

◆ minLength()

int Wt::WPasswordValidator::minLength ( ) const

Returns the minimum length of the password.

See also
setMinLength(int)

◆ setInvalidTooLongText()

void Wt::WPasswordValidator::setInvalidTooLongText ( const WString text)

Sets the message to display when the password is too long.

The default value is "Password too long".

◆ setInvalidTooShortText()

void Wt::WPasswordValidator::setInvalidTooShortText ( const WString text)

Sets the message to display when the password is too small.

The default value is "Password too small".

◆ setMaxLength()

void Wt::WPasswordValidator::setMaxLength ( int  chars)

Specifies the maximum length of the password.

The default value is std::numeric_limits<int>::max().

◆ setMinLength()

void Wt::WPasswordValidator::setMinLength ( int  chars)

Specifies the minimum length of the password.

The default value is 0.

◆ validate()

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

Validates 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::WRegExpValidator.