6#include "validatordigits_p.h"
14 :
ValidatorRule(*new ValidatorDigitsPrivate(field, length, messages, defValKey))
28 const qlonglong _length = d->extractLongLong(c, params, d->length, &ok);
30 qCDebug(C_VALIDATOR).noquote() <<
debugString(c) <<
"Invalid comparison length";
38 if ((_length > 0) && (v.
length() != _length)) {
40 qCDebug(C_VALIDATOR).noquote()
41 <<
debugString(c) <<
"Does not contain exactly" << _length
42 <<
"digits:" << v.
length() <<
"!=" << _length;
48 qCDebug(C_VALIDATOR).noquote().nospace()
49 <<
debugString(c) <<
" Does not only contain digits: \"" << v <<
"\"";
62 const ushort &uc = ch.unicode();
63 if (!((uc >= ValidatorRulePrivate::ascii_0) && (uc <= ValidatorRulePrivate::ascii_9))) {
78 const int _length = errorData.
toInt();
83 return c->
qtTrId(
"cutelyst-valdigits-genvalerr-length", _length);
86 return c->
qtTrId(
"cutelyst-valdigits-genvalerr");
92 return c->
qtTrId(
"cutelyst-valdigits-genvalerr-length-label", _length).
arg(_label);
96 return c->
qtTrId(
"cutelyst-valdigits-genvalerr-label").
arg(_label);
QString qtTrId(const char *id, int n=-1) const
Checks for digits only with optional length check.
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
~ValidatorDigits() override
ValidatorDigits(const QString &field, const QVariant &length=-1, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString())
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, qsizetype length=-1)
Returns true if value only contains digits.
The Cutelyst namespace holds all public Cutelyst API.
QString arg(Args &&... args) const const
bool isEmpty() const const
qsizetype length() const const
void setValue(QVariant &&value)
int toInt(bool *ok) const const
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.