Better documentation for numericality validator
pedroaugustofsilva opened this issue · 1 comments
pedroaugustofsilva commented
In the monetize below:
monetize :price_cents,
allow_nil: true,
numericality: {
greater_than_or_equal_to: 0,
less_than_or_equal_to: 10000
}
The values for greater_than_or_equal_to
and less_than_or_equal_to
refer to the normalized raw value, not to the value in cents. This is not documented, which can cause some confusion, as it did with me.
Another point is that nil values are converted to 0. In cases where the money cannot be nil, but nil is assigned to it, wouldn't it be better to add an error like "Value can't be blank"?
If these suggestions make sense, I can document them.
semmons99 commented
please do