Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

djmoney/contrib/django_rest_framework/fields.py throws InvalidOperation instead of validation exception #601

Closed
ahurracode opened this issue Feb 1, 2021 · 3 comments · Fixed by #650

Comments

@ahurracode
Copy link

image

Inputs:

  • 1: {'amount': 'v', 'amount_currency': 'XUA'}
  • 2: {'amount': '', 'amount_currency': 'XUA'}
@benjaoming
Copy link
Contributor

Hi @ahurracode 👋

Are you looking for a better Exception type here or do you believe this input should be considered valid?

@ahurracode
Copy link
Author

Hi @benjaoming ,
Am using djmoney in a DRF project.
if my input is an invalid string for both fields like {'amount': 'v', 'amount_currency': ''} i get a nice error from calling is_valid on the serializer, it would be nice to have same behaviour if any of the field values are not valid

@benjaoming benjaoming changed the title djmoney/contrib/django_rest_framework/fields.py throws invalid operation exception when there is a value for ammount_currency and amount is empty str .i.e '''' or anyother string that cant be coersed to an number djmoney/contrib/django_rest_framework/fields.py throws InvalidOperation instead of validation exception Feb 14, 2021
@benjaoming
Copy link
Contributor

That seems fair. Thanks for opening the issue. A PR is most welcome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants