cutelyst 4.3.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-2023 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#include <Cutelyst/cutelyst_global.h>
12
13namespace Cutelyst {
14
15class ValidatorDomainPrivate;
16
41class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorDomain : public ValidatorRule
42{
43 Q_GADGET
44public:
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 };
66 Q_ENUM(Diagnose)
67
68
77 ValidatorDomain(const QString &field,
78 bool checkDNS = false,
79 const ValidatorMessages &messages = ValidatorMessages(),
80 const QString &defValKey = QString());
81
85 ~ValidatorDomain() override;
86
99 static bool validate(const QString &value,
100 bool checkDNS,
101 Diagnose *diagnose = nullptr,
102 QString *extractedValue = nullptr);
103
112 static QString diagnoseString(Context *c, Diagnose diagnose, const QString &label = QString());
113
114protected:
121 ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
122
128 QString genericValidationError(Context *c,
129 const QVariant &errorData = QVariant()) const override;
130
131private:
132 Q_DECLARE_PRIVATE(ValidatorDomain) // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
133 Q_DISABLE_COPY(ValidatorDomain)
134};
135
136} // namespace Cutelyst
137
138#endif // CUTELYSTVALIDATORDOMAIN_H
The Cutelyst Context.
Definition context.h:42
Checks if the value of the input field contains a FQDN according to RFC 1035.
Diagnose
Possible diagnose information for the checked domain.
Base class for all validator rules.
The Cutelyst namespace holds all public Cutelyst API.
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.