6#include "validatorrequiredwithall_p.h"
11 const QStringList &otherFields,
13 :
ValidatorRule(*new ValidatorRequiredWithAllPrivate(field, otherFields, messages))
26 if (d->otherFields.empty()) {
28 qCWarning(C_VALIDATOR).noquote() <<
debugString(c) <<
"Invalid validation data";
31 bool containsAll =
true;
33 const QStringList ofc = d->otherFields;
35 for (
const QString &other : ofc) {
36 if (!params.contains(other)) {
42 const QString v =
value(params);
46 result.
value.setValue(v);
50 <<
"The field is not present or empty but all other "
51 "required fields are present";
55 result.
value.setValue(v);
64 const QVariant &errorData)
const
68 const QString _label =
label(c);
69 if (_label.isEmpty()) {
70 return c->
qtTrId(
"cutelyst-validator-genvalerr-req");
72 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 only if all of the other specified fields ar...
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
ValidatorRequiredWithAll(const QString &field, const QStringList &otherFields, const ValidatorMessages &messages=ValidatorMessages())
ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const override
~ValidatorRequiredWithAll() override
Base class for all validator rules.
QString validationError(Context *c, const QVariant &errorData={}) const
QString label(Context *c) const
QString validationDataError(Context *c, const QVariant &errorData={}) const
QString value(const ParamsMultiMap ¶ms) const
QString debugString(Context *c) const
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.