Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oneOf and patternProperties validates incorrectly #291

Closed
lengarvey opened this issue Jan 9, 2016 · 1 comment
Closed

oneOf and patternProperties validates incorrectly #291

lengarvey opened this issue Jan 9, 2016 · 1 comment

Comments

@lengarvey
Copy link

I would expect the following test to pass:

  def test_one_of_pattern_properties
    schema = {
      "$schema" => "http://json-schema.org/draft-04/schema#",
      "oneOf" => [
        {
          "patternProperties" => {
            "^([a-z_0-9])+$" => {
              "type": "object",
              "properties" => [
                "foo" => { "type" => "string", "enum" => ["bar", "hello"] }
              ]
            }
          }
        }
      ]
    }

    assert_valid schema, { "test_thing" => { "foo" => "bar" }}
    refute_valid schema, { "test_thing" => { "foo" => "no" }}
  end

It fails with:

# Running:

F

Finished in 0.004238s, 235.9452 runs/s, 471.8904 assertions/s.

  1) Failure:
OneOfTest#test_one_of_pattern_properties [test/test_one_of.rb:103]:
{"test_thing"=>{"foo"=>"no"}} should be invalid for schema:
{"$schema"=>"http://json-schema.org/draft-04/schema#", "oneOf"=>[{"patternProperties"=>{"^([a-z_0-9])+$"=>{:type=>"object", "properties"=>[{"foo"=>{"type"=>"string", "enum"=>["bar", "hello"]}}]}}}]}.
Expected [] to not be equal to [].

1 runs, 2 assertions, 1 failures, 0 errors, 0 skips

Is this a bug? or am I missing something with my schema?

@lengarvey
Copy link
Author

Fairly sure I was mistaken here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant