refactor: ComputerNameValidator define regex static where used

This commit is contained in:
sithlord48
2026-02-23 22:32:32 -05:00
committed by Nick Bolton
parent 568f5c7fc5
commit 4e641adae9
2 changed files with 3 additions and 7 deletions

View File

@ -17,7 +17,9 @@ ComputerNameValidator::ComputerNameValidator(const QString &message) : IStringVa
bool ComputerNameValidator::validate(const QString &input) const 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(); return match.hasMatch();
} }

View File

@ -8,8 +8,6 @@
#include "IStringValidator.h" #include "IStringValidator.h"
#include <QRegularExpression>
namespace validators { namespace validators {
class ComputerNameValidator : public IStringValidator class ComputerNameValidator : public IStringValidator
@ -17,10 +15,6 @@ class ComputerNameValidator : public IStringValidator
public: public:
explicit ComputerNameValidator(const QString &message); explicit ComputerNameValidator(const QString &message);
bool validate(const QString &input) const override; bool validate(const QString &input) const override;
private:
inline static const QRegularExpression m_nameValidator =
QRegularExpression(QStringLiteral("^[\\w\\._-]{0,255}$"), QRegularExpression::CaseInsensitiveOption);
}; };
} // namespace validators } // namespace validators