You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have a nested form on web or if you want to do validation it would be prefered to list the errors inside nested schema not just that nested item is missing. This way you can map the errors to a input form more preciesly.
In marhsmallow 2 you would get what is missing in required nested schema.
{'corpo_info': {'company_name': ['Missing data for required field.'], 'address': ['Missing data for required field.']}}
Now you get only:
{'corpo_info': ['Missing data for required field.']}
I prefer previous behaviour.
import marshmallow
from marshmallow import fields
class BeneficiaryCorpoInfo(marshmallow.Schema):
company_name = fields.Str(load_only=True, allow_none=True, required=True)
address = fields.Str(load_only=True, allow_none=True, required=True)
class BeneficiaryInfoDataSchema(marshmallow.Schema):
corpo_info = fields.Nested(
BeneficiaryCorpoInfo, required=True, load_only=True, allow_none=True
)
try:
if marshmallow.__version__.startswith('2.'):
BeneficiaryInfoDataSchema(strict=True).load({})
else:
BeneficiaryInfoDataSchema().load({})
except marshmallow.ValidationError as e:
print(e.messages)
BeneficiaryInfoDataSchema(strict=True).validate('')
# marhsmallow 2: {'corpo_info': {'company_name': ['Missing data for required field.'], 'address': ['Missing data for required field.']}}
# marshmallow 3: {'corpo_info': ['Missing data for required field.']}
The text was updated successfully, but these errors were encountered:
If you have a nested form on web or if you want to do validation it would be prefered to list the errors inside nested schema not just that nested item is missing. This way you can map the errors to a input form more preciesly.
In marhsmallow 2 you would get what is missing in required nested schema.
Now you get only:
I prefer previous behaviour.
The text was updated successfully, but these errors were encountered: