Skip to content

Documentation : Is the readme example actually working ? #299

Closed
@etiennechabert

Description

@etiennechabert

I am using your library for few days and I struggled a bit at the beginning to make it work with a very basic case.

I did my best to follow your example, but it was not really helping :

$data = json_decode(file_get_contents('data.json'));

// Validate
$validator = new JsonSchema\Validator;
$validator->check($data, (object)['$ref' => 'file://' . realpath('schema.json')]);

I created this stackoverflow post with my issue, please feel free to read it : http://stackoverflow.com/questions/39042346/json-schema-required-properties-ignored/39048262?noredirect=1#comment65497165_39048262

The answer was not really helping, for this reason I finally execute my code and your library step-by-step to understand what was going on. To be honest I don't understand how your example could work. After debugging your code, I am not able to tell where you are loading the JSON schema.

Inside the UndefinedConstraint:validateCommonProperties function, where you are checking if required properties are in, my schema is not loaded yet.

As you can see in the stackoverflow post, I finally make it work by loading the schema myself.

I created this ticket because I get quite confused by your example, I am definitely missing something about it... Is it possible for you to add more details on how dummies like me are supposed to use it ;)

Best regards,

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