cutelyst 5.0.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-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
11namespace Cutelyst {
12
13class ValidatorDomainPrivate;
14
41class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorDomain : public ValidatorRule
42{
43 Q_GADGET
44public:
67 Q_ENUM(Diagnose)
68
69
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
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(const Context *c, Diagnose diagnose, const QString &label = {});
141
142protected:
149 ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
150
160 void validateCb(Context *c, const ParamsMultiMap &params, ValidatorRtFn cb) const override;
161
167 QString genericValidationError(Context *c,
168 const QVariant &errorData = QVariant()) const override;
169
170private:
171 Q_DECLARE_PRIVATE(ValidatorDomain) // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
172 Q_DISABLE_COPY(ValidatorDomain)
173};
174
175} // namespace Cutelyst
176
177Q_DECLARE_OPERATORS_FOR_FLAGS(Cutelyst::ValidatorDomain::Options);
178
179#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.
Option
Options for the domain validation.
static QString diagnoseString(const Context *c, Diagnose diagnose, const QString &label={})
ValidatorDomain(const QString &field, Options options=NoOption, const ValidatorMessages &messages={}, const QString &defValKey={})
Constructs a new ValidatorDomain object with the given parameters.
Diagnose
Possible diagnose information for the checked domain.
QString label(const Context *c) const
ValidatorRule(const QString &field, const ValidatorMessages &messages={}, const QString &defValKey={}, QByteArrayView validatorName=nullptr)
QString value(const ParamsMultiMap &params) const
QMultiMap< QString, QString > ParamsMultiMap
static void validateCb(const QString &value, Options options, std::function< void(Diagnose diagnose, const QString &extractedValue)> cb)
Checks if value is a vaid fully qualified domain name and writes the result to the callback cb.
static bool validate(const QString &value, Diagnose *diagnose=nullptr, QString *extractedValue=nullptr)
Returns true if value is a valid fully qualified domain name.
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.