6#include "validatorrequiredwithout_p.h"
11 const QStringList &otherFields,
26 if (d->otherFields.isEmpty()) {
28 qCWarning(C_VALIDATOR).noquote() <<
"Invalid validation data";
30 const QString v =
value(params);
32 auto it = std::ranges::find_if(
33 d->otherFields, [params](
const QString &other) { return !params.contains(other); });
35 bool otherMissing = (it != d->otherFields.end());
38 result.
value.setValue(v);
41 qCDebug(C_VALIDATOR).noquote().nospace()
42 <<
debugString(c) <<
" The field is not present or empty but the field \""
43 << *it <<
"\" is not present";
47 result.
value.setValue(v);
63 const QVariant &errorData)
const
67 const QString _label =
label(c);
68 if (_label.isEmpty()) {
69 return c->
qtTrId(
"cutelyst-validator-genvalerr-req");
71 return c->
qtTrId(
"cutelyst-validator-genvalerr-req-label").arg(_label);
QString qtTrId(const char *id, int n=-1) const
ValidatorRequiredWithout(const QString &field, const QStringList &otherFields, const ValidatorMessages &messages=ValidatorMessages())
~ValidatorRequiredWithout() override
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
void validateCb(Context *c, const ParamsMultiMap ¶ms, ValidatorRtFn cb) const override
ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const override
QString field() const noexcept
QString validationError(Context *c, const QVariant &errorData={}) const
QString label(const Context *c) const
QString debugString(const Context *c) const
ValidatorRule(const QString &field, const ValidatorMessages &messages={}, const QString &defValKey={}, QByteArrayView validatorName=nullptr)
QString validationDataError(Context *c, const QVariant &errorData={}) const
std::function< void(ValidatorReturnType &&result)> ValidatorRtFn
Void callback function for validator rules that processes the ValidatorReturnType.
QString value(const ParamsMultiMap ¶ms) 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.