|
|
@@ -243,12 +243,14 @@ public:
|
|
|
// SECTION: String Constraints
|
|
|
|
|
|
static auto minLength(detail::ParserContext<A> const & context) {
|
|
|
- EXPECT(context.schema.type() == adapter::Type::Integer);
|
|
|
+ EXPECT(context.schema.type() == adapter::Type::Integer ||
|
|
|
+ context.schema.type() == adapter::Type::Number);
|
|
|
return std::make_unique<constraint::MinLengthConstraint>(context.schema.as_integer());
|
|
|
}
|
|
|
|
|
|
static auto maxLength(detail::ParserContext<A> const & context) {
|
|
|
- EXPECT(context.schema.type() == adapter::Type::Integer);
|
|
|
+ EXPECT(context.schema.type() == adapter::Type::Integer ||
|
|
|
+ context.schema.type() == adapter::Type::Number);
|
|
|
return std::make_unique<constraint::MaxLengthConstraint>(context.schema.as_integer());
|
|
|
}
|
|
|
|
|
|
@@ -355,12 +357,14 @@ public:
|
|
|
}
|
|
|
|
|
|
static auto minProperties(detail::ParserContext<A> const & context) {
|
|
|
- EXPECT(context.schema.type() == adapter::Type::Integer);
|
|
|
+ EXPECT(context.schema.type() == adapter::Type::Integer ||
|
|
|
+ context.schema.type() == adapter::Type::Number);
|
|
|
return std::make_unique<constraint::MinPropertiesConstraint>(context.schema.as_integer());
|
|
|
}
|
|
|
|
|
|
static auto maxProperties(detail::ParserContext<A> const & context) {
|
|
|
- EXPECT(context.schema.type() == adapter::Type::Integer);
|
|
|
+ EXPECT(context.schema.type() == adapter::Type::Integer ||
|
|
|
+ context.schema.type() == adapter::Type::Number);
|
|
|
return std::make_unique<constraint::MaxPropertiesConstraint>(context.schema.as_integer());
|
|
|
}
|
|
|
|
|
|
@@ -425,13 +429,13 @@ public:
|
|
|
std::map<std::string, schema::Node const *> schemas;
|
|
|
std::map<std::string, std::unordered_set<std::string>> required;
|
|
|
for (auto [prop, subschema] : context.schema.as_object()) {
|
|
|
- if (subschema.type() == adapter::Type::Object) {
|
|
|
- schemas.emplace(prop, context.child(subschema, prop).node());
|
|
|
- } else {
|
|
|
+ if (subschema.type() == adapter::Type::Array) {
|
|
|
for (auto key : subschema.as_array()) {
|
|
|
EXPECT(key.type() == adapter::Type::String);
|
|
|
required[prop].insert(key.as_string());
|
|
|
}
|
|
|
+ } else {
|
|
|
+ schemas.emplace(prop, context.child(subschema, prop).node());
|
|
|
}
|
|
|
}
|
|
|
|