cutelyst  4.5.1
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 namespace Cutelyst {
12 
13 class ValidatorDomainPrivate;
14 
39 class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorDomain : public ValidatorRule
40 {
41  Q_GADGET
42 public:
46  enum Diagnose : quint8 {
47  Valid = 0,
49  MissingDNS = 1,
51  InvalidChars = 2,
52  LabelTooLong =
53  3,
54  TooLong = 4,
55  InvalidLabelCount =
56  5,
57  EmptyLabel = 6,
58  InvalidTLD = 7,
59  DashStart = 8,
60  DashEnd = 9,
61  DigitStart = 10,
62  DNSTimeout = 11
63  };
64  Q_ENUM(Diagnose)
65 
66 
75  ValidatorDomain(const QString &field,
76  bool checkDNS = false,
77  const ValidatorMessages &messages = ValidatorMessages(),
78  const QString &defValKey = QString());
79 
83  ~ValidatorDomain() override;
84 
97  static bool validate(const QString &value,
98  bool checkDNS,
99  Diagnose *diagnose = nullptr,
100  QString *extractedValue = nullptr);
101 
110  static QString diagnoseString(Context *c, Diagnose diagnose, const QString &label = QString());
111 
112 protected:
119  ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
120 
126  QString genericValidationError(Context *c,
127  const QVariant &errorData = QVariant()) const override;
128 
129 private:
130  Q_DECLARE_PRIVATE(ValidatorDomain) // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
131  Q_DISABLE_COPY(ValidatorDomain)
132 };
133 
134 } // namespace Cutelyst
135 
136 #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.
Definition: validatorrule.h:49