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

Support for "const"? #506

Closed
martin-helmich opened this issue Apr 16, 2018 · 2 comments · Fixed by #507
Closed

Support for "const"? #506

martin-helmich opened this issue Apr 16, 2018 · 2 comments · Fixed by #507

Comments

@martin-helmich
Copy link
Contributor

martin-helmich commented Apr 16, 2018

I just noticed that the Validator class does not appear to support the const keyword as specified in section 6.1.3 of the spec. Is this intentional?

Given a few pointers where to start, I'd also be prepared to open a PR to add support for this feature.

$schema = [
        "properties" => [
                "foo" => [
                        "type" => "string",
                        "const" => "foo"
                ]
        ]
];

$doc = ["foo" => "bar"];

$validator = new JsonSchema\Validator();
$validator->validate($doc, $schema);

// expected: false, actual: true
var_dump($validator->isValid());
@erayd
Copy link
Contributor

erayd commented Apr 16, 2018

This validator currently doesn't support past draft-04, and const is a draft-06 keyword (mainly because this project lacks resources - not enough devs, and those of us who do work on it don't have tons of available time, and I'm also maintaining another validator too). I'm intending to bring this project up to scratch with the newer standards at some point (probably after draft-08 is released, because that version may require some significant architectural changes), but if you'd like to open a PR for const support earlier, we'd love to have your contribution to the project :-).

@martin-helmich
Copy link
Contributor Author

@erayd Thanks for the feedback! I've opened a pull request at #507.

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

Successfully merging a pull request may close this issue.

2 participants