Is there a way to use validates_numericality_of and still allow null
values?
I have a model with some optional values that can be nil, but if they’re
present, they must be numbers. Will I need to construct a custom
valiation for this, or is there some method built in? Seems like it
would be a common enough need.
Is there a way to use validates_numericality_of and still allow null
values?
I have a model with some optional values that can be nil, but if they’re
present, they must be numbers. Will I need to construct a custom
valiation for this, or is there some method built in? Seems like it
would be a common enough need.
Jeff
That will teach me to post without trying it. :allow_nil wasn’t listed
in the attributes for validates_numericality_of in Agile Web Dev, so I
just assumed and posted prematurely. It works fine.
Jeff
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.