File: ValidationType.hpp

package info (click to toggle)
reflect-cpp 0.18.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 12,524 kB
  • sloc: cpp: 44,484; python: 131; makefile: 30; sh: 3
file content (69 lines) | stat: -rw-r--r-- 1,274 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef RFL_PARSING_SCHEMA_VALIDATIONTYPE_HPP_
#define RFL_PARSING_SCHEMA_VALIDATIONTYPE_HPP_

#include <cstddef>
#include <map>
#include <string>
#include <vector>

#include "../../Ref.hpp"
#include "../../Variant.hpp"

namespace rfl::parsing::schema {

struct ValidationType {
  struct AllOf {
    std::vector<ValidationType> types_;
  };

  struct AnyOf {
    std::vector<ValidationType> types_;
  };

  struct EqualTo {
    rfl::Variant<double, int> value_;
  };

  struct ExclusiveMaximum {
    rfl::Variant<double, int> value_;
  };

  struct ExclusiveMinimum {
    rfl::Variant<double, int> value_;
  };

  struct Maximum {
    rfl::Variant<double, int> value_;
  };

  struct Minimum {
    rfl::Variant<double, int> value_;
  };

  struct NotEqualTo {
    rfl::Variant<double, int> value_;
  };

  struct OneOf {
    std::vector<ValidationType> types_;
  };

  struct Regex {
    std::string pattern_;
  };

  struct Size {
    Ref<ValidationType> size_limit_;
  };

  using VariantType =
      rfl::Variant<AllOf, AnyOf, EqualTo, ExclusiveMaximum, ExclusiveMinimum,
                   Maximum, Minimum, OneOf, NotEqualTo, Regex, Size>;

  /// A type can be determined to be any of the above.
  VariantType variant_;
};

}  // namespace rfl::parsing::schema

#endif