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

Change error reporting for invalid types with multiple valid types #294

Merged
merged 1 commit into from
Aug 11, 2016

Conversation

FlorianSW
Copy link
Contributor

@FlorianSW FlorianSW commented Jul 25, 2016

Currently, if a property has multiple valid types, an error message
when a value doesn't conform to the schema, would mention only the
last valid type, without mentioning the other valid types.

This commit changes, how the TypeConstraint works internally. It
does a little bit of refactoring (removing also the "Refacter this"
ToDo) and now mentions any valid types on a failure.

Fixes #293

// with a new type constraint
if (is_object($tp)) {
if (!$isValid) {
$validator = new static($this->checkMode);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we could get rid of this (at least for me) ugly looking workaround, but it seems it's the best solution we currently have :/

@FlorianSW
Copy link
Contributor Author

I'm not sure, but the failed test https://travis-ci.org/justinrainbow/json-schema/jobs/147291856 looks unrelated to this change?

@FlorianSW
Copy link
Contributor Author

@bighappyface Have you found some time to take a look at this commit? :-)

@bighappyface
Copy link
Collaborator

@FlorianSW did we lose the test?

@FlorianSW
Copy link
Contributor Author

What test? I'm pretty sure we don't need extra test for this change as it's already covered by existing tests? :-)

@bighappyface
Copy link
Collaborator

I feel like a test was added that would have encouraged me to remove the "needs tests" label. I don't recall it exactly but the comment history suggests a test was created.

Regardless, I feel because this PR changes behavior that a new test exhibiting the new behavior is desirable to ensure the outcome described in #293 has been achieved.

@FlorianSW
Copy link
Contributor Author

Ah, my bad, in my second commit I had in focus to unbreak existing tests (because of my refactoring), so I haven't noticed anymore, that I added some functionality. :D Let me add some tests! :)

Currently, if a property has multiple valid types, an error message
when a value doesn't conform to the schema, would mention only the
last valid type, without mentioning the other valid types.

This commit changes, how the TypeConstraint works internally. It
does a little bit of refactoring (removing also the "Refacter this"
ToDo) and now mentions any valid types on a failure.

Fixes jsonrainbow#293
@FlorianSW
Copy link
Contributor Author

@bighappyface Maybe you haven't seen it, but I've added some tests to an already existing test case :-)

@bighappyface
Copy link
Collaborator

+1

@bighappyface bighappyface merged commit 38503c4 into jsonrainbow:master Aug 11, 2016
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 this pull request may close these issues.

2 participants