6#include "validatordigitsbetween_p.h"
15 :
ValidatorRule(*new ValidatorDigitsBetweenPrivate(field, min, max, messages, defValKey))
31 qsizetype _min = d->extractSizeType(c, params, d->min, &ok);
34 qCWarning(C_VALIDATOR).noquote()
35 <<
debugString(c) <<
"Invalid minimum length comparison data";
38 _max = d->extractSizeType(c, params, d->max, &ok);
41 qCWarning(C_VALIDATOR).noquote()
42 <<
debugString(c) <<
"Invalid maximum length comparison data";
49 qCWarning(C_VALIDATOR).noquote() <<
debugString(c) <<
"Minimum comparison length" << _min
50 <<
"is larger than" <<
"maximum comparison length" << _max;
60 qCDebug(C_VALIDATOR).noquote()
61 <<
debugString(c) <<
"Length of" << v.
length() <<
"is not between" << _min <<
"and"
62 << _max <<
"and/or input value contains non-digit characters";
75 const ushort &uc = ch.unicode();
76 if (!((uc >= ValidatorRulePrivate::ascii_0) && (uc <= ValidatorRulePrivate::ascii_9))) {
90 const QVariantList list = errorData.
toList();
91 const QString min = list.
at(0).toString();
92 const QString max = list.
at(1).toString();
97 return c->
qtTrId(
"cutelyst-valdigitsbetween-genvalerr").
arg(min, max);
101 return c->
qtTrId(
"cutelyst-valdigitsbetween-genvalerr-label").
arg(_label, min, max);
QString qtTrId(const char *id, int n=-1) const
Checks for digits only with a length between min and max.
~ValidatorDigitsBetween() override
ValidatorDigitsBetween(const QString &field, const QVariant &min, const QVariant &max, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString())
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
Base class for all validator rules.
QString validationError(Context *c, const QVariant &errorData={}) const
QString label(Context *c) const
QString validationDataError(Context *c, const QVariant &errorData={}) const
void defaultValue(Context *c, ValidatorReturnType *result) const
QString value(const ParamsMultiMap ¶ms) const
QString debugString(Context *c) const
static bool validate(const QString &value, int min, int max)
Returns true if value only contains digits and has a length between min and max.
The Cutelyst namespace holds all public Cutelyst API.
QString arg(Args &&... args) const const
const QChar at(qsizetype position) const const
bool isEmpty() const const
qsizetype length() const const
void setValue(QVariant &&value)
QList< QVariant > toList() const const
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.