MantisBase v0.3.4
Loading...
Searching...
No Matches
validators.h
Go to the documentation of this file.
1
9#ifndef MANTISBASE_VALIDATORS_H
10#define MANTISBASE_VALIDATORS_H
11
12#include <string>
13
16#include "nlohmann/json.hpp"
17
18
19namespace mb {
20 using json = nlohmann::json;
21
22 class Validators {
23 public:
24 static std::optional<json> findPreset(const std::string &key);
25
26 static std::optional<std::string> validatePreset(const std::string &key, const std::string &value);
27
28 static std::optional<std::string> minimumConstraintCheck(const json &field, const json &body);
29
30 static std::optional<std::string> maximumConstraintCheck(const json &field, const json &body);
31
32 static std::optional<std::string> requiredConstraintCheck(const json &field, const json &body);
33
34 static std::optional<std::string> validatorConstraintCheck(const json &field, const json &body);
35
36 static std::optional<std::string> foreignKeyConstraintCheck(const json &field, const json &body);
37
38 static std::optional<std::string> viewTypeSQLCheck(const json &body);
39
40 static std::optional<std::string> validateTableSchema(const json &entity_schema);
41
42 static std::optional<std::string> validateRequestBody(const json &schema, const json &body);
43
44 static std::optional<std::string> validateRequestBody(const Entity &schema, const json &body);
45
46 static std::optional<std::string> validateUpdateRequestBody(const json &schema, const json &body);
47
48 static std::optional<std::string> validateUpdateRequestBody(const Entity &schema, const json &body);
49
50 private:
51 static std::unordered_map<std::string, json> presets;
52 };
53} // mb
54
55#endif //MANTISBASE_VALIDATORS_H
Represents a database table/entity with schema and CRUD operations.
Definition entity.h:39
Definition validators.h:22
static std::optional< std::string > validateUpdateRequestBody(const json &schema, const json &body)
Definition validators.cpp:370
static std::optional< std::string > maximumConstraintCheck(const json &field, const json &body)
Definition validators.cpp:100
static std::optional< std::string > viewTypeSQLCheck(const json &body)
Definition validators.cpp:227
static std::optional< std::string > validateTableSchema(const json &entity_schema)
Definition validators.cpp:242
static std::optional< std::string > foreignKeyConstraintCheck(const json &field, const json &body)
Definition validators.cpp:175
static std::optional< json > findPreset(const std::string &key)
Definition validators.cpp:37
static std::optional< std::string > validateRequestBody(const json &schema, const json &body)
Definition validators.cpp:288
static std::optional< std::string > validatePreset(const std::string &key, const std::string &value)
Definition validators.cpp:49
static std::optional< std::string > minimumConstraintCheck(const json &field, const json &body)
Definition validators.cpp:70
static std::optional< std::string > validatorConstraintCheck(const json &field, const json &body)
Definition validators.cpp:151
static std::optional< std::string > requiredConstraintCheck(const json &field, const json &body)
Definition validators.cpp:130
Entity class for database table operations and CRUD functionality.
router.h
Definition auth.h:15
nlohmann::json json
Shorten JSON namespace.
Definition context_store.h:18