27 if (d->stashKey.isEmpty() || d->stashValues.isNull() || !d->stashValues.isValid()) {
29 qCWarning(C_VALIDATOR).noquote() <<
debugString(c) <<
"Invalid validation data";
33 const QString v =
value(params);
34 const QVariant sv = c->
stash(d->stashKey);
35 bool isRequired =
false;
37 if (d->stashValues.typeId() == QMetaType::QString) {
39 const QVariant _stashValues = c->
stash(d->stashValues.toString());
41 if (_stashValues.typeId() == QMetaType::QStringList) {
43 const auto str = sv.toString();
44 const auto strList = _stashValues.toStringList();
45 isRequired = strList.contains(str);
47 }
else if (_stashValues.typeId() == QMetaType::QVariantList) {
49 const auto varList = _stashValues.toList();
50 isRequired = varList.contains(sv);
54 qCWarning(C_VALIDATOR).noquote().nospace()
55 <<
debugString(c) <<
"Invalid validation data. The stash key \""
56 << d->stashValues.toString()
57 <<
"\" does not contain a QStringList or a QVariantList.";
61 }
else if (d->stashValues.typeId() == QMetaType::QStringList) {
63 const auto str = sv.toString();
64 const auto strList = d->stashValues.toStringList();
65 isRequired = strList.contains(str);
67 }
else if (d->stashValues.typeId() == QMetaType::QVariantList) {
69 const auto varList = d->stashValues.toList();
70 isRequired = varList.contains(sv);
75 <<
"Invalid validation data. "
76 "stashValues has to be one of QString, "
77 "QStringList or QVariantList.";
81 if (isRequired && v.isEmpty()) {
83 qCDebug(C_VALIDATOR).noquote().nospace()
84 <<
debugString(c) <<
" The field is not present or empty but stash key \""
85 << d->stashKey <<
"\" contains " << sv;
90 result.
value.setValue(v);
void stash(const QVariantHash &unite)
QString qtTrId(const char *id, int n=-1) const