cutelyst 5.0.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
validatorcharnotallowed.h
1/*
2 * SPDX-FileCopyrightText: (C) 2019-2025 Matthias Fehring <mf@huessenbergnetz.de>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef CUTELYSTVALIDATORCHARNOTALLOWED_H
7#define CUTELYSTVALIDATORCHARNOTALLOWED_H
8
9#include "validatorrule.h"
10
11namespace Cutelyst {
12
13class ValidatorCharNotAllowedPrivate;
14
38class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorCharNotAllowed : public ValidatorRule
39{
40public:
50 ValidatorCharNotAllowed(const QString &field,
51 const QString &forbiddenChars,
52 const ValidatorMessages &messages = ValidatorMessages(),
53 const QString &defValKey = {});
54
59
68 static std::optional<QChar> validate(const QString &value, const QString &forbiddenChars);
69
70protected:
77 ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
78
88 void validateCb(Context *c, const ParamsMultiMap &params, ValidatorRtFn cb) const override;
89
93 QString genericValidationError(Context *c,
94 const QVariant &errorData = QVariant()) const override;
95
99 QString genericValidationDataError(Context *c,
100 const QVariant &errorData = QVariant()) const override;
101
102private:
103 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
104 Q_DECLARE_PRIVATE(ValidatorCharNotAllowed)
105 Q_DISABLE_COPY(ValidatorCharNotAllowed)
106};
107
108} // namespace Cutelyst
109
110#endif // CUTELYSTVALIDATORCHARNOTALLOWED_H
The Cutelyst Context.
Definition context.h:42
Validates an input field for not allowed characters.
Base class for all validator rules.
std::function< void(ValidatorReturnType &&result)> ValidatorRtFn
Void callback function for validator rules that processes the ValidatorReturnType.
QMultiMap< QString, QString > ParamsMultiMap
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.