Wt  3.7.1
Public Member Functions | List of all members
Wt::WDoubleValidator Class Reference

A validator for validating floating point user input. More...

#include <Wt/WDoubleValidator>

Inheritance diagram for Wt::WDoubleValidator:
Inheritance graph
[legend]

Public Member Functions

 WDoubleValidator (WObject *parent=0)
 Creates a new double validator that accepts any double. More...
 
 WDoubleValidator (double minimum, double maximum, WObject *parent=0)
 Creates a new double validator that accepts double within the given range. More...
 
double bottom () const
 Returns the bottom of the valid double range.
 
void setBottom (double bottom)
 Sets the bottom of the valid double range. More...
 
double top () const
 Returns the top of the valid double range.
 
void setTop (double top)
 Sets the top of the valid double range. More...
 
virtual void setRange (double bottom, double top)
 Sets the range of valid doubles.
 
virtual Result validate (const WString &input) const
 Validates the given input. More...
 
virtual void createExtConfig (std::ostream &config) const
 Provides Ext-compatible config options for client-side validation.
 
void setInvalidNotANumberText (const WString &text)
 Sets the message to display when the input is not a number. More...
 
WString invalidNotANumberText () const
 Returns the message displayed when the input is not a number. More...
 
void setInvalidTooSmallText (const WString &text)
 Sets the message to display when the number is too small. More...
 
WString invalidTooSmallText () const
 Returns the message displayed when the number is too small. More...
 
void setInvalidTooLargeText (const WString &text)
 Sets the message to display when the number is too large. More...
 
WString invalidTooLargeText () const
 Returns the message displayed when the number is too large. More...
 
void setIgnoreTrailingSpaces (bool b)
 If true the validator will ignore trailing spaces. More...
 
bool ignoreTrailingSpaces ()
 Indicates whether the validator should ignore the trailing spaces. More...
 
virtual std::string javaScriptValidate () const
 Creates a Javascript object that validates the input. More...
 
- Public Member Functions inherited from Wt::WValidator
 WValidator (WObject *parent=0)
 Creates a new validator.
 
 WValidator (bool mandatory, WObject *parent=0)
 Creates a new validator. More...
 
 ~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...
 
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 Create a WObject with a given parent object. More...
 
virtual ~WObject ()
 Destructor. More...
 
virtual const std::string id () const
 Returns the (unique) identifier for this object. More...
 
virtual void setObjectName (const std::string &name)
 Sets an object name. More...
 
virtual std::string objectName () const
 Returns the object name. More...
 
void resetLearnedSlots ()
 Resets learned stateless slot implementations. More...
 
template<class T >
void resetLearnedSlot (void(T::*method)())
 Resets a learned stateless slot implementation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)())
 Declares a slot to be stateless and learn client-side behaviour on first invocation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 Declares a slot to be stateless and learn client-side behaviour in advance. More...
 
void isNotStateless ()
 Marks the current function as not stateless. More...
 
template<class T >
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 Provides a JavaScript implementation for a method. More...
 
void addChild (WObject *child)
 Adds a child object. More...
 
virtual void removeChild (WObject *child)
 Removes a child object. More...
 
const std::vector< WObject * > & children () const
 Returns the children.
 
WObjectparent () const
 Returns the parent object.
 

Additional Inherited Members

- Public Types inherited from Wt::WValidator
enum  State { Invalid, InvalidEmpty, Valid }
 The state in which validated input can exist. More...
 
- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 Typedef for a WObject method without arguments.
 
- Protected Member Functions inherited from Wt::WObject
virtual WStatelessSlot * getStateless (Method method)
 On-demand stateless slot implementation. More...
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 Returns the sender of the current slot call. More...
 

Detailed Description

A validator for validating floating point user input.

This validator checks whether user input is a double in the pre-defined range.

Usage example:

Wt::WLineEdit *lineEdit = new Wt::WLineEdit(this);
lineEdit->setValidator(validator);
lineEdit->setText("13.42");

i18n

The strings used in this class can be translated by overriding the default values for the following localization keys: Wt.WDoubleValidator.NotANumber: Must be a number Wt.WDoubleValidator.TooSmall: The number must be larger than {1} Wt.WDoubleValidator.BadRange: The number must be in the range {1} to {2} Wt.WDoubleValidator.TooLarge: The number must be smaller than {1}

Constructor & Destructor Documentation

◆ WDoubleValidator() [1/2]

Wt::WDoubleValidator::WDoubleValidator ( WObject parent = 0)

Creates a new double validator that accepts any double.

The validator will accept numbers using the current locale's format.

See also
WLocale::currentLocale()

◆ WDoubleValidator() [2/2]

Wt::WDoubleValidator::WDoubleValidator ( double  minimum,
double  maximum,
WObject parent = 0 
)

Creates a new double validator that accepts double within the given range.

The validator will accept numbers using the current locale's format.

See also
WLocale::currentLocale()

Member Function Documentation

◆ ignoreTrailingSpaces()

bool Wt::WDoubleValidator::ignoreTrailingSpaces ( )

Indicates whether the validator should ignore the trailing spaces.

See also
setIgnoreTrailingSpaces()

◆ invalidNotANumberText()

WString Wt::WDoubleValidator::invalidNotANumberText ( ) const

Returns the message displayed when the input is not a number.

See also
setInvalidNotANumberText(const WString&)

◆ invalidTooLargeText()

WString Wt::WDoubleValidator::invalidTooLargeText ( ) const

Returns the message displayed when the number is too large.

See also
setInvalidTooLargeText(const WString&)

◆ invalidTooSmallText()

WString Wt::WDoubleValidator::invalidTooSmallText ( ) const

Returns the message displayed when the number is too small.

See also
setInvalidTooSmallText(const WString&)

◆ javaScriptValidate()

std::string Wt::WDoubleValidator::javaScriptValidate ( ) const
virtual

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.

Note
The signature and contract changed changed in Wt 3.1.9.
See also
inputFilter()

Reimplemented from Wt::WValidator.

◆ setBottom()

void Wt::WDoubleValidator::setBottom ( double  bottom)

Sets the bottom of the valid double range.

The default value is the minimum double value.

◆ setIgnoreTrailingSpaces()

void Wt::WDoubleValidator::setIgnoreTrailingSpaces ( bool  b)

If true the validator will ignore trailing spaces.

See also
ignoreTrailingSpaces()

◆ setInvalidNotANumberText()

void Wt::WDoubleValidator::setInvalidNotANumberText ( const WString text)

Sets the message to display when the input is not a number.

The default value is "Must be a number."

◆ setInvalidTooLargeText()

void Wt::WDoubleValidator::setInvalidTooLargeText ( const WString text)

Sets the message to display when the number is too large.

Depending on whether bottom() and top() are real bounds, the default message is "The number must be between {1} and {2}" or "The number must be smaller than {2}".

◆ setInvalidTooSmallText()

void Wt::WDoubleValidator::setInvalidTooSmallText ( const WString text)

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

Depending on whether bottom() and top() are real bounds, the default message is "The number must be between {1} and {2}" or "The number must be larger than {1}".

◆ setTop()

void Wt::WDoubleValidator::setTop ( double  top)

Sets the top of the valid double range.

The default value is the maximum double value.

◆ validate()

WValidator::Result Wt::WDoubleValidator::validate ( const WString input) const
virtual

Validates the given input.

The input is considered valid only when it is blank for a non-mandatory field, or represents a double within the valid range.

Reimplemented from Wt::WValidator.


Generated on Tue Dec 15 2020 for the C++ Web Toolkit (Wt) by doxygen 1.8.13