cutelyst 3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
validatordigitsbetween.h
1/*
2 * SPDX-FileCopyrightText: (C) 2017-2022 Matthias Fehring <mf@huessenbergnetz.de>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef CUTELYSTVALIDATORDIGITSBETWEEN_H
6#define CUTELYSTVALIDATORDIGITSBETWEEN_H
7
8#include "validatorrule.h"
9
10#include <Cutelyst/cutelyst_global.h>
11
12namespace Cutelyst {
13
14class ValidatorDigitsBetweenPrivate;
15
37class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorDigitsBetween : public ValidatorRule
38{
39public:
53 const QVariant &min,
54 const QVariant &max,
55 const ValidatorMessages &messages = ValidatorMessages(),
56 const QString &defValKey = QString());
57
61 ~ValidatorDigitsBetween() override;
62
71 static bool validate(const QString &value, int min, int max);
72
73protected:
80 ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
81
89 const QVariant &errorData = QVariant()) const override;
90
91private:
92 Q_DECLARE_PRIVATE(ValidatorDigitsBetween)
93 Q_DISABLE_COPY(ValidatorDigitsBetween)
94};
95
96} // namespace Cutelyst
97
98#endif // CUTELYSTVALIDATORDIGITSBETWEEN_H
The Cutelyst Context.
Definition context.h:39
ValidatorDigitsBetween(const QString &field, const QVariant &min, const QVariant &max, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString())
Constructs a new digits between validator.
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
Returns a generic error if validation failed.
QString field() const
Returns the name of the field to validate.
ValidatorRule(const QString &field, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString())
Constructs a new ValidatorRule with the given parameters.
QString value(const ParamsMultiMap &params) const
Returns the value of the field from the input params.
static bool validate(const QString &value, int min, int max)
Returns true if value only contains digits and has a length between min and max.
The Cutelyst namespace holds all public Cutelyst API.
Definition Mainpage.dox:8
QMultiMap< QString, QString > ParamsMultiMap
Stores custom error messages and the input field label.
Contains the result of a single input parameter validation.