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
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user