Projekt

Allgemein

Profil

Herunterladen als
Herunterladen (1016 Bytes) Statistiken
| Zweig: | Revision:
ec6a9500 Christian Ehringfeld
#include "emailvalidator.h"
2cfe6214 Christian Ehringfeld
#include <QRegularExpression>
ec6a9500 Christian Ehringfeld
using namespace CuteEntityManager;
EmailValidator::EmailValidator() : Validator() {

}

ErrorMsg EmailValidator::validateParam(QVariant value, Param param) const {
2cfe6214 Christian Ehringfeld
QRegularExpression exp = QRegularExpression();
QString val = value.toString();
dcb097f9 Christian Ehringfeld
if (!val.isEmpty()) {
if (param.getName() == "full") {
exp.setPattern(this->getFullPattern());
} else {
exp.setPattern(this->getPattern());
}
if (exp.match(val).hasMatch()) {
return ErrorMsg();
}
return ErrorMsg(param.getName(), "<property> is not a valid email address.");
2cfe6214 Christian Ehringfeld
}
dcb097f9 Christian Ehringfeld
return ErrorMsg();
2cfe6214 Christian Ehringfeld
}
ec6a9500 Christian Ehringfeld
2cfe6214 Christian Ehringfeld
QString EmailValidator::getPattern() const {
return pattern;
}

void EmailValidator::setPattern(const QString &value) {
pattern = value;
}
QString EmailValidator::getFullPattern() const {
return fullPattern;
ec6a9500 Christian Ehringfeld
}

2cfe6214 Christian Ehringfeld
void EmailValidator::setFullPattern(const QString &value) {
fullPattern = value;
}