refactor: ComputerNameValidator define regex static where used
This commit is contained in:
@ -17,7 +17,9 @@ ComputerNameValidator::ComputerNameValidator(const QString &message) : IStringVa
|
||||
|
||||
bool ComputerNameValidator::validate(const QString &input) const
|
||||
{
|
||||
auto match = m_nameValidator.match(input);
|
||||
static const auto s_nameValidator =
|
||||
QRegularExpression(QStringLiteral("^[\\w\\._-]{0,255}$"), QRegularExpression::CaseInsensitiveOption);
|
||||
auto match = s_nameValidator.match(input);
|
||||
return match.hasMatch();
|
||||
}
|
||||
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
|
||||
#include "IStringValidator.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace validators {
|
||||
|
||||
class ComputerNameValidator : public IStringValidator
|
||||
@ -17,10 +15,6 @@ class ComputerNameValidator : public IStringValidator
|
||||
public:
|
||||
explicit ComputerNameValidator(const QString &message);
|
||||
bool validate(const QString &input) const override;
|
||||
|
||||
private:
|
||||
inline static const QRegularExpression m_nameValidator =
|
||||
QRegularExpression(QStringLiteral("^[\\w\\._-]{0,255}$"), QRegularExpression::CaseInsensitiveOption);
|
||||
};
|
||||
|
||||
} // namespace validators
|
||||
|
||||
Reference in New Issue
Block a user