6#include "validatorresult_p.h"
14 : d(new ValidatorResultPrivate)
35 QStringList fieldErrors = d->errors.value(field);
36 fieldErrors.append(message);
37 d->errors.insert(field, fieldErrors);
44 auto i = d->errors.constBegin();
45 while (i != d->errors.constEnd()) {
46 strings.append(i.value());
60 return d->errors.value(field);
65 return d->errors.contains(field);
72 if (!d->errors.empty()) {
73 auto i = d->errors.constBegin();
74 while (i != d->errors.constEnd()) {
75 json.insert(i.key(), QJsonValue(QJsonArray::fromStringList(i.value())));
85 return QStringList(d->errors.keys());
95 return d->values.value(field);
100 d->values.insert(field,
value);
110 return d->extras.value(field);
115 d->extras.insert(field,
extra);
Provides information about performed validations.
void addExtra(const QString &field, const QVariant &extra)
Adds new extra data that came up when validating the input field.
QStringList failedFields() const
Returns a list of fields with errors.
ValidatorResult & operator=(const ValidatorResult &other) noexcept
Assigns other to this ValidatorResult.
QJsonObject errorsJsonObject() const
Returns the dictionray containing fields with errors as JSON object.
bool hasErrors(const QString &field) const noexcept
Returns true if the field has validation errors.
void addValue(const QString &field, const QVariant &value)
Adds a new value extracted from the specified input field.
QVariant value(const QString &field) const noexcept
Returns the extracted value for the input field.
QHash< QString, QStringList > errors() const noexcept
Returns a dictionary containing fields with errors.
void addError(const QString &field, const QString &message)
Adds new error information to the internal QHash.
QVariant extra(const QString &field) const noexcept
Returns the extra data for the input field.
ValidatorResult()
Constructs a new ValidatorResult.
QStringList errorStrings() const
Returns a list of all error messages.
QVariantHash values() const noexcept
Returns the values that have been extracted by the validators.
~ValidatorResult() noexcept
Deconstructs the ValidatorResult.
QVariantHash extras() const noexcept
Returns all extra data that has been extracted by the validators.
The Cutelyst namespace holds all public Cutelyst API.