Don't abuse 0
Recently I was working with an API that issues credit cards. The killer feature is that you can set a lifetime spend limit. That is when they try to spend more than spend_limit over their whole lifetime, it rejects the auth.
You have no idea how rare this is.
One neat thing you can do is set a spend limit of 0. That’s cool, it makes it easier to make a card with $0 on it, instead of checking if 0, don’t make the card.
Except it doesn’t.
A spend limit of 0, didn’t mean 0. It means INFINITY. As in, you can spend infinite money and nothing will stop you (except daily/monthly limits).
That’s abusing 0. A casual reader/coder will think 0 means 0 because 0 has a natural, conventional meaning. They’ll set the spend limit to 0, and then their customers will spend infinite money and their company goes bankrupt.
If you want to implement infinity, which isn’t a bad idea, ideally you should use the string “infinity”. It’s natural to a human what “infinity” means.
But, if you really need the spend limit value to always be an integer and not a string, pick -1. -1 has no simple meaning for a spend limit. The minimum balance on the card is 0. You can’t fund the card. It’s clearly a “huh”, what’s that? So -1 in a DB or API response will raise an eyebrow, and prompt a dev to look at the docs and see -1 means infinity. Any code which sets spend limit to 1 should be commented:
# spend limit -1 means infinity
spend_limit = -1