6 #include "validatorsame_p.h" 12 const char *otherLabel,
15 :
ValidatorRule(*new ValidatorSamePrivate(field, otherField, otherLabel, messages, defValKey))
34 qCDebug(C_VALIDATOR).noquote().nospace()
35 <<
debugString(c) <<
" The value in \"" << d->otherField
36 <<
"\" is not the same: " << v <<
" != " << ov;
59 _olabel = d->translationContext ? c->
translate(d->translationContext, d->otherLabel)
60 : c->
qtTrId(d->otherLabel);
62 _olabel = d->otherField;
68 return c->
qtTrId(
"cutelyst-valsame-genvalerr").
arg(_olabel);
73 return c->
qtTrId(
"cutelyst-valsame-genvalerr-label").
arg(_label, _olabel);
Stores custom error messages and the input field label.
~ValidatorSame() override
bool trimBefore() const noexcept
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
void defaultValue(Context *c, ValidatorReturnType *result) const
bool isEmpty() const const
QString translate(const char *context, const char *sourceText, const char *disambiguation=nullptr, int n=-1) const
The Cutelyst namespace holds all public Cutelyst API.
QString debugString(const Context *c) const
Base class for all validator rules.
ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const override
QString value(const ParamsMultiMap ¶ms) const
QString label(const Context *c) const
std::function< void(ValidatorReturnType &&result)> ValidatorRtFn
Void callback function for validator rules that processes the ValidatorReturnType.
QString validationError(Context *c, const QVariant &errorData={}) const
QString qtTrId(const char *id, int n=-1) const
ValidatorSame(const QString &field, const QString &otherField, const char *otherLabel=nullptr, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey={})
Contains the result of a single input parameter validation.
void validateCb(Context *c, const ParamsMultiMap ¶ms, ValidatorRtFn cb) const override
QString arg(Args &&... args) const const
T value(const Key &key, const T &defaultValue) const const
void setValue(QVariant &&value)
The given field must match the field under validation.