You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> import warlock
>>> Example=warlock.model_factory(schema)
>>> Example('xyz')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/warlock/core.py", line 35, in __init__
base_class.__init__(self, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/warlock/model.py", line 30, in __init__
d = dict(*args, **kwargs)
ValueError: dictionary update sequence element #0 has length 1; 2 is required
or
>>> Example(_='xyz')
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/warlock/model.py", line 140, in validate
jsonschema.validate(obj, self.schema)
File "/usr/local/lib/python3.6/site-packages/jsonschema/validators.py", line 934, in validate
raise error
jsonschema.exceptions.ValidationError: {'_': 'xyz'} is not of type 'string'
Failed validating 'type' in schema:
{'$schema': 'http://json-schema.org/draft-04/schema#',
'enum': ['abc', 'xyz'],
'title': 'Example',
'type': 'string'}
On instance:
{'_': 'xyz'}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/warlock/model.py", line 33, in __init__
self.validate(d)
File "/usr/local/lib/python3.6/site-packages/warlock/model.py", line 142, in validate
raise exceptions.ValidationError(str(exc))
warlock.exceptions.ValidationError: {'_': 'xyz'} is not of type 'string'
Failed validating 'type' in schema:
{'$schema': 'http://json-schema.org/draft-04/schema#',
'enum': ['abc', 'xyz'],
'title': 'Example',
'type': 'string'}
On instance:
{'_': 'xyz'}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/warlock/core.py", line 35, in __init__
base_class.__init__(self, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/warlock/model.py", line 35, in __init__
raise ValueError(str(exc))
ValueError: {'_': 'xyz'} is not of type 'string'
Failed validating 'type' in schema:
{'$schema': 'http://json-schema.org/draft-04/schema#',
'enum': ['abc', 'xyz'],
'title': 'Example',
'type': 'string'}
On instance:
{'_': 'xyz'}
The text was updated successfully, but these errors were encountered:
Hello,
If a JSON Schema is for a simple JSON object (string/number/integer), warlock will fail to bind and we can't instantiate object.
For example, given the following JSON Schema:
warlock
will fail to create an objector
The text was updated successfully, but these errors were encountered: