6#include "validatorrequiredif_p.h"
14 :
ValidatorRule(*new ValidatorRequiredIfPrivate(field, otherField, otherValues, messages))
26 if (d->otherField.isEmpty() || d->otherValues.empty()) {
28 qCWarning(C_VALIDATOR).noquote() <<
debugString(c) <<
"Invalid validation data";
33 if (d->otherValues.contains(ov)) {
36 qCDebug(C_VALIDATOR).noquote().nospace()
37 <<
debugString(c) <<
" The field is not present or empty but \""
38 << d->otherField <<
"\" contains " << ov;
58 return c->
qtTrId(
"cutelyst-validator-genvalerr-req");
60 return c->
qtTrId(
"cutelyst-validator-genvalerr-req-label").
arg(_label);
QString qtTrId(const char *id, int n=-1) const
The field under validation must be present and not empty if the other field is equal to any value in ...
ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const override
~ValidatorRequiredIf() override
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
ValidatorRequiredIf(const QString &field, const QString &otherField, const QStringList &otherValues, const ValidatorMessages &messages=ValidatorMessages())
Base class for all validator rules.
QString validationError(Context *c, const QVariant &errorData={}) const
QString label(Context *c) const
bool trimBefore() const noexcept
QString validationDataError(Context *c, const QVariant &errorData={}) const
QString value(const ParamsMultiMap ¶ms) const
QString debugString(Context *c) const
The Cutelyst namespace holds all public Cutelyst API.
T value(const Key &key, const T &defaultValue) const const
QString arg(Args &&... args) const const
bool isEmpty() const const
void setValue(QVariant &&value)
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.