Sha256: 7e5114c728cdce92a2cec7a63446dc4d80a8ec7f767a4a97a09479aa5fcd91cd
Contents?: true
Size: 937 Bytes
Versions: 2
Compression:
Stored size: 937 Bytes
Contents
class OpenAPIParser::SchemaValidator module PropertiesNumber # check minProperties and manProperties value by schema # @param [Object] value # @param [OpenAPIParser::Schemas::Schema] schema def check_properties_number(value, schema) include_properties_num = schema.minProperties || schema.maxProperties return [value, nil] unless include_properties_num validate(value, schema) [value, nil] rescue OpenAPIParser::OpenAPIError => e return [nil, e] end private def validate(value, schema) reference = schema.object_reference if schema.minProperties && (value.size < schema.minProperties) raise OpenAPIParser::LessThanMinProperties.new(value, reference) end if schema.maxProperties && (value.size > schema.maxProperties) raise OpenAPIParser::MoreThanMaxProperties.new(value, reference) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openapi_parser-2.2.3 | lib/openapi_parser/schema_validator/properties_number.rb |
openapi_parser-2.2.2 | lib/openapi_parser/schema_validator/properties_number.rb |