Sha256: aaa46999837bdec67550f2c328f5eca867efdc332a89519638f2f7ac629bb084
Contents?: true
Size: 1.78 KB
Versions: 2
Compression:
Stored size: 1.78 KB
Contents
module NumberValidation module MinMaxTests def test_minimum schema = { 'properties' => { 'a' => { 'minimum' => 5 } } } assert_valid schema, {'a' => 5} assert_valid schema, {'a' => 6} refute_valid schema, {'a' => 4} refute_valid schema, {'a' => 4.99999} # other types are disregarded assert_valid schema, {'a' => 'str'} end def test_exclusive_minimum schema = { 'properties' => { 'a' => { 'minimum' => 5 }.merge(exclusive_minimum) } } assert_valid schema, {'a' => 6} assert_valid schema, {'a' => 5.0001} refute_valid schema, {'a' => 5} end def test_maximum schema = { 'properties' => { 'a' => { 'maximum' => 5 } } } assert_valid schema, {'a' => 4} assert_valid schema, {'a' => 5} refute_valid schema, {'a' => 6} refute_valid schema, {'a' => 5.0001} end def test_exclusive_maximum schema = { 'properties' => { 'a' => { 'maximum' => 5 }.merge(exclusive_maximum) } } assert_valid schema, {'a' => 4} assert_valid schema, {'a' => 4.99999} refute_valid schema, {'a' => 5} end end # draft3 introduced `divisibleBy`, renamed to `multipleOf` in draft4. # Favor the newer name, but the behavior should be identical. module MultipleOfTests def multiple_of 'multipleOf' end def test_multiple_of schema = { 'properties' => { 'a' => { multiple_of => 1.1 } } } assert_valid schema, {'a' => 0} assert_valid schema, {'a' => 2.2} refute_valid schema, {'a' => 3.4} # other types are disregarded assert_valid schema, {'a' => 'hi'} 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/number_validation.rb |
mountapi-0.11.1 | vendor/json-schema/test/support/number_validation.rb |