19 #include "validatordigitsbetween_p.h"
24 ValidatorRule(*new ValidatorDigitsBetweenPrivate(field, min, max, messages, defValKey))
38 const QString v =
value(params);
42 int _min = d->extractInt(c, params, d->min, &ok);
45 qCWarning(C_VALIDATOR,
"ValidatorDigitsBetween: Invalid minimum validation length for field %s at %s::%s.", qPrintable(
field()), qPrintable(c->controllerName()), qPrintable(c->actionName()));
48 _max = d->extractInt(c, params, d->max, &ok);
51 qCWarning(C_VALIDATOR,
"ValidatorDigitsBetween: Invalid maximum validation length for field %s at %s::%s.", qPrintable(
field()), qPrintable(c->controllerName()), qPrintable(c->actionName()));
58 qCWarning(C_VALIDATOR,
"ValidatorDigitsBetween: Minimum length %i is larger than maximum length %i for field %s at %s::%s", _min, _max, qPrintable(
field()), qPrintable(c->controllerName()), qPrintable(c->actionName()));
65 result.
value.setValue<QString>(v);
68 qCDebug(C_VALIDATOR,
"ValidatorDigitsBetween: Validation failed for value \"%s\" in field %s at %s::%s: length not between %i and %i and/or non-digit characters.", qPrintable(v), qPrintable(
field()), qPrintable(c->controllerName()), qPrintable(c->actionName()), _min, _max);
82 for (
const QChar &ch :
value) {
83 const ushort &uc = ch.unicode();
84 if (!((uc > 47) && (uc < 58))) {
90 if (valid && ((
value.length() < min) || (
value.length() > max))) {
101 const QVariantList list = errorData.toList();
102 const QString min = list.at(0).toString();
103 const QString max = list.at(1).toString();
104 const QString _label =
label(c);
106 if (_label.isEmpty()) {
107 error = c->
translate(
"Cutelyst::ValidatorDigitsBetween",
"Must contain between %1 and %2 digits.").arg(min, max);
110 error = c->
translate(
"Cutelyst::ValidatorDigitsBetween",
"The “%1” field must contain between %2 and %3 digits.").arg(_label, min, max);