Cutelyst  3.5.0
validatorregularexpression.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2017-2022 Matthias Fehring <mf@huessenbergnetz.de>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef CUTELYSTVALIDATORREGEX_H
6 #define CUTELYSTVALIDATORREGEX_H
7 
8 #include <Cutelyst/cutelyst_global.h>
9 #include "validatorrule.h"
10 #include <QRegularExpression>
11 
12 namespace Cutelyst {
13 
14 class ValidatorRegularExpressionPrivate;
15 
33 class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorRegularExpression : public ValidatorRule
34 {
35 public:
43  ValidatorRegularExpression(const QString &field, const QRegularExpression &regex, const ValidatorMessages &messages = ValidatorMessages(), const QString &defValKey = QString());
44 
48  ~ValidatorRegularExpression() override;
49 
50 protected:
57  ValidatorReturnType validate(Context *c, const ParamsMultiMap &params) const override;
58 
62  QString genericValidationError(Context *c, const QVariant &errorData = QVariant()) const override;
63 
64 private:
65  Q_DECLARE_PRIVATE(ValidatorRegularExpression)
66  Q_DISABLE_COPY(ValidatorRegularExpression)
67 };
68 
69 }
70 
71 #endif //CUTELYSTVALIDATORREGEX_H
72 
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
The field under validation must match the given regular expression.