45 if (Q_UNLIKELY(!ok)) {
47 qCWarning(C_VALIDATOR).noquote().nospace()
49 <<
"\" into an integer number";
52 ValidatorBetweenPrivate::extractLongLong(c, params, d->min, &ok);
53 if (Q_UNLIKELY(!ok)) {
55 c,
static_cast<int>(ValidatorRulePrivate::ErrorType::InvalidMin));
56 qCWarning(C_VALIDATOR).noquote()
57 <<
"Invalid mininum comparison value:" << d->min;
60 ValidatorBetweenPrivate::extractLongLong(c, params, d->max, &ok);
61 if (Q_UNLIKELY(!ok)) {
63 c,
static_cast<int>(ValidatorRulePrivate::ErrorType::InvalidMax));
64 qCWarning(C_VALIDATOR).noquote()
65 <<
"Invalid maximum comparison value:" << d->max;
67 if ((val < min) || (val > max)) {
69 c, QVariantMap{{u
"val"_s, val}, {u
"min"_s, min}, {u
"max"_s, max}});
70 qCDebug(C_VALIDATOR).noquote()
71 <<
debugString(c) << val <<
"is not between" << min <<
"and" << max;
86 if (Q_UNLIKELY(!ok)) {
88 qCWarning(C_VALIDATOR).noquote().nospace()
90 <<
"\" into an unsigned integer number";
92 const qulonglong min =
93 ValidatorBetweenPrivate::extractULongLong(c, params, d->min, &ok);
94 if (Q_UNLIKELY(!ok)) {
96 c,
static_cast<int>(ValidatorRulePrivate::ErrorType::InvalidMin));
97 qCWarning(C_VALIDATOR).noquote()
98 <<
debugString(c) <<
"Invalid mininum comparison value:" << d->min;
100 const qulonglong max =
101 ValidatorBetweenPrivate::extractULongLong(c, params, d->max, &ok);
102 if (Q_UNLIKELY(!ok)) {
104 c,
static_cast<int>(ValidatorRulePrivate::ErrorType::InvalidMax));
105 qCWarning(C_VALIDATOR).noquote()
106 <<
debugString(c) <<
"Invalid maximum comparison value:" << d->max;
108 if ((val < min) || (val > max)) {
110 c, QVariantMap{{u
"val"_s, val}, {u
"min"_s, min}, {u
"max"_s, max}});
111 qCDebug(C_VALIDATOR).noquote()
112 <<
debugString(c) << val <<
"is not between" << min <<
"and" << max;
124 if (Q_UNLIKELY(!ok)) {
126 qCWarning(C_VALIDATOR).noquote().nospace()
127 <<
debugString(c) <<
" Can not parse input \"" << v
128 <<
"\" into a floating point number";
130 const double min = ValidatorBetweenPrivate::extractDouble(c, params, d->min, &ok);
131 if (Q_UNLIKELY(!ok)) {
133 c,
static_cast<int>(ValidatorRulePrivate::ErrorType::InvalidMin));
134 qCWarning(C_VALIDATOR).noquote()
135 <<
debugString(c) <<
"Invalid mininum comparison value:" << d->min;
138 ValidatorBetweenPrivate::extractDouble(c, params, d->max, &ok);
139 if (Q_UNLIKELY(!ok)) {
141 c,
static_cast<int>(ValidatorRulePrivate::ErrorType::InvalidMax));
142 qCWarning(C_VALIDATOR).noquote()
143 <<
debugString(c) <<
"Invalid maximum comparison value:" << d->max;
145 if ((val < min) || (val > max)) {
147 c, QVariantMap{{u
"val"_s, val}, {u
"min"_s, min}, {u
"max"_s, max}});
148 qCDebug(C_VALIDATOR).noquote()
149 <<
debugString(c) << val <<
"is not between" << min <<
"and" << max;
159 const auto val =
static_cast<qlonglong
>(v.
length());
160 const qlonglong min = ValidatorBetweenPrivate::extractLongLong(c, params, d->min, &ok);
161 if (Q_UNLIKELY(!ok)) {
163 c,
static_cast<int>(ValidatorRulePrivate::ErrorType::InvalidMin));
164 qCWarning(C_VALIDATOR).noquote()
165 <<
debugString(c) <<
"Invalid mininum comparison value:" << d->min;
167 const qlonglong max =
168 ValidatorBetweenPrivate::extractLongLong(c, params, d->max, &ok);
169 if (Q_UNLIKELY(!ok)) {
171 c,
static_cast<int>(ValidatorRulePrivate::ErrorType::InvalidMax));
172 qCWarning(C_VALIDATOR).noquote()
173 <<
debugString(c) <<
"Invalid maximum comparison value:" << d->max;
175 if ((val < min) || (val > max)) {
177 c, QVariantMap{{u
"val"_s, val}, {u
"min"_s, min}, {u
"max"_s, max}});
178 qCDebug(C_VALIDATOR).noquote() <<
debugString(c) <<
"String length" << val
179 <<
"is not between" << min <<
"and" << max;
187 qCWarning(C_VALIDATOR).noquote()
188 <<
debugString(c) <<
"The comparison type" << d->type <<
"is not supported";
190 c,
static_cast<int>(ValidatorRulePrivate::ErrorType::InvalidType));
196 const QVariant _v = ValidatorBetweenPrivate::valueToNumber(c, v, d->type);
284 const auto errorType =
static_cast<ValidatorRulePrivate::ErrorType
>(errorData.
toInt());
289 case ValidatorRulePrivate::ErrorType::InvalidMin:
291 return c->
qtTrId(
"cutelyst-validator-genvaldataerr-min");
292 case ValidatorRulePrivate::ErrorType::InvalidType:
298 return c->
qtTrId(
"cutelyst-validator-genvaldataerr-type")
301 case ValidatorRulePrivate::ErrorType::InvalidMax:
303 return c->
qtTrId(
"cutelyst-validator-genvaldataerr-max");
307 case ValidatorRulePrivate::ErrorType::InvalidMin:
310 return c->
qtTrId(
"cutelyst-validator-genvaldataerr-min-label").
arg(_label);
311 case ValidatorRulePrivate::ErrorType::InvalidType:
317 return c->
qtTrId(
"cutelyst-validator-genvaldataerr-type-label")
320 case ValidatorRulePrivate::ErrorType::InvalidMax:
323 return c->
qtTrId(
"cutelyst-validator-genvaldataerr-max-label").
arg(_label);
QLocale locale() const noexcept
QString qtTrId(const char *id, int n=-1) const