cutelyst 4.0.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
validatorresult.h
1/*
2 * SPDX-FileCopyrightText: (C) 2017-2023 Matthias Fehring <mf@huessenbergnetz.de>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef CUTELYSTVALIDATORRESULT_H
6#define CUTELYSTVALIDATORRESULT_H
7
8#include <Cutelyst/cutelyst_global.h>
9
10#include <QJsonObject>
11#include <QSharedDataPointer>
12#include <QString>
13#include <QStringList>
14#include <QVariantHash>
15
16namespace Cutelyst {
17
18class ValidatorResultPrivate;
19
71class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorResult
72{
73public:
81
85 ValidatorResult(const ValidatorResult &other) noexcept;
86
90 ValidatorResult(ValidatorResult &&other) noexcept;
91
95 ValidatorResult &operator=(const ValidatorResult &other) noexcept;
96
100 ValidatorResult &operator=(ValidatorResult &&other) noexcept;
101
106
112 [[nodiscard]] bool isValid() const noexcept;
113
120 void addError(const QString &field, const QString &message);
121
126 [[nodiscard]] QStringList errorStrings() const;
127
134 [[nodiscard]] QHash<QString, QStringList> errors() const noexcept;
135
143 [[nodiscard]] QStringList errors(const QString &field) const noexcept;
144
152 [[nodiscard]] bool hasErrors(const QString &field) const noexcept;
153
164 [[nodiscard]] QJsonObject errorsJsonObject() const;
165
171 [[nodiscard]] QStringList failedFields() const;
172
178 explicit operator bool() const noexcept { return isValid(); }
179
187 [[nodiscard]] QVariantHash values() const noexcept;
188
197 [[nodiscard]] QVariant value(const QString &field) const noexcept;
198
205 void addValue(const QString &field, const QVariant &value);
206
215 [[nodiscard]] QVariantHash extras() const noexcept;
216
225 [[nodiscard]] QVariant extra(const QString &field) const noexcept;
226
233 void addExtra(const QString &field, const QVariant &extra);
234
235private:
236 QSharedDataPointer<ValidatorResultPrivate> d;
237};
238
239} // namespace Cutelyst
240
241#endif // CUTELYSTVALIDATORRESULT_H
Provides information about performed validations.
ValidatorResult & operator=(const ValidatorResult &other) noexcept
Assigns other to this ValidatorResult.
ValidatorResult(const ValidatorResult &other) noexcept
Constructs a copy of other.
~ValidatorResult() noexcept
Deconstructs the ValidatorResult.
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:8