Revision 34233707
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
src/validators/comparevalidator.cpp | ||
---|---|---|
}
|
||
|
||
ErrorMsg CompareValidator::validateParam(QVariant value, Param param) const {
|
||
|
||
if (param.getName().isEmpty()) {
|
||
return ErrorMsg("", "No operator set.");
|
||
}
|
||
if (param.getName() == "==" && value != param.getValue()) {
|
||
return ErrorMsg(param.getName(), "<property> must be repeated exactly.");
|
||
} else if (param.getName() == "!=" && value == param.getValue()) {
|
||
return ErrorMsg(param.getName(),
|
||
"<property> must not be equal to " + param.getValue().toString() + ".");
|
||
} else if (param.getName() == ">" && value <= param.getValue()) {
|
||
return ErrorMsg(param.getName(),
|
||
"<property> must be greater than " + param.getValue().toString() + ".");
|
||
} else if (param.getName() == "<" && value >= param.getValue()) {
|
||
return ErrorMsg(param.getName(),
|
||
"<property> must be greater than or equal to " + param.getValue().toString() + ".");
|
||
} else if (param.getName() == ">=" && value < param.getValue()) {
|
||
return ErrorMsg(param.getName(),
|
||
"<property> must be less than " + param.getValue().toString() + ".");
|
||
} else if (param.getName() == "<=" && value > param.getValue()) {
|
||
return ErrorMsg(param.getName(),
|
||
"<property> must be less than or equal to " + param.getValue().toString() + ".");
|
||
}
|
||
return ErrorMsg();
|
||
}
|
||
|
src/validators/datevalidator.cpp | ||
---|---|---|
if (date.isValid()) {
|
||
if (param.getName() == "future") {
|
||
if (date < QDate::currentDate()) {
|
||
ErrorMsg(param.getName(), "Date is not in the future.");
|
||
ErrorMsg(param.getName(), "<property> is not in the future.");
|
||
}
|
||
} else if (param.getName() == "past") {
|
||
if (date > QDate::currentDate()) {
|
||
ErrorMsg(param.getName(), "Date is not in the past.");
|
||
ErrorMsg(param.getName(), "<property> is not in the past.");
|
||
}
|
||
|
||
} else if (param.getName() == "min" && date < param.getValue().toDate()) {
|
||
ErrorMsg(param.getName(),
|
||
"Date must be no less than " + param.getValue().toString());
|
||
"<property> must be no less than " + param.getValue().toString());
|
||
} else if (param.getName() == "max" && date > param.getValue().toDate()) {
|
||
ErrorMsg(param.getName(),
|
||
"Date must be no greater than " + param.getValue().toString());
|
||
"<property> must be no greater than " + param.getValue().toString());
|
||
}
|
||
}
|
||
//cause we don't want to replace functionality of RequiredValidator
|
src/validators/emailvalidator.cpp | ||
---|---|---|
if (exp.match(val).hasMatch()) {
|
||
return ErrorMsg();
|
||
}
|
||
return ErrorMsg(param.getName(), "Value is not a valid email address.");
|
||
return ErrorMsg(param.getName(), "<property> is not a valid email address.");
|
||
}
|
||
|
||
QString EmailValidator::getPattern() const {
|
src/validators/existvalidator.cpp | ||
---|---|---|
#include "existvalidator.h"
|
||
using namespace CuteEntityManager;
|
||
ExistValidator::ExistValidator() : Validator() {
|
||
|
||
}
|
||
|
||
ErrorMsg ExistValidator::validateParam(QVariant value, Param param) const {
|
src/validators/numbervalidator.cpp | ||
---|---|---|
}
|
||
if (param.getName() == "min" && param.getValue().toDouble() > converted) {
|
||
return ErrorMsg(param.getName(),
|
||
"Value must be no less than " + QString::number(param.getValue().toDouble()) +
|
||
"<property> must be no less than " + QString::number(param.getValue().toDouble()) +
|
||
".");
|
||
} else if (param.getName() == "max"
|
||
&& param.getValue().toDouble() < converted) {
|
||
return ErrorMsg(param.getName(),
|
||
"Value must be not greater than " + QString::number(param.getValue().toDouble())
|
||
"<property> must be not greater than " + QString::number(param.getValue().toDouble())
|
||
+ ".");
|
||
}
|
||
return ErrorMsg();
|
src/validators/urlvalidator.cpp | ||
---|---|---|
if (regExp.match(val).hasMatch()) {
|
||
return ErrorMsg();
|
||
} else {
|
||
return ErrorMsg(param.getName(), "Value is not a valid URL.");
|
||
return ErrorMsg(param.getName(), "<property> is not a valid URL.");
|
||
}
|
||
}
|
||
return ErrorMsg();
|
src/validators/validator.cpp | ||
---|---|---|
hash.insert("compare", "CompareValidator");
|
||
hash.insert("default", "DefaultValidator");
|
||
hash.insert("email", "EmailValidator");
|
||
hash.insert("exist", "ExistValidator");
|
||
hash.insert("exists", "ExistValidator");
|
||
hash.insert("file", "FileValidator");
|
||
hash.insert("image", "ImageValidator");
|
||
hash.insert("number", "NumberValidator");
|
Auch abrufbar als: Unified diff
...