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
We have an object that can hold a value which is just a string. Depends on the STI Child of the object, a specific validation is running.
t.string :value, null: true
class SmartField < ApplicationRecord
validates :value, date: true
end
SmartField.create! value: Date.today
ActiveRecord::RecordInvalid: Validatie mislukt: Value is geen datum
this looks very odd to me and was unexpected.
def is_time?(object)
object.is_a?(Time) || (defined?(Date) and object.is_a?(Date)) || (defined?(ActiveSupport::TimeWithZone) and object.is_a?(ActiveSupport::TimeWithZone))
end
do we need a string check, aka Date.parse rescue false?
The text was updated successfully, but these errors were encountered:
krtschmr
changed the title
Not working as expected, what am i missing?
Validation doesn't work if the value is represented as a string
Aug 5, 2022
We have an object that can hold a value which is just a string. Depends on the STI Child of the object, a specific validation is running.
this looks very odd to me and was unexpected.
do we need a string check, aka
Date.parse rescue false
?The text was updated successfully, but these errors were encountered: