6 #include "validatorrequiredunless_p.h" 14 :
ValidatorRule(*new ValidatorRequiredUnlessPrivate(field, otherField, otherValues, messages))
27 if (d->otherField.isEmpty() || d->otherValues.empty()) {
29 qCWarning(C_VALIDATOR).noquote() <<
"Invalid validation data";
34 if (!d->otherValues.contains(ov)) {
39 qCDebug(C_VALIDATOR).noquote().nospace()
40 <<
debugString(c) <<
" The field is not present or empty but \"" 41 << d->otherField <<
"\" not contains " << ov;
66 return c->
qtTrId(
"cutelyst-validator-genvalerr-req");
68 return c->
qtTrId(
"cutelyst-validator-genvalerr-req-label").
arg(_label);
ValidatorRequiredUnless(const QString &field, const QString &otherField, const QStringList &otherValues, const ValidatorMessages &messages=ValidatorMessages())
Stores custom error messages and the input field label.
The field under validation must be present and not empty unless the other field is equal to any value...
~ValidatorRequiredUnless() override
bool trimBefore() const noexcept
bool isEmpty() const const
The Cutelyst namespace holds all public Cutelyst API.
QString debugString(const Context *c) const
Base class for all validator rules.
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 genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
QString validationError(Context *c, const QVariant &errorData={}) const
QString validationDataError(Context *c, const QVariant &errorData={}) const
QString qtTrId(const char *id, int n=-1) const
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
ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const override
T value(const Key &key, const T &defaultValue) const const
void setValue(QVariant &&value)