5#ifndef CUTELYSTVALIDATORRESULT_H
6#define CUTELYSTVALIDATORRESULT_H
8#include <Cutelyst/Plugins/Utils/validator_export.h>
9#include <Cutelyst/context.h>
15#include <QSharedDataPointer>
18#include <QVariantHash>
22class ValidatorResultPrivate;
117 [[nodiscard]]
bool isValid() const noexcept;
128 void addError(const QString &field, const QString &message);
133 [[nodiscard]] QStringList errorStrings() const;
142 [[nodiscard]] QHash<QString, QStringList> errors() const noexcept;
149 [[nodiscard]] QStringList errors(const QString &field) const noexcept;
156 [[nodiscard]]
bool hasErrors(const QString &field) const noexcept;
168 [[nodiscard]] QJsonObject errorsJsonObject() const;
174 [[nodiscard]] QStringList failedFields() const;
181 explicit operator
bool() const noexcept {
return isValid(); }
194 [[nodiscard]] QVariantHash values() const noexcept;
206 [[nodiscard]] QVariant value(const QString &field) const noexcept;
214 void addValue(const QString &field, const QVariant &value);
226 [[nodiscard]] QVariantHash extras() const noexcept;
239 [[nodiscard]] QVariant extra(const QString &field) const noexcept;
247 void addExtra(const QString &field, const QVariant &extra);
250 QSharedDataPointer<ValidatorResultPrivate> d;
262 bool await_ready()
const noexcept {
return m_hasResult; }
264 bool await_suspend(std::coroutine_handle<> h)
noexcept
268 m_destroyConn = QObject::connect(m_receiver, &QObject::destroyed, [h,
this] {
270 QString(), QStringLiteral(
"Internal Server Error: the context was destroyed."));
276 return !await_ready();
301 QMetaObject::Connection m_destroyConn;
302 QPointer<Context> m_receiver;
304 std::coroutine_handle<> m_handle;
305 bool m_hasResult{
false};
Coroutine awaitable for ValidatorResult.
Provides information about performed validations.
ValidatorResult & operator=(const ValidatorResult &other) noexcept
ValidatorResult(const ValidatorResult &other) noexcept
ValidatorResult & operator=(ValidatorResult &&other) noexcept
ValidatorResult(ValidatorResult &&other) noexcept
~ValidatorResult() noexcept
Validation processor for input data.
The Cutelyst namespace holds all public Cutelyst API.