cutelyst 3.9.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-2022 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);
86
91
96
102 bool isValid() const;
103
110 void addError(const QString &field, const QString &message);
111
117
125
133 QStringList errors(const QString &field) const;
134
142 bool hasErrors(const QString &field) const;
143
155
162
168 explicit operator bool() const { return isValid(); }
169
177 QVariantHash values() const;
178
187 QVariant value(const QString &field) const;
188
195 void addValue(const QString &field, const QVariant &value);
196
205 QVariantHash extras() const;
206
215 QVariant extra(const QString &field) const;
216
223 void addExtra(const QString &field, const QVariant &extra);
224
225private:
227};
228
229} // namespace Cutelyst
230
231#endif // CUTELYSTVALIDATORRESULT_H
QStringList failedFields() const
Returns a list of fields with errors.
QJsonObject errorsJsonObject() const
Returns the dictionray containing fields with errors as JSON object.
QHash< QString, QStringList > errors() const
Returns a dictionary containing fields with errors.
ValidatorResult & operator=(const ValidatorResult &other)
Assigns other to this ValidatorResult.
bool isValid() const
Returns true if the validation was successful.
void addError(const QString &field, const QString &message)
Adds new error information to the internal QHash.
ValidatorResult()
Constructs a new ValidatorResult.
QStringList errorStrings() const
Returns a list of all error messages.
bool hasErrors(const QString &field) const
Returns true if the field has validation errors.
The Cutelyst namespace holds all public Cutelyst API.
Definition Mainpage.dox:8