cutelyst  4.5.1
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/Plugins/Utils/validator_export.h>
9 
10 #include <QJsonObject>
11 #include <QSharedDataPointer>
12 #include <QString>
13 #include <QStringList>
14 #include <QVariantHash>
15 
16 namespace Cutelyst {
17 
18 class ValidatorResultPrivate;
19 
71 class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorResult
72 {
73 public:
81 
85  ValidatorResult(const ValidatorResult &other) noexcept;
86 
91  ValidatorResult(ValidatorResult &&other) noexcept;
92 
96  ValidatorResult &operator=(const ValidatorResult &other) noexcept;
97 
102 
106  ~ValidatorResult() noexcept;
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 
245 private:
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.