You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm upgrading Rails app from mongoid 7.5 to 8.1.1. I had validations like:
field :number_per_year, type: Float, default: 0
validates_numericality_of :number_per_year, allow_blank: true
When using 7.5 and I pass e.g. string 'foo' validation does not pass as expected. But in mongoid 8.1.1 as I'v found when passing string and it's not a number it's casted to number, if cast can not be done it's silently converted to nil. So now my validation passes when it should not. I'v refactored it that way:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm upgrading Rails app from mongoid 7.5 to 8.1.1. I had validations like:
When using 7.5 and I pass e.g. string 'foo' validation does not pass as expected. But in mongoid 8.1.1 as I'v found when passing string and it's not a number it's casted to number, if cast can not be done it's silently converted to nil. So now my validation passes when it should not. I'v refactored it that way:
It works as expected now but I want to make sure are there any drawbacks/dangers in that approach?
Beta Was this translation helpful? Give feedback.
All reactions