6 #include "validatorcharnotallowed_p.h"
14 :
ValidatorRule(*new ValidatorCharNotAllowedPrivate(field, forbiddenChars, messages, defValKey))
26 for (
const QChar &forbiddenChar : forbiddenChars) {
30 *foundChar = forbiddenChar;
48 if (Q_LIKELY(!d->forbiddenChars.isEmpty())) {
56 qCWarning(C_VALIDATOR).noquote() <<
debugString(c) <<
"Empty validation data";
76 return c->
qtTrId(
"cutelyst-valcharnotallowed-genvalerr")
83 return c->
qtTrId(
"cutelyst-valcharnotallowed-genvalerr-label")
84 .
arg(_label, d->forbiddenChars,
QString(foundChar));
95 return c->
qtTrId(
"cutelyst-valcharnotallowed-genvaldataerr");
98 return c->
qtTrId(
"cutelyst-valcharnotallowed-genvaldataerr-label").
arg(_label);
QString qtTrId(const char *id, int n=-1) const
Validates an input field for not allowed characters.
QString genericValidationDataError(Context *c, const QVariant &errorData=QVariant()) const override
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
~ValidatorCharNotAllowed() override
ValidatorCharNotAllowed(const QString &field, const QString &forbiddenChars, 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, const QString &forbiddenChars, QChar *foundChar=nullptr)
Returns true if value does not contain any of the forbideden characters.
The Cutelyst namespace holds all public Cutelyst API.
QString arg(Args &&... args) const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
void setValue(QVariant &&value)
QChar toChar() const const
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.