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;
181 explicit operator
bool() const noexcept {
return isValid(); }
194 [[nodiscard]] QVariantHash values() const noexcept;
226 [[nodiscard]] QVariantHash extras() const noexcept;
259class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT AwaitedValidatorResult
262 bool await_ready()
const noexcept {
return m_hasResult; }
264 bool await_suspend(std::coroutine_handle<> h)
noexcept
270 QString(), QStringLiteral(
"Internal Server Error: the context was destroyed."));
276 return !await_ready();
281 explicit AwaitedValidatorResult(
Context *c)
297 friend class Validator;
304 std::coroutine_handle<> m_handle;
305 bool m_hasResult{
false};
Provides information about performed validations.
QStringList failedFields() const
Returns a list of fields with errors.
ValidatorResult & operator=(const ValidatorResult &other) noexcept
QJsonObject errorsJsonObject() const
bool hasErrors(const QString &field) const noexcept
ValidatorResult(const ValidatorResult &other) noexcept
ValidatorResult & operator=(ValidatorResult &&other) noexcept
QHash< QString, QStringList > errors() const noexcept
void addError(const QString &field, const QString &message)
QStringList errorStrings() const
ValidatorResult(ValidatorResult &&other) noexcept
~ValidatorResult() noexcept
bool isValid() const noexcept
The Cutelyst namespace holds all public Cutelyst API.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void destroyed(QObject *obj)
bool disconnect(const QMetaObject::Connection &connection)