cutelyst  3.9.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
validator.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2017-2022 Matthias Fehring <mf@huessenbergnetz.de>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef CUTELYSTVALIDATOR_H
6 #define CUTELYSTVALIDATOR_H
7 
8 #include "validatorresult.h"
9 
10 #include <Cutelyst/ParamsMultiMap>
11 #include <Cutelyst/cutelyst_global.h>
12 
13 #include <QScopedPointer>
14 
15 namespace Cutelyst {
16 
46 class ValidatorPrivate;
47 class Context;
48 class Application;
49 class ValidatorRule;
50 
282 class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT Validator
283 {
284 public:
289  NoSpecialBehavior = 0,
290  StopOnFirstError =
291  1,
292  FillStashOnError = 2,
293  NoTrimming = 4,
295  BodyParamsOnly =
296  8,
298  QueryParamsOnly =
299  16
301  };
302  Q_DECLARE_FLAGS(ValidatorFlags, ValidatorFlag)
303 
304 
307  explicit Validator(QLatin1String translationContext = QLatin1String());
308 
309 #ifdef Q_COMPILER_INITIALIZER_LISTS
310 
317  explicit Validator(std::initializer_list<ValidatorRule *> validators,
318  QLatin1String translationContext = QLatin1String());
319 #endif
320 
324  ~Validator();
325 
332  void clear();
333 
345  ValidatorResult validate(Context *c, ValidatorFlags flags = NoSpecialBehavior) const;
346 
357  ValidatorResult validate(Context *c,
358  const ParamsMultiMap &parameters,
359  ValidatorFlags flags = NoSpecialBehavior) const;
360 
367  void addValidator(ValidatorRule *v);
368 
372  static void loadTranslations(Application *app);
373 
374 protected:
376 
377 private:
378  Q_DECLARE_PRIVATE(Validator)
379  Q_DISABLE_COPY(Validator)
380 };
381 
382 } // namespace Cutelyst
383 
384 Q_DECLARE_OPERATORS_FOR_FLAGS(Cutelyst::Validator::ValidatorFlags)
385 
386 #endif // CUTELYSTVALIDATOR_H
The Cutelyst Context.
Definition: context.h:38
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
ValidatorFlag
Flags that change the behavior of the Validator.
Definition: validator.h:288
Base class for all validator rules.
Validation processor for input data
Definition: validator.h:282
The Cutelyst Application.
Definition: application.h:42
Provides information about performed validations.