Cutelyst  3.5.0
validatorrequiredifstash.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2018-2022 Matthias Fehring <mf@huessenbergnetz.de>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef CUTELYSTVALIDATORREQUIREDIFSTASH_H
6 #define CUTELYSTVALIDATORREQUIREDIFSTASH_H
7 
8 #include "validatorrule.h"
9 #include <Cutelyst/cutelyst_global.h>
10 
11 namespace Cutelyst {
12 
13 class ValidatorRequiredIfStashPrivate;
14 
33 class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT ValidatorRequiredIfStash : public ValidatorRule
34 {
35 public:
43  ValidatorRequiredIfStash(const QString &field, const QString &stashKey, const QVariantList &stashValues, const ValidatorMessages &messages = ValidatorMessages());
44 
48  ~ValidatorRequiredIfStash() 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(ValidatorRequiredIfStash)
66  Q_DISABLE_COPY(ValidatorRequiredIfStash)
67 };
68 
69 }
70 
71 #endif // CUTELYSTVALIDATORREQUIREDIFSTASH_H
Stores custom error messages and the input field label.
The field under validation must be present and not empty if the content of a stash key is equal to on...
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