cutelyst
5.0.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
validatordomain.h
1
/*
2
* SPDX-FileCopyrightText: (C) 2018-2025 Matthias Fehring <mf@huessenbergnetz.de>
3
* SPDX-License-Identifier: BSD-3-Clause
4
*/
5
6
#ifndef CUTELYSTVALIDATORDOMAIN_H
7
#define CUTELYSTVALIDATORDOMAIN_H
8
9
#include "validatorrule.h"
10
11
namespace
Cutelyst
{
12
13
class
ValidatorDomainPrivate;
14
41
class
CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT
ValidatorDomain
:
public
ValidatorRule
42
{
43
Q_GADGET
44
public
:
48
enum
Diagnose
: quint8 {
49
Valid = 0,
51
MissingDNS = 1,
53
InvalidChars = 2,
54
LabelTooLong =
55
3,
56
TooLong = 4,
57
InvalidLabelCount =
58
5,
59
EmptyLabel = 6,
60
InvalidTLD = 7,
61
DashStart = 8,
62
DashEnd = 9,
63
DigitStart = 10,
64
DNSTimeout = 11,
65
DNSError = 12
66
};
67
Q_ENUM(Diagnose)
68
69
73
enum
Option
{
74
NoOption = 0,
75
CheckARecord = 1,
76
CheckAAAARecord = 2,
77
CheckDNS = CheckARecord | CheckAAAARecord
79
};
80
Q_DECLARE_FLAGS(Options, Option)
81
82
92
explicit
ValidatorDomain
(
const
QString
&field,
93
Options options = NoOption,
94
const
ValidatorMessages
&messages = {},
95
const
QString
&defValKey = {});
96
100
~ValidatorDomain
()
override
;
101
114
static
bool
validate(
const
QString
&value,
115
Diagnose
*diagnose =
nullptr
,
116
QString
*extractedValue =
nullptr
);
117
127
static
void
128
validateCb(
const
QString
&value,
129
Options options,
130
std::function<
void
(
Diagnose
diagnose,
const
QString
&extractedValue)> cb);
131
140
static
QString
diagnoseString(
Context
*c,
Diagnose
diagnose,
const
QString
&label = {});
141
142
protected
:
149
ValidatorReturnType
validate(
Context
*c,
const
ParamsMultiMap
¶ms)
const override
;
150
160
void
validateCb(
Context
*c,
const
ParamsMultiMap
¶ms, ValidatorRtFn cb)
const override
;
161
167
QString
genericValidationError(
Context
*c,
168
const
QVariant
&errorData =
QVariant
())
const override
;
169
170
private
:
171
Q_DECLARE_PRIVATE(
ValidatorDomain
)
// NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
172
Q_DISABLE_COPY(
ValidatorDomain
)
173
};
174
175
}
// namespace Cutelyst
176
177
Q_DECLARE_OPERATORS_FOR_FLAGS(Cutelyst::ValidatorDomain::Options);
178
179
#endif
// CUTELYSTVALIDATORDOMAIN_H
Cutelyst::Context
The Cutelyst Context.
Definition
context.h:42
Cutelyst::ValidatorDomain
Checks if the value of the input field contains a FQDN according to RFC 1035.
Definition
validatordomain.h:42
Cutelyst::ValidatorDomain::Option
Option
Options for the domain validation.
Definition
validatordomain.h:73
Cutelyst::ValidatorDomain::~ValidatorDomain
~ValidatorDomain() override
Cutelyst::ValidatorDomain::Diagnose
Diagnose
Possible diagnose information for the checked domain.
Definition
validatordomain.h:48
Cutelyst::ValidatorRule
Base class for all validator rules.
Definition
validatorrule.h:354
Cutelyst
The Cutelyst namespace holds all public Cutelyst API.
Definition
group-core-actions.dox:1
QMultiMap
QString
QVariant
Cutelyst::ValidatorMessages
Stores custom error messages and the input field label.
Definition
validatorrule.h:153
Cutelyst::ValidatorReturnType
Contains the result of a single input parameter validation.
Definition
validatorrule.h:52
Cutelyst
Plugins
Utils
Validator
validatordomain.h
Generated on Mon Apr 21 2025 23:25:44 for cutelyst by
1.9.8