jazzband / jsonmodels

jsonmodels is library to make it easier for you to deal with structures that are converted to, or read from JSON.
http://jsonmodels.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
334 stars 51 forks source link

Validation Error should be more explicit #61

Closed thomas-maurice closed 8 years ago

thomas-maurice commented 8 years ago
    schema.validate()
  File "/home/thomas/.local/share/virtualenvs/orm/lib/python2.7/site-packages/jsonmodels/models.py", line 36, in validate
    field.validate_for_object(self)
  File "/home/thomas/.local/share/virtualenvs/orm/lib/python2.7/site-packages/jsonmodels/fields.py", line 48, in validate_for_object
    value = self.__get__(obj)
  File "/home/thomas/.local/share/virtualenvs/orm/lib/python2.7/site-packages/jsonmodels/fields.py", line 40, in __get__
    self._check_value(obj)
  File "/home/thomas/.local/share/virtualenvs/orm/lib/python2.7/site-packages/jsonmodels/fields.py", line 45, in _check_value
    self.__set__(obj, self.get_default_value())
  File "/home/thomas/.local/share/virtualenvs/orm/lib/python2.7/site-packages/jsonmodels/fields.py", line 33, in __set__
    self.validate(value)
  File "/home/thomas/.local/share/virtualenvs/orm/lib/python2.7/site-packages/jsonmodels/fields.py", line 54, in validate
    self._check_against_required(value)
  File "/home/thomas/.local/share/virtualenvs/orm/lib/python2.7/site-packages/jsonmodels/fields.py", line 59, in _check_against_required
    raise ValidationError('Field is required!')
ValidationError: Field is required!

It should at least tell me which field(s) is(are) required

beregond commented 8 years ago

Ok, thanks for feedback - I'll try to improve that.

beregond commented 8 years ago

@thomas-maurice fixed and released in version 2.1 (already on PyPI) - additional info will be shown when assigning value or validating model.

thomas-maurice commented 8 years ago

Nice ! Awesome thanks :)