Cutelyst
2.13.0
Cutelyst
Plugins
Utils
Validator
validatordomain.h
1
/*
2
* Copyright (C) 2018 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
#ifndef CUTELYSTVALIDATORDOMAIN_H
20
#define CUTELYSTVALIDATORDOMAIN_H
21
22
#include <Cutelyst/cutelyst_global.h>
23
#include "validatorrule.h"
24
25
namespace
Cutelyst
{
26
27
class
ValidatorDomainPrivate;
28
46
class
CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT
ValidatorDomain
:
public
ValidatorRule
47
{
48
Q_GADGET
49
public
:
53
enum
Diagnose
: quint8 {
54
Valid = 0,
55
MissingDNS = 1,
56
InvalidChars = 2,
57
LabelTooLong = 3,
58
TooLong = 4,
59
InvalidLabelCount = 5,
60
EmptyLabel = 6,
61
InvalidTLD = 7,
62
DashStart = 8,
63
DashEnd = 9,
64
DigitStart = 10,
65
DNSTimeout = 11
66
};
67
Q_ENUM(Diagnose)
68
69
76
ValidatorDomain
(
const
QString
&field,
bool
checkDNS =
false
,
const
ValidatorMessages
&messages =
ValidatorMessages
(),
const
QString
&defValKey =
QString
());
77
81
~
ValidatorDomain
()
override
;
82
92
static
bool
validate(
const
QString
&value,
bool
checkDNS, Diagnose *diagnose =
nullptr
,
QString
*extractedValue =
nullptr
);
93
101
static
QString
diagnoseString(
Context
*c, Diagnose diagnose,
const
QString
&label =
QString
());
102
103
protected
:
110
ValidatorReturnType
validate(
Context
*c,
const
ParamsMultiMap
¶ms)
const override
;
111
117
QString
genericValidationError(
Context
*c,
const
QVariant
&errorData =
QVariant
())
const override
;
118
119
private
:
120
Q_DECLARE_PRIVATE(
ValidatorDomain
)
121
Q_DISABLE_COPY(
ValidatorDomain
)
122
};
123
124
}
125
126
#endif // CUTELYSTVALIDATORDOMAIN_H
Cutelyst::ValidatorDomain
Checks if the value of the input field contains FQDN according to RFC 1035.
Definition:
validatordomain.h:46
Cutelyst::ValidatorMessages
Stores custom error messages and the input field label.
Definition:
validatorrule.h:144
QMap
Cutelyst::Context
The Cutelyst Context.
Definition:
context.h:51
Cutelyst
The Cutelyst namespace holds all public Cutelyst API.
Definition:
Mainpage.dox:7
QString
Cutelyst::ValidatorRule
Base class for all validator rules.
Definition:
validatorrule.h:292
Cutelyst::ValidatorDomain::Diagnose
Diagnose
Possible diagnose information for the checked domain.
Definition:
validatordomain.h:53
Cutelyst::ValidatorReturnType
Contains the result of a single input parameter validation.
Definition:
validatorrule.h:62
QVariant
Generated by
1.8.14