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