6 #include "validator_p.h"
8 #include <Cutelyst/application.h>
9 #include <Cutelyst/context.h>
10 #include <Cutelyst/request.h>
12 #include <QLoggingCategory>
16 Q_LOGGING_CATEGORY(C_VALIDATOR,
"cutelyst.utils.validator", QtWarningMsg)
19 : d_ptr(new ValidatorPrivate(translationContext))
24 const char *translationContext)
25 : d_ptr(new ValidatorPrivate(validators, translationContext))
35 if (!d->validators.empty()) {
36 qDeleteAll(d->validators.begin(), d->validators.end());
37 d->validators.clear();
70 if (d->validators.empty()) {
71 qCWarning(C_VALIDATOR) <<
"Validation started with empty validator list.";
76 qCWarning(C_VALIDATOR) <<
"Validation started with empty parameters.";
80 const bool noTrimming = flags.testFlag(
NoTrimming);
85 v->setTrimBefore(
false);
98 if (stopOnFirstError) {
125 v->setTranslationContext(d->translationContext);
126 d->validators.push_back(v);
The Cutelyst application.
void loadTranslations(const QString &filename, const QString &directory={}, const QString &prefix={}, const QString &suffix={})
void setStash(const QString &key, const QVariant &value)
ParamsMultiMap bodyParameters() const
ParamsMultiMap queryParameters() const
Provides information about performed validations.
void addExtra(const QString &field, const QVariant &extra)
void addValue(const QString &field, const QVariant &value)
QHash< QString, QStringList > errors() const noexcept
void addError(const QString &field, const QString &message)
QStringList errorStrings() const
Base class for all validator rules.
QString field() const noexcept
virtual ValidatorReturnType validate(Context *c, const ParamsMultiMap ¶ms) const =0
Validation processor for input data.
ValidatorResult validate(Context *c, ValidatorFlags flags=NoSpecialBehavior) const
Validator(const char *translationContext=nullptr)
void addValidator(ValidatorRule *v)
static void loadTranslations(Application *app)
The Cutelyst namespace holds all public Cutelyst API.
QMultiMap::const_iterator constBegin() const const
QMultiMap::const_iterator constEnd() const const
bool isEmpty() const const
QMultiMap< Key, T > & unite(QMultiMap< Key, T > &&other)
QVariant fromValue(T &&value)
bool isValid() const const
Contains the result of a single input parameter validation.