HAL
hal::Validator Class Referenceabstract

Base class for any string validator. More...

#include <validator.h>

Inheritance diagram for hal::Validator:
Inheritance graph
Collaboration diagram for hal::Validator:
Collaboration graph

Public Member Functions

virtual bool validate (const QString &input)=0
 
void setFailText (const QString &text)
 
QString failText () const
 

Protected Attributes

QString mFailText = "Chosen input is not allowed."
 

Detailed Description

Base class for any string validator.

A Validator can be used to check if a string meets certain requirements. It is intended to be used in and input dialog to dynamically validate the input string of the user. If the input is not considered valid and the validation fails the Validator provides a 'fail text' that can be inserted in the input dialog widget to provide further information about the reason why the validation failed.

Definition at line 40 of file validator.h.

Member Function Documentation

◆ failText()

QString hal::Validator::failText ( ) const

Accesses the fail text configured via Validator::setFailText (or a default fail text if no text was configured).

Returns
the fail text

Definition at line 10 of file validator.cpp.

References mFailText.

◆ setFailText()

void hal::Validator::setFailText ( const QString text)

Configures the fail text that describes the reason for a failed validation. It can be accessed via Validator::failText.

Parameters
text- The new fail text

Definition at line 5 of file validator.cpp.

References mFailText.

Referenced by hal::EmptyStringValidator::EmptyStringValidator(), hal::HexadecimalValidator::HexadecimalValidator(), hal::UniqueStringValidator::UniqueStringValidator(), and hal::StackedValidator::validate().

◆ validate()

virtual bool hal::Validator::validate ( const QString input)
pure virtual

Given any input string this function returns true if the Validator considers this string as valid. It returns false otherwise.

Parameters
input- The input string
Returns
true iff the string is considered valid

Implemented in hal::UniqueStringValidator, hal::StackedValidator, hal::HexadecimalValidator, hal::EmptyStringValidator, and hal::GroupingTableModel.

Member Data Documentation

◆ mFailText

QString hal::Validator::mFailText = "Chosen input is not allowed."
protected

Definition at line 69 of file validator.h.

Referenced by failText(), and setFailText().


The documentation for this class was generated from the following files: