Skip to content

Optional enums #16

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

Merged
merged 3 commits into from
Aug 18, 2012
Merged

Conversation

JoakimLofgren
Copy link
Contributor

I made a suggested solution to my issue #15.

I updated the Enum constraint to take the required attribute into consideration
when checking an enumeration property and whether a value exists or not for it.

I also refactored it a bit to minimize the code.
The use of in_array should pretty much mimic the "foreach-if-equal-then-found".

Test cases are added to reflect the changes.

I hope everything is satisfactory. :)

Only one unrelated test case is failing, and it must be because
I am using Windows 7 with PHP 5.4.5 at home.

There was 1 error:

1) JsonSchema\Tests\Uri\UriRetrieverTest::testResolveRelativeUri with data set #0 ('{
    "type":"object",
    "title":"child",
    "extends":"http://some.host.at/somewhere/parent",
    "properties":
    {
        "childProp":
        {
            "type":"string"
        }
    }
}', '{
    "type":"object",
    "title":"parent",
    "properties":
    {
        "parentProp":
        {
            "type":"boolean"
        }
    }
}')
JsonSchema\Exception\UriResolverException: Unable to resolve URI 'grandparent' from base '/somewhere/parent'
...
FAILURES!
Tests: 147, Assertions: 153, Errors: 1.

Added test cases where required is set as true and false,
with the attribute omitted.
@justinrainbow
Copy link
Collaborator

Looks great - all tests passing, too

justinrainbow added a commit that referenced this pull request Aug 18, 2012
@justinrainbow justinrainbow merged commit 674852b into jsonrainbow:master Aug 18, 2012
hakre pushed a commit to hakre/json-schema that referenced this pull request Mar 26, 2015
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