-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathinteger_upper_bound_multiplier.h
More file actions
38 lines (36 loc) · 1.79 KB
/
Copy pathinteger_upper_bound_multiplier.h
File metadata and controls
38 lines (36 loc) · 1.79 KB
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
class IntegerUpperBoundMultiplier final
: public sourcemeta::blaze::SchemaTransformRule {
public:
using mutates = std::true_type;
using reframe_after_transform = std::true_type;
IntegerUpperBoundMultiplier()
: sourcemeta::blaze::SchemaTransformRule{"integer_upper_bound_multiplier",
""} {};
[[nodiscard]] auto
condition(const sourcemeta::core::JSON &schema,
const sourcemeta::core::JSON &,
const sourcemeta::blaze::Vocabularies &vocabularies,
const sourcemeta::blaze::SchemaFrame &,
const sourcemeta::blaze::SchemaFrame::Location &location,
const sourcemeta::blaze::SchemaWalker &,
const sourcemeta::blaze::SchemaResolver &, const bool) const
-> sourcemeta::blaze::SchemaTransformRule::Result override {
return location.dialect == "https://json-schema.org/draft/2020-12/schema" &&
vocabularies.contains(sourcemeta::blaze::Vocabularies::Known::
JSON_Schema_2020_12_Validation) &&
schema.is_object() && schema.defines("type") &&
schema.at("type").to_string() == "integer" &&
!schema.defines("minimum") && schema.defines("maximum") &&
schema.defines("multipleOf") && schema.at("multipleOf").is_integer();
}
auto transform(sourcemeta::core::JSON &schema,
const sourcemeta::blaze::SchemaTransformRule::Result &) const
-> void override {
auto maximum = schema.at("maximum");
auto multiplier = schema.at("multipleOf");
auto options = sourcemeta::core::JSON::make_object();
options.assign("maximum", std::move(maximum));
options.assign("multiplier", std::move(multiplier));
make_encoding(schema, "ROOF_MULTIPLE_MIRROR_ENUM_VARINT", options);
}
};