cutelyst 4.3.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
92
96 ValidatorResult &operator=(const ValidatorResult &other) noexcept;
97
102
107
113 [[nodiscard]] bool isValid() const noexcept;
114
124 void addError(const QString &field, const QString &message);
125
129 [[nodiscard]] QStringList errorStrings() const;
130
138 [[nodiscard]] QHash<QString, QStringList> errors() const noexcept;
139
145 [[nodiscard]] QStringList errors(const QString &field) const noexcept;
146
152 [[nodiscard]] bool hasErrors(const QString &field) const noexcept;
153
164 [[nodiscard]] QJsonObject errorsJsonObject() const;
165
170 [[nodiscard]] QStringList failedFields() const;
171
177 explicit operator bool() const noexcept { return isValid(); }
178
190 [[nodiscard]] QVariantHash values() const noexcept;
191
202 [[nodiscard]] QVariant value(const QString &field) const noexcept;
203
210 void addValue(const QString &field, const QVariant &value);
211
222 [[nodiscard]] QVariantHash extras() const noexcept;
223
235 [[nodiscard]] QVariant extra(const QString &field) const noexcept;
236
243 void addExtra(const QString &field, const QVariant &extra);
244
245private:
246 QSharedDataPointer<ValidatorResultPrivate> d;
247};
248
249} // namespace Cutelyst
250
251#endif // CUTELYSTVALIDATORRESULT_H
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
The Cutelyst namespace holds all public Cutelyst API.