cutelyst  4.3.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 #include <Cutelyst/cutelyst_global.h>
12 
13 namespace Cutelyst {
14 
15 class ValidatorCharNotAllowedPrivate;
16 
40 class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorCharNotAllowed : public ValidatorRule
41 {
42 public:
52  ValidatorCharNotAllowed(const QString &field,
53  const QString &forbiddenChars,
54  const ValidatorMessages &messages = ValidatorMessages(),
55  const QString &defValKey = QString());
56 
60  ~ValidatorCharNotAllowed() override;
61 
71  static bool
72  validate(const QString &value, const QString &forbiddenChars, QChar *foundChar = nullptr);
73 
74 protected:
81  ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
82 
86  QString genericValidationError(Context *c,
87  const QVariant &errorData = QVariant()) const override;
88 
92  QString genericValidationDataError(Context *c,
93  const QVariant &errorData = QVariant()) const override;
94 
95 private:
96  // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
97  Q_DECLARE_PRIVATE(ValidatorCharNotAllowed)
98  Q_DISABLE_COPY(ValidatorCharNotAllowed)
99 };
100 
101 } // namespace Cutelyst
102 
103 #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