Herunterladen als
root/src/validators/patternvalidator.cpp @ 49762cb7
519b2fe3 | Christian Ehringfeld | #include "patternvalidator.h"
|
|
#include <QRegularExpression>
|
|||
using namespace CuteEntityManager;
|
|||
PatternValidator::PatternValidator() : Validator() {
|
|||
}
|
|||
ErrorMsg PatternValidator::validateParam(QVariant value, Param param) const {
|
|||
dcb097f9 | Christian Ehringfeld | if (!value.toString().isEmpty()) {
|
|
QRegularExpression regExp = QRegularExpression();
|
|||
if (param.getName().isEmpty()) {
|
|||
regExp.setPattern(param.getValue().toString());
|
|||
} else {
|
|||
regExp.setPattern(param.getName());
|
|||
}
|
|||
if (regExp.match(value.toString()).hasMatch()) {
|
|||
return ErrorMsg();
|
|||
}
|
|||
return ErrorMsg(param.getName(), "<property> not matches the pattern.");
|
|||
519b2fe3 | Christian Ehringfeld | }
|
|
dcb097f9 | Christian Ehringfeld | return ErrorMsg();
|
|
519b2fe3 | Christian Ehringfeld | }
|