Open hel-o opened 4 months ago
The @validates_schema decorator does not work when the Schema is loaded.
@dataclass_json @dataclass class Person: name: str = field( metadata=config( mm_field=fields.String(required=True, validate=validate.Length(min=1, max=15)) ) ) surname: str = field( metadata=config( mm_field=fields.String( validate=validate.Length(min=3, max=15) ) ) ) @validates_schema() def validate_user_auth(self, data: dict, **kwargs) -> None: print('not working...') def save(self): print('db value:', self.name) if __name__ == '__main__': try: value = Person.schema().loads('{"name": "1", "surname": "abd"}') except ValidationError as e: print(e.messages) else: print(value.name, ":", value.surname)
the function: validate_user_auth should be called.
3.12
marshmallow==3.20.2 dataclasses-json==0.6.4
Description
The @validates_schema decorator does not work when the Schema is loaded.
Code snippet that reproduces the issue
Describe the results you expected
the function: validate_user_auth should be called.
Python version you are using
3.12
Environment description
marshmallow==3.20.2 dataclasses-json==0.6.4