cutelyst  5.0.1
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 
11 namespace Cutelyst {
12 
13 class ValidatorCharNotAllowedPrivate;
14 
38 class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorCharNotAllowed : public ValidatorRule
39 {
40 public:
50  ValidatorCharNotAllowed(const QString &field,
51  const QString &forbiddenChars,
52  const ValidatorMessages &messages = ValidatorMessages(),
53  const QString &defValKey = {});
54 
58  ~ValidatorCharNotAllowed() override;
59 
68  static std::optional<QChar> validate(const QString &value, const QString &forbiddenChars);
69 
70 protected:
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 
102 private:
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
Stores custom error messages and the input field label.
The Cutelyst Context.
Definition: context.h:42
The Cutelyst namespace holds all public Cutelyst API.
Base class for all validator rules.
Validates an input field for not allowed characters.
std::function< void(ValidatorReturnType &&result)> ValidatorRtFn
Void callback function for validator rules that processes the ValidatorReturnType.
Definition: validatorrule.h:82
Contains the result of a single input parameter validation.
Definition: validatorrule.h:52