Herunterladen als
root/src/validators/numbervalidator.cpp @ 51bbd62c
e111d9ab | Christian Ehringfeld | #include "numbervalidator.h"
|
|
using namespace CuteEntityManager;
|
|||
NumberValidator::NumberValidator() : Validator() {
|
|||
}
|
|||
ErrorMsg NumberValidator::validateParam(QVariant value, Param param) const {
|
|||
bool convert;
|
|||
double converted = value.toDouble(&convert);
|
|||
if (!convert) {
|
|||
return ErrorMsg(param.getName(), "Value could not converted.");
|
|||
}
|
|||
if (param.getName() == "min" && param.getValue().toDouble() > converted) {
|
|||
return ErrorMsg(param.getName(),
|
|||
"Value 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())
|
|||
+ ".");
|
|||
}
|
|||
return ErrorMsg();
|
|||
}
|