Beispiel #1
0
 def __setattr__(self, name, value):
     if name in self.meta_.declared_fields or name in [
             'raise_errors', 'errors', 'owner'
     ]:
         super().__setattr__(name, value)
     else:
         raise InvalidDataError({name: ['is invalid']})
Beispiel #2
0
    def __init__(self, to=None, data=None):
        if to is None or data is None:
            raise InsufficientDataError("`to` and `data` fields are mandatory")

        if not isinstance(data, dict):
            raise InvalidDataError({'data': ['should be a dict']})

        super().__init__(subject=self.SUBJECT, template=self.TEMPLATE, data=data, to=to)
Beispiel #3
0
 def __setattr__(self, name, value):
     if name in self.meta_.declared_fields or name in [
             "raise_errors",
             "errors",
             "owner",
     ]:
         super().__setattr__(name, value)
     else:
         raise InvalidDataError({name: ["is invalid"]})
Beispiel #4
0
 def __init__(self, *args, **kwargs):
     try:
         super().__init__(*args, **kwargs)
     except ValidationError as exception:
         raise InvalidDataError(exception.messages)