cutelyst  3.7.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-2022 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 <Cutelyst/cutelyst_global.h>
10 #include "validatorrule.h"
11 
12 namespace Cutelyst {
13 
14 class ValidatorDomainPrivate;
15 
33 class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorDomain : public ValidatorRule
34 {
35  Q_GADGET
36 public:
40  enum Diagnose : quint8 {
41  Valid = 0,
42  MissingDNS = 1,
43  InvalidChars = 2,
44  LabelTooLong = 3,
45  TooLong = 4,
46  InvalidLabelCount = 5,
47  EmptyLabel = 6,
48  InvalidTLD = 7,
49  DashStart = 8,
50  DashEnd = 9,
51  DigitStart = 10,
52  DNSTimeout = 11
53  };
54  Q_ENUM(Diagnose)
55 
56 
63  ValidatorDomain(const QString &field, bool checkDNS = false, const ValidatorMessages &messages = ValidatorMessages(), const QString &defValKey = QString());
64 
68  ~ValidatorDomain() override;
69 
79  static bool validate(const QString &value, bool checkDNS, Diagnose *diagnose = nullptr, QString *extractedValue = nullptr);
80 
88  static QString diagnoseString(Context *c, Diagnose diagnose, const QString &label = QString());
89 
90 protected:
97  ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
98 
104  QString genericValidationError(Context *c, const QVariant &errorData = QVariant()) const override;
105 
106 private:
107  Q_DECLARE_PRIVATE(ValidatorDomain)
108  Q_DISABLE_COPY(ValidatorDomain)
109 };
110 
111 }
112 
113 #endif // CUTELYSTVALIDATORDOMAIN_H
The Cutelyst Context.
Definition: context.h:39
Checks if the value of the input field contains 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.
Definition: Mainpage.dox:8
QMultiMap< QString, QString > ParamsMultiMap
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.
Definition: validatorrule.h:49