How to use the jsonmodels.errors.ValidationError function in jsonmodels

To help you get started, we’ve selected a few jsonmodels examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jazzband / jsonmodels / tests / test_lazy_loading.py View on Github external
def test_embedded_model(model):
    entity = model()
    assert entity.secondary is None
    entity.name = 'chuck'
    entity.secondary = Secondary()
    entity.secondary.data = 42

    with pytest.raises(errors.ValidationError):
        entity.secondary = 'something different'

    entity.secondary = None
github jazzband / jsonmodels / jsonmodels / fields.py View on Github external
def _check_types(self):
        if self.types is None:
            raise ValidationError(
                'Field "{type}" is not usable, try '
                'different field type.'.format(type=type(self).__name__))
github openstack / dragonflow / dragonflow / db / api_nb.py View on Github external
def _get_topic(obj):
    try:
        return getattr(obj, 'topic', None)
    except errors.ValidationError:
        return None
github jazzband / jsonmodels / jsonmodels / fields.py View on Github external
def _check_against_required(self, value):
        if value is None and self.required:
            raise ValidationError('Field is required!')