cutelyst  3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
validatordigits.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2017-2022 Matthias Fehring <mf@huessenbergnetz.de>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef CUTELYSTVALIDATORDIGITS_H
6 #define CUTELYSTVALIDATORDIGITS_H
7 
8 #include "validatorrule.h"
9 
10 #include <Cutelyst/cutelyst_global.h>
11 
12 namespace Cutelyst {
13 
14 class ValidatorDigitsPrivate;
15 
37 class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorDigits : public ValidatorRule
38 {
39 public:
50  ValidatorDigits(const QString &field,
51  const QVariant &length = -1,
52  const ValidatorMessages &messages = ValidatorMessages(),
53  const QString &defValKey = QString());
54 
58  ~ValidatorDigits() override;
59 
71  static bool validate(const QString &value, int length = -1);
72 
73 protected:
80  ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
81 
88  QString genericValidationError(Context *c,
89  const QVariant &errorData = QVariant()) const override;
90 
91 private:
92  Q_DECLARE_PRIVATE(ValidatorDigits)
93  Q_DISABLE_COPY(ValidatorDigits)
94 };
95 
96 } // namespace Cutelyst
97 
98 #endif // CUTELYSTVALIDATORDIGITS_H
Checks for digits only with optional length check.
Stores custom error messages and the input field label.
The Cutelyst Context.
Definition: context.h:38
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
Base class for all validator rules.
Contains the result of a single input parameter validation.
Definition: validatorrule.h:49