cutelyst 3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
validatorcharnotallowed.h
1/*
2 * SPDX-FileCopyrightText: (C) 2019-2022 Matthias Fehring <mf@huessenbergnetz.de>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef CUTELYSTVALIDATORCHARNOTALLOWED_H
7#define CUTELYSTVALIDATORCHARNOTALLOWED_H
8
9#include "validatorrule.h"
10
11#include <Cutelyst/cutelyst_global.h>
12
13namespace Cutelyst {
14
15class ValidatorCharNotAllowedPrivate;
16
37class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorCharNotAllowed : public ValidatorRule
38{
39public:
50 const QString &forbiddenChars,
51 const ValidatorMessages &messages = ValidatorMessages(),
52 const QString &defValKey = QString());
53
57 ~ValidatorCharNotAllowed() override;
58
67 static bool
68 validate(const QString &value, const QString &forbiddenChars, QChar *foundChar = nullptr);
69
70protected:
77 ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
78
83 const QVariant &errorData = QVariant()) const override;
84
89 const QVariant &errorData = QVariant()) const override;
90
91private:
92 Q_DECLARE_PRIVATE(ValidatorCharNotAllowed)
93 Q_DISABLE_COPY(ValidatorCharNotAllowed)
94};
95
96} // namespace Cutelyst
97
98#endif // CUTELYSTVALIDATORCHARNOTALLOWED_H
The Cutelyst Context.
Definition context.h:39
QString genericValidationDataError(Context *c, const QVariant &errorData=QVariant()) const override
Returns a generic error if the list of forbidden characters is empty.
QString genericValidationError(Context *c, const QVariant &errorData=QVariant()) const override
Returns a generic error message if validation failed.
ValidatorCharNotAllowed(const QString &field, const QString &forbiddenChars, const ValidatorMessages &messages=ValidatorMessages(), const QString &defValKey=QString())
Constructs a new char not allowed validator.
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, const QString &forbiddenChars, QChar *foundChar=nullptr)
Returns true if value does not contain any of the characters in forbiddenChars.
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.