HAL
hal::UniqueStringValidator Class Reference

Checks if a given string is unique compared to other given strings. More...

#include <unique_string_validator.h>

Inheritance diagram for hal::UniqueStringValidator:
Inheritance graph
Collaboration diagram for hal::UniqueStringValidator:
Collaboration graph

Public Member Functions

 UniqueStringValidator (const QStringList &unique_strings)
 
bool validate (const QString &input)
 
- Public Member Functions inherited from hal::Validator
void setFailText (const QString &text)
 
QString failText () const
 

Additional Inherited Members

- Protected Attributes inherited from hal::Validator
QString mFailText = "Chosen input is not allowed."
 

Detailed Description

Checks if a given string is unique compared to other given strings.

The UniqueStringValidator is a Validator which validate function returns true if the candidate string does not appear in the list of unique strings passed in the constructor. It should be used whenever an input must not contain an already used identifier.

Definition at line 42 of file unique_string_validator.h.

Constructor & Destructor Documentation

◆ UniqueStringValidator()

hal::UniqueStringValidator::UniqueStringValidator ( const QStringList unique_strings)

Constructor.

Parameters
unique_strings- The black list of strings that will cause the validate function to return false

Definition at line 5 of file unique_string_validator.cpp.

References hal::Validator::setFailText().

Member Function Documentation

◆ validate()

bool hal::UniqueStringValidator::validate ( const QString input)
virtual

Given any string this function returns true iff the string does not appear in the unique_string list passed to the constructor.

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

Implements hal::Validator.

Definition at line 10 of file unique_string_validator.cpp.

References QStringList::contains(), and hal::input.


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