cutelyst  4.3.0
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-2023 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 #include <Cutelyst/cutelyst_global.h>
11 
12 namespace Cutelyst {
13 
14 class ValidatorSizePrivate;
15 
51 class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorSize : public ValidatorRule
52 {
53 public:
65  ValidatorSize(const QString &field,
66  QMetaType::Type type,
67  const QVariant &size,
68  const ValidatorMessages &messages = ValidatorMessages(),
69  const QString &defValKey = QString());
70 
74  ~ValidatorSize() override;
75 
76 protected:
83  ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
84 
88  QString genericValidationError(Context *c,
89  const QVariant &errorData = QVariant()) const override;
90 
94  QString genericValidationDataError(Context *c, const QVariant &errorData) const override;
95 
99  QString genericParsingError(Context *c, const QVariant &errorData) const override;
100 
101 private:
102  Q_DECLARE_PRIVATE(ValidatorSize) // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
103  Q_DISABLE_COPY(ValidatorSize)
104 };
105 
106 } // namespace Cutelyst
107 
108 #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:51
The Cutelyst Context.
Definition: context.h:42
The Cutelyst namespace holds all public Cutelyst API.
Base class for all validator rules.
Contains the result of a single input parameter validation.
Definition: validatorrule.h:49