MantisBase v0.4.9
Loading...
Searching...
No Matches
validators.h
Go to the documentation of this file.
1
8
9#ifndef MANTISBASE_VALIDATORS_H
10#define MANTISBASE_VALIDATORS_H
11
12#include <string>
13
16#include "nlohmann/json.hpp"
17#include "../types.h"
18
19namespace mb {
20 using json = nlohmann::json;
21
28 public:
30 static std::optional<json> findPreset(const std::string &key);
31
33 static std::optional<std::string> validatePreset(const std::string &key, const std::string &value);
34
36 static std::optional<std::string> minimumConstraintCheck(const json &field, const json &body);
37
39 static std::optional<std::string> maximumConstraintCheck(const json &field, const json &body);
40
42 static std::optional<std::string> intPrecisionValueCheck(const json &field, const json &body);
43
45 static std::optional<std::string> requiredConstraintCheck(const json &field, const json &body);
46
48 static std::optional<std::string> validatorConstraintCheck(const json &field, const json &body);
49
56 static std::optional<std::string> foreignKeyConstraintCheck(const MantisBase& app, const json &field, const json &body);
57
59 static std::optional<std::string> viewTypeSQLCheck(const json &body);
60
62 static std::optional<std::string> validateTableSchema(const json &entity_schema);
63
65 static std::optional<std::string> validateRequestBody(const MbEntity &entity, const json &body);
66
68 static std::optional<std::string> validateUpdateRequestBody(const MbEntity &entity, const json &body);
69
70 private:
71 static std::unordered_map<std::string, json> presets;
72 };
73} // mb
74
75#endif //MANTISBASE_VALIDATORS_H
MantisBase entry point.
Definition mantisbase.h:54
Represents a database table/entity with schema and CRUD operations.
Definition entity.h:55
Static validators for schema definitions and CRUD request bodies.
Definition validators.h:27
static std::optional< json > findPreset(const std::string &key)
Definition validators.cpp:44
static std::optional< std::string > validateTableSchema(const json &entity_schema)
Definition validators.cpp:319
static std::optional< std::string > intPrecisionValueCheck(const json &field, const json &body)
Definition validators.cpp:76
static std::optional< std::string > maximumConstraintCheck(const json &field, const json &body)
Definition validators.cpp:141
static std::optional< std::string > validatePreset(const std::string &key, const std::string &value)
Definition validators.cpp:56
static std::optional< std::string > validatorConstraintCheck(const json &field, const json &body)
Definition validators.cpp:212
static std::optional< std::string > validateUpdateRequestBody(const MbEntity &entity, const json &body)
Definition validators.cpp:416
static std::optional< std::string > requiredConstraintCheck(const json &field, const json &body)
Definition validators.cpp:193
static std::optional< std::string > validateRequestBody(const MbEntity &entity, const json &body)
Definition validators.cpp:379
static std::optional< std::string > foreignKeyConstraintCheck(const MantisBase &app, const json &field, const json &body)
Validate a foreign-key field against a referenced entity record.
Definition validators.cpp:235
static std::optional< std::string > minimumConstraintCheck(const json &field, const json &body)
Definition validators.cpp:89
static std::optional< std::string > viewTypeSQLCheck(const json &body)
Definition validators.cpp:284
MbDatabase connection, pooling, and system table migration.
MbEntity class for database table operations and CRUD functionality.
#define MANTISBASE_API
Definition export.h:31
Definition api_keys.h:35
nlohmann::json json
Shorten JSON namespace.
Definition api_keys.h:36
Core type aliases, handler signatures, and the MbAppMixin DI mixin.