Wt: Wt::WTimeValidator Class Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Public Member Functions | List of all members
Wt::WTimeValidator Class Reference

A time validator. More...

`#include <Wt/WTimeValidator.h>`

Inheritance diagram for Wt::WTimeValidator:
[legend]

## Public Member Functions
| WTimeValidator ()
| Creates a new WTimeValidator.
| WTimeValidator (const WString &format)
| Creates a new WTimeValidator.
| WTimeValidator (const WString &format, const WTime &bottom, const WTime &top)
| Creates a new WTimeValidator.
void | setFormat (const WString &format)
| Sets the validator format.
virtual WString | format () const override
| Returns the validator current format.
void | setFormats (const std::vector< WString > &formats)
| Sets the time formats used to parse time strings.
const std::vector< WString > & | formats () const
| Returns the time formats used to parse time strings.
void | setBottom (const WTime &bottom)
| Sets the lower limit of the valid time range.
const WTime & | bottom () const
| Returns the lower limit of the valid time range.
void | setTop (const WTime &top)
| Sets the upper limit of the valid time range.
const WTime & | top () const
| Returns the upper limit of the valid time range.
void | setInvalidNotATimeText (const WString &text)
| Sets the message to display when the input is not a time.
WString | invalidNotATimeText () const
| Returns the message displayed when the input is not a time.
void | setInvalidTooEarlyText (const WString &text)
| Sets the message to display when the time is earlier than bottom.
WString | invalidTooEarlyText () const
| Returns the message displayed when time is too early.
void | setInvalidTooLateText (const WString &text)
| Sets the message to display when the time is later than top.
WString | invalidTooLateText () const
| Returns the message displayed when time is too late.
virtual Result | validate (const WString &input) const override
| Validates the given input.
virtual std::string | javaScriptValidate () const override
| Creates a Javascript object that validates the input.
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.
| ~WRegExpValidator ()
| Destructor.
void | setRegExp (const WString &pattern)
| Sets the regular expression for valid input.
WString | regExpPattern () const
| Returns the regular expression for valid input.
std::regex | regExp () const
| Returns the regular expression for valid input.
void | setFlags (WFlags< RegExpFlag > flags)
| Sets regular expression matching flags.
WFlags< RegExpFlag > | flags () const
| Returns regular expression matching flags.
void | setInvalidNoMatchText (const WString &text)
| Sets the message to display when the input does not match.
WString | invalidNoMatchText () const
| Returns the message displayed when the input does not match.
Public Member Functions inherited from Wt::WValidator
| 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 std::string | inputFilter () const
| Returns a regular expression that filters input.

## Additional Inherited Members
Public Types inherited from Wt::WValidator
typedef ValidationState | State
| Typedef for enum Wt::ValidationState.
Protected Member Functions inherited from Wt::WValidator

## Detailed Description

A time validator.

See also
  WTimeEdit
  WTime
  WTimePicker

## Constructor & Destructor Documentation

## ◆ WTimeValidator()

Wt::WTimeValidator::WTimeValidator | ( | const WString & | format,
|  | const WTime & | bottom,
|  | const WTime & | top )

Creates a new WTimeValidator.

The validator will accept only times within the indicated range bottom to top, in the time formate `format`

## Member Function Documentation

## ◆ javaScriptValidate()

virtual std::string Wt::WTimeValidator::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.

## ◆ setBottom()

void Wt::WTimeValidator::setBottom | ( | const WTime & | bottom | ) |

Sets the lower limit of the valid time range.

The default is a null time constructed using WTime()

## ◆ setFormat()

void Wt::WTimeValidator::setFormat | ( | const WString & | format | ) |

Sets the validator format.

See also
  WTime::toString()

## ◆ setTop()

void Wt::WTimeValidator::setTop | ( | const WTime & | top | ) |

Sets the upper limit of the valid time range.

The default is a null time constructed using WTime()

## ◆ validate()

virtual Result Wt::WTimeValidator::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 represents a time in the given format, and within the valid range.

Reimplemented from Wt::WRegExpValidator.