cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
validatorip.h
1/*
2 * SPDX-FileCopyrightText: (C) 2017-2023 Matthias Fehring <mf@huessenbergnetz.de>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef CUTELYSTVALIDATORIP_H
6#define CUTELYSTVALIDATORIP_H
7
8#include "validatorrule.h"
9
10#include <Cutelyst/cutelyst_global.h>
11
12namespace Cutelyst {
13
14class ValidatorIpPrivate;
15
36class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorIp : public ValidatorRule
37{
38public:
43 NoConstraint = 0,
44 IPv4Only = 1,
45 IPv6Only = 2,
46 NoPrivateRange = 4,
48 NoReservedRange = 8,
50 NoMultiCast = 16,
51 PublicOnly = 32
52 };
53 Q_DECLARE_FLAGS(Constraints, Constraint)
54
55
64 ValidatorIp(const QString &field,
65 Constraints constraints = NoConstraint,
66 const ValidatorMessages &messages = ValidatorMessages(),
67 const QString &defValKey = QString());
68
72 ~ValidatorIp() override;
73
81 static bool validate(const QString &value, Constraints constraints = NoConstraint);
82
83protected:
90 ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
91
95 QString genericValidationError(Context *c,
96 const QVariant &errorData = QVariant()) const override;
97
98private:
99 Q_DECLARE_PRIVATE(ValidatorIp) // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
100 Q_DISABLE_COPY(ValidatorIp)
101};
102
103} // namespace Cutelyst
104
105Q_DECLARE_OPERATORS_FOR_FLAGS(Cutelyst::ValidatorIp::Constraints)
106
107#endif // CUTELYSTVALIDATORIP_H
The Cutelyst Context.
Definition context.h:42
Checks if the field value is a valid IP address.
Definition validatorip.h:37
Constraint
Acceptable address ranges.
Definition validatorip.h:42
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.