6#include "validatorresult_p.h"
14 : d(new ValidatorResultPrivate)
35 return d->errors.empty();
41 fieldErrors.
append(message);
42 d->errors.insert(field, fieldErrors);
50 while (i != d->errors.constEnd()) {
65 return d->errors.
value(field);
70 return d->errors.contains(field);
77 if (!d->errors.empty()) {
78 auto i = d->errors.constBegin();
79 while (i != d->errors.constEnd()) {
100 return d->values.
value(field);
105 d->values.insert(field,
value);
115 return d->extras.
value(field);
120 d->extras.insert(field,
extra);
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.
QJsonObject errorsJsonObject() const
Returns the dictionray containing fields with errors as JSON object.
QVariant value(const QString &field) const
Returns the extracted value for the input field.
void addValue(const QString &field, const QVariant &value)
Adds a new value extracted from the specified input field.
QHash< QString, QStringList > errors() const
Returns a dictionary containing fields with errors.
QVariantHash values() const
Returns the values that have been extracted by the validators.
~ValidatorResult()
Deconstructs the ValidatorResult.
QVariant extra(const QString &field) const
Returns the extra data for the input field.
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.
QVariantHash extras() const
Returns all extra data that has been extracted by the validators.
bool hasErrors(const QString &field) const
Returns true if the field has validation errors.
The Cutelyst namespace holds all public Cutelyst API.
QJsonArray fromStringList(const QStringList &list)
iterator insert(const QString &key, const QJsonValue &value)
void append(const T &value)
const_iterator constBegin() const const
T value(int i) const const