Sha256: 7590e08b38249409f3931d7d0419d1b6c82526392a9990e008b2d8c16a519f50
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
module ObjectValidation module AdditionalPropertiesTests def test_additional_properties_false schema = { 'properties' => { 'a' => { 'type' => 'integer' } }, 'additionalProperties' => false } assert_valid schema, {'a' => 1} refute_valid schema, {'a' => 1, 'b' => 2} end def test_additional_properties_schema schema = { 'properties' => { 'a' => { 'type' => 'integer' } }, 'additionalProperties' => { 'type' => 'string' } } assert_valid schema, {'a' => 1} assert_valid schema, {'a' => 1, 'b' => 'hi'} refute_valid schema, {'a' => 1, 'b' => 2} end end module PatternPropertiesTests def test_pattern_properties schema = { 'patternProperties' => { "\\d+ taco" => { 'type' => 'integer' } } } assert_valid schema, {'1 taco' => 1, '20 taco' => 20} assert_valid schema, {'foo' => true, '1 taco' => 1} refute_valid schema, {'1 taco' => 'yum'} end def test_pattern_properties_additional_properties_false schema = { 'patternProperties' => { "\\d+ taco" => { 'type' => 'integer' } }, 'additionalProperties' => false } assert_valid schema, {'1 taco' => 1} refute_valid schema, {'1 taco' => 'yum'} refute_valid schema, {'1 taco' => 1, 'foo' => true} end def test_pattern_properties_additional_properties_schema schema = { 'patternProperties' => { "\\d+ taco" => { 'type' => 'integer' } }, 'additionalProperties' => { 'type' => 'string' } } assert_valid schema, {'1 taco' => 1} assert_valid schema, {'1 taco' => 1, 'foo' => 'bar'} refute_valid schema, {'1 taco' => 1, 'foo' => 2} end end end
Version data entries
2 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mountapi-0.11.1 | vendor/bundle/ruby/2.7.0/bundler/gems/json-schema-2253a5ee6679/test/support/object_validation.rb |
mountapi-0.11.1 | vendor/json-schema/test/support/object_validation.rb |