6#include "validatorrequiredwithoutall_p.h"
12 const QStringList &otherFields,
14 :
ValidatorRule(*new ValidatorRequiredWithoutAllPrivate(field, otherFields, messages))
27 if (d->otherFields.empty()) {
29 qCWarning(C_VALIDATOR).noquote() <<
"Invalid validation data";
32 const QStringList ofc = d->otherFields;
34 bool withoutAll =
true;
36 for (
const QString &other : ofc) {
37 if (params.contains(other)) {
43 const QString v =
value(params);
47 result.
value.setValue(v);
51 <<
"The field is not present or empty and all of "
52 "the other fields are not present";
56 result.
value.setValue(v);
65 const QVariant &errorData)
const
69 const QString _label =
label(c);
70 if (_label.isEmpty()) {
71 return c->
qtTrId(
"cutelyst-validator-genvalerr-req");
73 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 when all of the other specified fields ...
~ValidatorRequiredWithoutAll() override
ValidatorRequiredWithoutAll(const QString &field, const QStringList &otherFields, const ValidatorMessages &messages=ValidatorMessages())
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const 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.