cutelyst  4.9.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-2023 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 = QString());
54 
58  ~ValidatorCharNotAllowed() override;
59 
69  static bool
70  validate(const QString &value, const QString &forbiddenChars, QChar *foundChar = nullptr);
71 
72 protected:
79  ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
80 
84  QString genericValidationError(Context *c,
85  const QVariant &errorData = QVariant()) const override;
86 
90  QString genericValidationDataError(Context *c,
91  const QVariant &errorData = QVariant()) const override;
92 
93 private:
94  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
95  Q_DECLARE_PRIVATE(ValidatorCharNotAllowed)
96  Q_DISABLE_COPY(ValidatorCharNotAllowed)
97 };
98 
99 } // namespace Cutelyst
100 
101 #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.
Contains the result of a single input parameter validation.
Definition: validatorrule.h:49