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

does jsonschema support verifying optional field in json? #567

Closed
naijim opened this issue Jun 6, 2019 · 1 comment
Closed

does jsonschema support verifying optional field in json? #567

naijim opened this issue Jun 6, 2019 · 1 comment

Comments

@naijim
Copy link

naijim commented Jun 6, 2019

I am trying to figure out whether jsonschema supporting verifying optional field in json or not. I tried the following code:

from jsonschema import validate

# your code here
schema = {
    "type" : "object",
    "properties" : {
        "price" : {"type" : "number", "required": false},
        "name" : {"type" : "string"},
    },
}

validate({"name" : "Eggs", "price" : 123.123}, schema)

I have this error:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-6-6a64e78dd26e> in <module>
      5     "type" : "object",
      6     "properties" : {
----> 7         "price" : {"type" : "number", "required": false},
      8         "name" : {"type" : "string"},
      9     },

NameError: name 'false' is not defined

So this feature isn't supported yet?
I found related question here

@naijim naijim changed the title does jsonshcema support verifying optional field in json? does jsonschema support verifying optional field in json? Jun 6, 2019
@naijim naijim closed this as completed Jun 6, 2019
@naijim
Copy link
Author

naijim commented Jun 6, 2019

I have found some clues. issue closed

Julian added a commit that referenced this issue Jul 2, 2022
b7d13f4b Merge pull request #567 from json-schema-org/invalid-anchors
4811789d Also add an anchor test with valid prefix (but still invalid).
b62f97cc Add tests for invalid anchors.
af5075ca Merge pull request #568 from json-schema-org/ether/perl-implementations
dc5c91e9 update the list of Perl implementations

git-subtree-dir: json
git-subtree-split: b7d13f4b563b2e4d4ba2af624917333e40ae96da
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

No branches or pull requests

1 participant