Files
GUI/src/utilities/InputFormatValidator.cpp
2025-09-04 09:39:14 +08:00

22 lines
733 B
C++

#include "InputFormatValidator.h"
#include <QRegularExpression>
bool InputFormatValidator::ValidateAETitleFormat(const QString &aAeTitle)
{
QRegularExpression regex("^[0-9a-zA-Z_-]{1,16}$");
return regex.match(aAeTitle).hasMatch();
}
bool InputFormatValidator::ValidateIpAddressFormat(const QString &aIpAddress)
{
QRegularExpression regex("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
return regex.match(aIpAddress).hasMatch();
}
bool InputFormatValidator::ValidatePortFormat(const QString& aPort)
{
QRegularExpression regex("^(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{0,3}|0)$");
return regex.match(aPort).hasMatch();
}