diff --git a/src/jsonschema/default_compiler_draft4.h b/src/jsonschema/default_compiler_draft4.h index 66bac162b..828d92381 100644 --- a/src/jsonschema/default_compiler_draft4.h +++ b/src/jsonschema/default_compiler_draft4.h @@ -548,7 +548,7 @@ auto compiler_draft4_validation_uniqueitems( auto compiler_draft4_validation_maxlength(const SchemaCompilerContext &context) -> SchemaCompilerTemplate { - assert(context.value.is_integer()); + assert(context.value.is_integer() || context.value.is_integer_real()); assert(context.value.is_positive()); // TODO: As an optimization, if `minLength` is set to the same number, do @@ -556,14 +556,14 @@ auto compiler_draft4_validation_maxlength(const SchemaCompilerContext &context) return {make( context, SchemaCompilerValueUnsignedInteger{ - static_cast(context.value.to_integer()) + 1}, + static_cast(context.value.as_integer()) + 1}, type_condition(context, JSON::Type::String), SchemaCompilerTargetType::Instance)}; } auto compiler_draft4_validation_minlength(const SchemaCompilerContext &context) -> SchemaCompilerTemplate { - assert(context.value.is_integer()); + assert(context.value.is_integer() || context.value.is_integer_real()); assert(context.value.is_positive()); // TODO: As an optimization, if `maxLength` is set to the same number, do @@ -571,14 +571,14 @@ auto compiler_draft4_validation_minlength(const SchemaCompilerContext &context) return {make( context, SchemaCompilerValueUnsignedInteger{ - static_cast(context.value.to_integer()) - 1}, + static_cast(context.value.as_integer()) - 1}, type_condition(context, JSON::Type::String), SchemaCompilerTargetType::Instance)}; } auto compiler_draft4_validation_maxitems(const SchemaCompilerContext &context) -> SchemaCompilerTemplate { - assert(context.value.is_integer()); + assert(context.value.is_integer() || context.value.is_integer_real()); assert(context.value.is_positive()); // TODO: As an optimization, if `minItems` is set to the same number, do @@ -586,14 +586,14 @@ auto compiler_draft4_validation_maxitems(const SchemaCompilerContext &context) return {make( context, SchemaCompilerValueUnsignedInteger{ - static_cast(context.value.to_integer()) + 1}, + static_cast(context.value.as_integer()) + 1}, type_condition(context, JSON::Type::Array), SchemaCompilerTargetType::Instance)}; } auto compiler_draft4_validation_minitems(const SchemaCompilerContext &context) -> SchemaCompilerTemplate { - assert(context.value.is_integer()); + assert(context.value.is_integer() || context.value.is_integer_real()); assert(context.value.is_positive()); // TODO: As an optimization, if `maxItems` is set to the same number, do @@ -601,14 +601,14 @@ auto compiler_draft4_validation_minitems(const SchemaCompilerContext &context) return {make( context, SchemaCompilerValueUnsignedInteger{ - static_cast(context.value.to_integer()) - 1}, + static_cast(context.value.as_integer()) - 1}, type_condition(context, JSON::Type::Array), SchemaCompilerTargetType::Instance)}; } auto compiler_draft4_validation_maxproperties( const SchemaCompilerContext &context) -> SchemaCompilerTemplate { - assert(context.value.is_integer()); + assert(context.value.is_integer() || context.value.is_integer_real()); assert(context.value.is_positive()); // TODO: As an optimization, if `minProperties` is set to the same number, do @@ -616,14 +616,14 @@ auto compiler_draft4_validation_maxproperties( return {make( context, SchemaCompilerValueUnsignedInteger{ - static_cast(context.value.to_integer()) + 1}, + static_cast(context.value.as_integer()) + 1}, type_condition(context, JSON::Type::Object), SchemaCompilerTargetType::Instance)}; } auto compiler_draft4_validation_minproperties( const SchemaCompilerContext &context) -> SchemaCompilerTemplate { - assert(context.value.is_integer()); + assert(context.value.is_integer() || context.value.is_integer_real()); assert(context.value.is_positive()); // TODO: As an optimization, if `maxProperties` is set to the same number, do @@ -631,7 +631,7 @@ auto compiler_draft4_validation_minproperties( return {make( context, SchemaCompilerValueUnsignedInteger{ - static_cast(context.value.to_integer()) - 1}, + static_cast(context.value.as_integer()) - 1}, type_condition(context, JSON::Type::Object), SchemaCompilerTargetType::Instance)}; }