28 if (d->stashKey.isEmpty() || d->stashValues.isNull() || !d->stashValues.isValid()) {
30 qCWarning(C_VALIDATOR).noquote() <<
debugString(c) <<
"Invalid validation data";
34 const QString v =
value(params);
35 const QVariant sv = c->
stash(d->stashKey);
36 bool isRequired =
false;
38 if (d->stashValues.typeId() == QMetaType::QString) {
40 const QVariant _stashValues = c->
stash(d->stashValues.toString());
42 if (_stashValues.typeId() == QMetaType::QStringList) {
44 const auto str = sv.toString();
45 const auto strLst = _stashValues.toStringList();
46 isRequired = !strLst.contains(str);
48 }
else if (_stashValues.typeId() == QMetaType::QVariantList) {
50 const auto varLst = _stashValues.toList();
51 isRequired = !varLst.contains(sv);
55 qCWarning(C_VALIDATOR).noquote().nospace()
56 <<
debugString(c) <<
"Invalid validation data. The stash key \""
57 << d->stashValues.toString()
58 <<
"\" does not contain a QStringList or a QVariantList.";
62 }
else if (d->stashValues.typeId() == QMetaType::QStringList) {
64 const auto str = sv.toString();
65 const auto strLst = d->stashValues.toStringList();
66 isRequired = !strLst.contains(str);
68 }
else if (d->stashValues.typeId() == QMetaType::QVariantList) {
70 const auto varList = d->stashValues.toList();
71 isRequired = !varList.contains(sv);
76 <<
"Invalid validation data. "
77 "stashValues has to be one of QString, "
78 "QStringList or QVariantList.";
82 if (isRequired && v.isEmpty()) {
84 qCDebug(C_VALIDATOR).noquote().nospace()
85 <<
debugString(c) <<
" The field is not present or empty but stash key \""
86 << d->stashKey <<
"\" does not contain " << sv;
91 result.
value.setValue(v);
void stash(const QVariantHash &unite)
QString qtTrId(const char *id, int n=-1) const