-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
- Loading branch information
Showing
44 changed files
with
1,699 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class DropNonArrayKeywords_Draft0 final : public Rule { | ||
public: | ||
DropNonArrayKeywords_Draft0() | ||
: Rule{"drop_non_array_keywords_draft0", | ||
"Keywords that don't apply to arrays will never match if the " | ||
"instance is guaranteed to be an array"} {}; | ||
|
||
[[nodiscard]] auto | ||
condition(const sourcemeta::jsontoolkit::JSON &schema, const std::string &, | ||
const std::set<std::string> &vocabularies, | ||
const sourcemeta::jsontoolkit::Pointer &) const -> bool override { | ||
return vocabularies.contains("http://json-schema.org/draft-00/schema#") && | ||
schema.is_object() && schema.defines("type") && | ||
schema.at("type").is_string() && | ||
schema.at("type").to_string() == "array" && | ||
schema.defines_any(this->BLACKLIST.cbegin(), this->BLACKLIST.cend()); | ||
} | ||
|
||
auto transform(Transformer &transformer) const -> void override { | ||
transformer.erase_keys(this->BLACKLIST.cbegin(), this->BLACKLIST.cend()); | ||
} | ||
|
||
private: | ||
const std::set<std::string> BLACKLIST{ | ||
"maxDecimal", "maximum", "maximumCanEqual", "minimum", | ||
"minimumCanEqual", "maxLength", "minLength", "pattern", | ||
"requires", "optional", "properties", "additionalProperties", | ||
"contentEncoding", "format"}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class DropNonArrayKeywords_Draft1 final : public Rule { | ||
public: | ||
DropNonArrayKeywords_Draft1() | ||
: Rule{"drop_non_array_keywords_draft1", | ||
"Keywords that don't apply to arrays will never match if the " | ||
"instance is guaranteed to be an array"} {}; | ||
|
||
[[nodiscard]] auto | ||
condition(const sourcemeta::jsontoolkit::JSON &schema, const std::string &, | ||
const std::set<std::string> &vocabularies, | ||
const sourcemeta::jsontoolkit::Pointer &) const -> bool override { | ||
return vocabularies.contains("http://json-schema.org/draft-01/schema#") && | ||
schema.is_object() && schema.defines("type") && | ||
schema.at("type").is_string() && | ||
schema.at("type").to_string() == "array" && | ||
schema.defines_any(this->BLACKLIST.cbegin(), this->BLACKLIST.cend()); | ||
} | ||
|
||
auto transform(Transformer &transformer) const -> void override { | ||
transformer.erase_keys(this->BLACKLIST.cbegin(), this->BLACKLIST.cend()); | ||
} | ||
|
||
private: | ||
const std::set<std::string> BLACKLIST{ | ||
"maxDecimal", "maximum", "maximumCanEqual", "minimum", | ||
"minimumCanEqual", "maxLength", "minLength", "pattern", | ||
"requires", "optional", "properties", "additionalProperties", | ||
"contentEncoding", "format"}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class DropNonArrayKeywords_Draft2 final : public Rule { | ||
public: | ||
DropNonArrayKeywords_Draft2() | ||
: Rule{"drop_non_array_keywords_draft2", | ||
"Keywords that don't apply to arrays will never match if the " | ||
"instance is guaranteed to be an array"} {}; | ||
|
||
[[nodiscard]] auto | ||
condition(const sourcemeta::jsontoolkit::JSON &schema, const std::string &, | ||
const std::set<std::string> &vocabularies, | ||
const sourcemeta::jsontoolkit::Pointer &) const -> bool override { | ||
return vocabularies.contains("http://json-schema.org/draft-02/schema#") && | ||
schema.is_object() && schema.defines("type") && | ||
schema.at("type").is_string() && | ||
schema.at("type").to_string() == "array" && | ||
schema.defines_any(this->BLACKLIST.cbegin(), this->BLACKLIST.cend()); | ||
} | ||
|
||
auto transform(Transformer &transformer) const -> void override { | ||
transformer.erase_keys(this->BLACKLIST.cbegin(), this->BLACKLIST.cend()); | ||
} | ||
|
||
private: | ||
const std::set<std::string> BLACKLIST{ | ||
"properties", "optional", "additionalProperties", | ||
"requires", "minimum", "maximum", | ||
"minimumCanEqual", "maximumCanEqual", "pattern", | ||
"maxLength", "minLength", "format", | ||
"contentEncoding", "divisibleBy"}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class DropNonArrayKeywords_Draft3 final : public Rule { | ||
public: | ||
DropNonArrayKeywords_Draft3() | ||
: Rule{"drop_non_array_keywords_draft3", | ||
"Keywords that don't apply to arrays will never match if the " | ||
"instance is guaranteed to be an array"} {}; | ||
|
||
[[nodiscard]] auto | ||
condition(const sourcemeta::jsontoolkit::JSON &schema, const std::string &, | ||
const std::set<std::string> &vocabularies, | ||
const sourcemeta::jsontoolkit::Pointer &) const -> bool override { | ||
return vocabularies.contains("http://json-schema.org/draft-03/schema#") && | ||
schema.is_object() && schema.defines("type") && | ||
schema.at("type").is_string() && | ||
schema.at("type").to_string() == "array" && | ||
schema.defines_any(this->BLACKLIST.cbegin(), this->BLACKLIST.cend()); | ||
} | ||
|
||
auto transform(Transformer &transformer) const -> void override { | ||
transformer.erase_keys(this->BLACKLIST.cbegin(), this->BLACKLIST.cend()); | ||
} | ||
|
||
private: | ||
const std::set<std::string> BLACKLIST{ | ||
"properties", "patternProperties", "additionalProperties", | ||
"required", "dependencies", "minimum", | ||
"maximum", "exclusiveMinimum", "exclusiveMaximum", | ||
"pattern", "minLength", "maxLength", | ||
"format", "divisibleBy"}; | ||
}; |
Oops, something went wrong.