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

Ecto types return malformed error when casting invalid currency #4

Closed
bgracie opened this issue Oct 4, 2019 · 2 comments
Closed

Ecto types return malformed error when casting invalid currency #4

bgracie opened this issue Oct 4, 2019 · 2 comments

Comments

@bgracie
Copy link

bgracie commented Oct 4, 2019

When casting an invalid currency, the both ecto types return an error tuple with another tuple as the second element.

{:error, {Cldr.UnknownCurrencyError, "The currency \"AAA\" is invalid"}}

This violates the typespec for Ecto.Type.cast: cast(term()) :: {:ok, term()} | {:error, keyword()} | :error, and causes an exception when used in Ecto.Changeset.cast

Please see this demo repo for a demonstration of the issue.

Incidentally, it appears that the load functions also violate the error typespec from Ecto.Type.

@kipcole9
Copy link
Owner

kipcole9 commented Nov 1, 2019

@bgracie I apologise, I only just noticed this (I need to check notifications on this repo). I’ll fix this right away.

@bgracie
Copy link
Author

bgracie commented Nov 2, 2019

@kipcole9 Thanks!

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