-
-
Notifications
You must be signed in to change notification settings - Fork 596
Closed
Description
The validation for format ipv4 and ipv6 seems to be broken or the oneOf implementation seems not to work.
Example code, version 2.3.0
from jsonschema import validate
schema = {
'type': 'object',
'properties': {
'ip': {
'type': 'string',
'oneOf' : [
{ "format": 'ipv4' },
{ "format": 'ipv6' },
],
},
},
}
validate({"ip" : "::1"}, schema)
validate({"ip" : "10.1.1.12"}, schema)
Exception
Traceback (most recent call last):
File "./test.py", line 18, in <module>
validate({"ip" : "::1"}, schema)
File "/Users/hudecof/Virtualenvs/flask-env/lib/python2.7/site-packages/jsonschema/validators.py", line 432, in validate
cls(schema, *args, **kwargs).validate(instance)
File "/Users/hudecof/Virtualenvs/flask-env/lib/python2.7/site-packages/jsonschema/validators.py", line 117, in validate
raise error
jsonschema.exceptions.ValidationError: '::1' is valid under each of {'format': 'ipv6'}, {'format': 'ipv4'}
Failed validating 'oneOf' in schema['properties']['ip']:
{'oneOf': [{'format': 'ipv4'}, {'format': 'ipv6'}], 'type': 'string'}
On instance['ip']:
'::1'
Metadata
Metadata
Assignees
Labels
No labels