cutelyst 4.3.0
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-2023 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
13namespace Cutelyst {
14
45class ValidatorPrivate;
46class Context;
47class Application;
48class ValidatorRule;
49
273class CUTELYST_PLUGIN_UTILS_VALIDATOR_EXPORT Validator
274{
275public:
280 NoSpecialBehavior = 0,
281 StopOnFirstError =
282 1,
283 FillStashOnError = 2,
284 NoTrimming = 4,
286 BodyParamsOnly =
287 8,
289 QueryParamsOnly =
290 16
292 };
293 Q_DECLARE_FLAGS(ValidatorFlags, ValidatorFlag)
294
295
301 explicit Validator(const char *translationContext = nullptr);
302
312 explicit Validator(std::initializer_list<ValidatorRule *> validators,
313 const char *translationContext = nullptr);
314
319
324 void clear();
325
337 ValidatorResult validate(Context *c, ValidatorFlags flags = NoSpecialBehavior) const;
338
349 ValidatorResult validate(Context *c,
350 const ParamsMultiMap &parameters,
351 ValidatorFlags flags = NoSpecialBehavior) const;
352
357 void addValidator(ValidatorRule *v);
358
365 static void loadTranslations(Application *app);
366
367private:
368 const std::unique_ptr<ValidatorPrivate> d_ptr;
369
370 Q_DECLARE_PRIVATE(Validator) // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
371 Q_DISABLE_COPY(Validator)
372};
373
374} // namespace Cutelyst
375
376Q_DECLARE_OPERATORS_FOR_FLAGS(Cutelyst::Validator::ValidatorFlags)
377
378#endif // CUTELYSTVALIDATOR_H
The Cutelyst application.
Definition application.h:66
The Cutelyst Context.
Definition context.h:42
Provides information about performed validations.
Base class for all validator rules.
Validation processor for input data.
Definition validator.h:274
The Cutelyst namespace holds all public Cutelyst API.