6 #include "validatorrequiredwithall_p.h" 13 :
ValidatorRule(*new ValidatorRequiredWithAllPrivate(field, otherFields, messages))
26 if (d->otherFields.empty()) {
28 qCWarning(C_VALIDATOR).noquote() <<
debugString(c) <<
"Invalid validation data";
30 const bool containsAll = std::ranges::all_of(
31 d->otherFields, [params](
const QString &other) { return params.contains(other); });
41 <<
"The field is not present or empty but all other " 42 "required fields are present";
68 return c->
qtTrId(
"cutelyst-validator-genvalerr-req");
70 return c->
qtTrId(
"cutelyst-validator-genvalerr-req-label").
arg(_label);
~ValidatorRequiredWithAll() override
void validateCb(Context *c, const ParamsMultiMap ¶ms, ValidatorRtFn cb) const override
Stores custom error messages and the input field label.
The field under validation must be present and not empty only if all of the other specified fields ar...
ValidatorRequiredWithAll(const QString &field, const QStringList &otherFields, const ValidatorMessages &messages=ValidatorMessages())
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 validationError(Context *c, const QVariant &errorData={}) const
QString validationDataError(Context *c, const QVariant &errorData={}) const
QString qtTrId(const char *id, int n=-1) const
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const override
Contains the result of a single input parameter validation.
QString arg(Args &&... args) const const
void setValue(QVariant &&value)