6 #include "validatorresult_p.h"
13 d(new ValidatorResultPrivate)
34 return d->errors.empty();
39 QStringList fieldErrors = d->errors.value(field);
40 fieldErrors.append(message);
41 d->errors.insert(field, fieldErrors);
48 auto i = d->errors.constBegin();
49 while (i != d->errors.constEnd()) {
50 strings.append(i.value());
64 return d->errors.contains(field);
71 if (!d->errors.empty()) {
72 auto i = d->errors.constBegin();
73 while (i != d->errors.constEnd()) {
74 json.insert(i.key(), QJsonValue(QJsonArray::fromStringList(i.value())));
84 return QStringList(d->errors.keys());
94 return d->values.value(field);
99 d->values.insert(field,
value);
109 return d->extras.value(field);
114 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.
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.