cutelyst  5.0.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
validatormax.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2017-2025 Matthias Fehring <mf@huessenbergnetz.de>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef CUTELYSTVALIDATORMAX_H
6 #define CUTELYSTVALIDATORMAX_H
7 
8 #include "validatorrule.h"
9 
10 namespace Cutelyst {
11 
12 class ValidatorMaxPrivate;
13 
46 class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorMax : public ValidatorRule
47 {
48 public:
60  ValidatorMax(const QString &field,
61  QMetaType::Type type,
62  const QVariant &max,
63  const ValidatorMessages &messages = ValidatorMessages(),
64  const QString &defValKey = {});
65 
69  ~ValidatorMax() override;
70 
71 protected:
78  ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
79 
89  void validateCb(Context *c, const ParamsMultiMap &params, ValidatorRtFn cb) const override;
90 
94  QString genericValidationError(Context *c,
95  const QVariant &errorData = QVariant()) const override;
96 
100  QString genericValidationDataError(Context *c, const QVariant &errorData) const override;
101 
105  QString genericParsingError(Context *c, const QVariant &errorData) const override;
106 
107 private:
108  Q_DECLARE_PRIVATE(ValidatorMax) // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
109  Q_DISABLE_COPY(ValidatorMax)
110 };
111 
112 } // namespace Cutelyst
113 
114 #endif // CUTELYSTVALIDATORMAX_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.
std::function< void(ValidatorReturnType &&result)> ValidatorRtFn
Void callback function for validator rules that processes the ValidatorReturnType.
Definition: validatorrule.h:82
Checks if a value is not bigger or longer than a maximum value.
Definition: validatormax.h:46
Contains the result of a single input parameter validation.
Definition: validatorrule.h:52