Cutelyst  1.11.0
validatorresult.cpp
1 /*
2  * Copyright (C) 2017 Matthias Fehring <kontakt@buschmann23.de>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "validatorresult_p.h"
20 
21 using namespace Cutelyst;
22 
24  d(new ValidatorResultPrivate)
25 {
26 }
27 
29  d(other.d)
30 {
31 }
32 
34 {
35  d = other.d;
36  return *this;
37 }
38 
40 {
41 }
42 
44 {
45  return d->errors.empty();
46 }
47 
48 void ValidatorResult::addError(const QString &field, const QString &message)
49 {
50  d->errorStrings.append(message);
51  QStringList fieldErrors = d->errors.value(field);
52  fieldErrors.append(message);
53  d->errors.insert(field, fieldErrors);
54 }
55 
56 QStringList ValidatorResult::errorStrings() const
57 {
58  return d->errorStrings;
59 }
60 
61 QHash<QString, QStringList> ValidatorResult::errors() const
62 {
63  return d->errors;
64 }
ValidatorResult & operator=(const ValidatorResult &other)
Assigns other to this object.
QStringList errorStrings() const
Returns a list of error messages.
bool isValid() const
Returns true if the validation was successful.
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
void addError(const QString &field, const QString &message)
Adds new error information to the.
~ValidatorResult()
Deconstructs the ValidatorResult.
QHash< QString, QStringList > errors() const
Returns a dictionary containing fields with errors.
ValidatorResult()
Constructs a new ValidatorResult.
Contains the result of Validator.