19 #include "validatorinteger_p.h"
24 ValidatorRule(*new ValidatorIntegerPrivate(field, type, messages, defValKey))
36 const QString v =
value(params);
44 case QMetaType::Short:
47 case QMetaType::LongLong:
48 case QMetaType::UChar:
49 case QMetaType::UShort:
51 case QMetaType::ULong:
52 case QMetaType::ULongLong:
53 converted = d->valueToNumber(c, v, d->type);
57 qCWarning(C_VALIDATOR,
"ValidatorInteger: Conversion type for field %s at %s::%s is not an integer type.", qPrintable(
field()), qPrintable(c->controllerName()), qPrintable(c->actionName()));
61 if (converted.isValid()) {
62 result.
value = converted;
64 qCDebug(C_VALIDATOR,
"ValidatorInteger: Validation failed for field %s at %s::%s: not an integer value.", qPrintable(
field()), qPrintable(c->controllerName()), qPrintable(c->actionName()));
79 const QString _label =
label(c);
84 min = c->
locale().toString(std::numeric_limits<char>::min());
85 max = c->
locale().toString(std::numeric_limits<char>::max());
87 case QMetaType::Short:
88 min = c->
locale().toString(std::numeric_limits<short>::min());
89 max = c->
locale().toString(std::numeric_limits<short>::max());
92 min = c->
locale().toString(std::numeric_limits<int>::min());
93 max = c->
locale().toString(std::numeric_limits<int>::max());
96 min = c->
locale().toString(
static_cast<qlonglong
>(std::numeric_limits<long>::min()));
97 max = c->
locale().toString(
static_cast<qlonglong
>(std::numeric_limits<long>::max()));
99 case QMetaType::LongLong:
100 min = c->
locale().toString(std::numeric_limits<qlonglong>::min());
101 max = c->
locale().toString(std::numeric_limits<qlonglong>::max());
103 case QMetaType::UChar:
104 min = c->
locale().toString(std::numeric_limits<uchar>::min());
105 max = c->
locale().toString(std::numeric_limits<uchar>::max());
107 case QMetaType::UShort:
108 min = c->
locale().toString(std::numeric_limits<ushort>::min());
109 max = c->
locale().toString(std::numeric_limits<ushort>::max());
111 case QMetaType::UInt:
112 min = c->
locale().toString(std::numeric_limits<uint>::min());
113 max = c->
locale().toString(std::numeric_limits<uint>::max());
115 case QMetaType::ULong:
116 min = c->
locale().toString(
static_cast<qulonglong
>(std::numeric_limits<ulong>::min()));
117 max = c->
locale().toString(
static_cast<qulonglong
>(std::numeric_limits<ulong>::max()));
119 case QMetaType::ULongLong:
121 min = c->
locale().toString(std::numeric_limits<qulonglong>::min());
122 max = c->
locale().toString(std::numeric_limits<qulonglong>::max());
125 if (_label.isEmpty()) {
127 error = c->
translate(
"Cutelyst::ValidatorInteger",
"Not a valid integer value between %1 and %2.").arg(min, max);
130 error = c->
translate(
"Cutelyst::ValidatorInteger",
"The value in the “%1“ field is not a valid integer between %2 and %3.").arg(_label, min, max);