cutelyst  5.0.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
validatorsize.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2017-2025 Matthias Fehring <mf@huessenbergnetz.de>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef CUTELYSTVALIDATORSIZE_H
6 #define CUTELYSTVALIDATORSIZE_H
7 
8 #include "validatorrule.h"
9 
10 namespace Cutelyst {
11 
12 class ValidatorSizePrivate;
13 
49 class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorSize : public ValidatorRule
50 {
51 public:
63  ValidatorSize(const QString &field,
64  QMetaType::Type type,
65  const QVariant &size,
66  const ValidatorMessages &messages = ValidatorMessages(),
67  const QString &defValKey = {});
68 
72  ~ValidatorSize() override;
73 
74 protected:
81  ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
82 
92  void validateCb(Context *c, const ParamsMultiMap &params, ValidatorRtFn cb) const override;
93 
97  QString genericValidationError(Context *c,
98  const QVariant &errorData = QVariant()) const override;
99 
103  QString genericValidationDataError(Context *c, const QVariant &errorData) const override;
104 
108  QString genericParsingError(Context *c, const QVariant &errorData) const override;
109 
110 private:
111  Q_DECLARE_PRIVATE(ValidatorSize) // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
112  Q_DISABLE_COPY(ValidatorSize)
113 };
114 
115 } // namespace Cutelyst
116 
117 #endif // CUTELYSTVALIDATORSIZE_H
Stores custom error messages and the input field label.
The field under validation must have a size matching the given value.
Definition: validatorsize.h:49
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
Contains the result of a single input parameter validation.
Definition: validatorrule.h:52