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

Is Float::INFINITY a valid Money input? #276

Open
ghiculescu opened this issue Aug 6, 2023 · 1 comment
Open

Is Float::INFINITY a valid Money input? #276

ghiculescu opened this issue Aug 6, 2023 · 1 comment

Comments

@ghiculescu
Copy link
Contributor

It doesn't seem like this input should be possible (unless you're writing a program to simulate the federal reserve):

m = Money.new(Float::INFINITY, "USD")
m.value # Infinity

It raises when trying to render, which makes me think it's not intentionally working:

Money.new(Float::INFINITY, "USD").to_s
        2: from /Users/alex/.rvm/gems/ruby-2.7.7/gems/shopify-money-1.2.1/lib/money/money.rb:236:in `to_fs'
        1: from /Users/alex/.rvm/gems/ruby-2.7.7/gems/shopify-money-1.2.1/lib/money/money.rb:236:in `-'
TypeError (nil can't be coerced into Integer)

Would you consider a PR to explicitly raise when the Money is initialized?

@elfassy
Copy link
Contributor

elfassy commented Oct 11, 2023

Have you ran into a situation where this was causing an issue? Feel free to open a PR, there's no specific intent to support infinite money

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

No branches or pull requests

2 participants