Add USD($) validator
Would like a validator that checks whether $10.03 is valid US dollars. Would accept 10.03, 1.39, .03, 0.10, $10.01, $0.01, etc, even 39¢
Thanks!
@chriso is this appropriate for this library or is it too specialized? Maybe a more generic validator that takes a currency code? I'd be happy to contribute if you think this belongs.
Would be completely happy with generic currency validator.
A generic one would be nice; one that uses locales or currency codes like the isMobilePhone validator.
Some more info here:
- https://msdn.microsoft.com/en-us/goglobal/bb688126.aspx
Cool, I'm on it. I'll try to add support for currency codes corresponding to those phone locales, plus USD.
@programsam just curious, what's the use case for needing to validate "39¢"?
No particular one in mind, but it is a valid representation for US currency, so, for completeness if nothing else. I imagine if you leave it unimplemented, there will be a request in the future.
Agree that it's a valid representation for US currency, but the pull request I just sent implements a currency validator based on currency codes, including USD. Doesn't seem like that would be a valid format for USD. I would suggest combining with a simple "matches" validator if you want to include strings with cents for units.
I like the PR the way it is just fine.
Fixed by #368.