dataclasses-json
dataclasses-json copied to clipboard
Feature Request: Include data validation for dataclass json
Can you provide more details what you need?
Are you aware of DataClassJson.schema().loads()
?
Can you provide more details what you need? Are you aware of
DataClassJson.schema().loads()
?
Ah okay, let me check it, but please don't close the issue, I may investigate it more and want to customize the validation logic. E.g field A must present if field B present or something like that, thanks for your swift reply <#
Can you provide more details what you need? Are you aware of DataClassJson.schema().loads()?
This doesn't work if I want to work with camelCase JSON. Even though I define my dataclass with @dataclass_json(letter_case=LetterCase.CAMEL)
, the schema the gets generated by .schema()
is still looking for snake_case.
I am expecting to be able to do something like:
from marshmallow import ValidationError
try:
mydataclass.schema().load(request.json) # request.json will be camelCase
except ValidationError as err:
# do something with marshmallow's err.normalized_messages()
Closing as stale - feel free to reopen and ping you think we should do something about this.