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?
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
?