Supports validation when a hash is provided to a monetized attribute.
Example:
Given Product:
class Product
monetize :price_in_a_range_cents, allow_nil: true,
subunit_numericality: {
greater_than: 0,
less_than_or_equal_to: 10000
},
numericality: {
greater_than: 0,
less_than_or_equal_to: 100,
message: "must be greater than zero and less than $100"
}
end
the following code passes validation:
Product.create(price_in_a_range:{amount: 4, currency: 'usd'})
Product.create(price_in_a_range:{cents: 4})
Product.create(price_in_a_range:{}) # treats it as if `nil` was passed
While the following would not pass:
Product.create(price_in_a_range:{currency: 'usd'}) # treat it as if `0` was passed to cents
Product.create(price_in_range:{some_other_key: 289}) # treat it as if `0` was passed to cents
Supports validation when a hash is provided to a
monetized
attribute.Example:
Given Product:
the following code passes validation:
While the following would not pass:
Closes #627