Skip to content

False passes with file loaded schemas. #340

Closed
@elb98rm

Description

@elb98rm

I'm working on a laravel project (so please excuse any framework specific functions), and I'm noticing false positives on the validation tests.
The system is part of a restful api, and as such I'm validating all requests for item creation.

If I define the following schema (docs/json/test_schema.json):

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Foo",
  "description": "Properly defines a Foo",
  "type": "object",
  "properties": {
    "foo_id_text": {
      "description": "UUID for this Foo",
      "type": "string"
    }
  },
  "required": [
    "foo_id_text"
  ]
}

Inside my controller, I have the following:

$json = json_decode('{}');

$this->validator->check(
    $json,
    (object)['$ref' => 'file://' . base_path('docs/json/test_schema.json')]
);

var_dump($this->validator->isValid()); exit;

... then I get:

bool(true)

Note that:

  • if I create a FILE based json and FILE based compare, OR
  • do an INLINE schema definition compared to an INLINE json submission
    ... it behaves as expected (i.e : bool(false)

I've reduced this to such a low level I think it is actually a bug. Can you please investigate (alongside me).

Cheers
Rick

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions