RubyMoney / money-rails

Integration of RubyMoney - Money with Rails
MIT License
1.79k stars 386 forks source link

Validation of Currency Types by Name or ISO #679

Closed chase-stevens closed 10 months ago

chase-stevens commented 11 months ago

I wanted to see if we could set validations on currency columns such that we only allow certain currencies to be initialized as Money objects or saved to currency columns (for example, USD and MXN) and/or disable others (GBP, EUR).

sunny commented 11 months ago

In my apps I use something like this for this:

validates :currency, inclusion: {in: -> %w[USD MXN]}
chase-stevens commented 10 months ago

Thanks @sunny appreciate it -- think this works for us!