19 #include "validatorresult_p.h"
26 d(new ValidatorResultPrivate)
47 return d->errors.empty();
52 QStringList fieldErrors = d->errors.value(field);
53 fieldErrors.append(message);
54 d->errors.insert(field, fieldErrors);
61 auto i = d->errors.constBegin();
62 while (i != d->errors.constEnd()) {
63 strings.append(i.value());
77 return d->errors.contains(field);
84 if (!d->errors.empty()) {
85 auto i = d->errors.constBegin();
86 while (i != d->errors.constEnd()) {
87 json.insert(i.key(), QJsonValue(QJsonArray::fromStringList(i.value())));
97 return QStringList(d->errors.keys());
107 return d->values.value(field);
112 d->values.insert(field,
value);
122 return d->extras.value(field);
127 d->extras.insert(field,
extra);
QStringList errorStrings() const
Returns a list of all error messages.
QStringList failedFields() const
Returns a list of fields with errors.
QVariantHash values() const
Returns the values that have been extracted by the validators.
void addExtra(const QString &field, const QVariant &extra)
Adds new extra data that came up when validating the input field.
bool isValid() const
Returns true if the validation was successful.
ValidatorResult & operator=(const ValidatorResult &other)
Assigns other to this ValidatorResult.
void addError(const QString &field, const QString &message)
Adds new error information to the internal QHash.
QVariant value(const QString &field) const
Returns the extracted value for the input field.
QJsonObject errorsJsonObject() const
Returns the dictionray containing fields with errors as JSON object.
~ValidatorResult()
Deconstructs the ValidatorResult.
QVariantHash extras() const
Returns all extra data that has been extracted by the validators.
QHash< QString, QStringList > errors() const
Returns a dictionary containing fields with errors.
ValidatorResult()
Constructs a new ValidatorResult.
The Cutelyst namespace holds all public Cutelyst API.
QVariant extra(const QString &field) const
Returns the extra data for the input field.
void addValue(const QString &field, const QVariant &value)
Adds a new value extracted from the specified input field.
bool hasErrors(const QString &field) const
Returns true if the field has validation errors.
Provides information about performed validations.