Projekt

Allgemein

Profil

Herunterladen als
Herunterladen (934 Bytes) Statistiken
| Zweig: | Revision:
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(),
34233707 Christian Ehringfeld
"<property> must be no less than " + QString::number(param.getValue().toDouble()) +
e111d9ab Christian Ehringfeld
".");
} else if (param.getName() == "max"
&& param.getValue().toDouble() < converted) {
return ErrorMsg(param.getName(),
34233707 Christian Ehringfeld
"<property> must be not greater than " + QString::number(param.getValue().toDouble())
e111d9ab Christian Ehringfeld
+ ".");
}
return ErrorMsg();
}