adzap / validates_timeliness

Date and time validation plugin for ActiveModel and Rails. Supports multiple ORMs and allows custom date/time formats.
MIT License
1.59k stars 227 forks source link

Save method does return false #148

Closed ilyakatz closed 1 year ago

ilyakatz commented 7 years ago

Looks like validates_timeliness has some issues when using SimpleDelegator. save method doesn't return false if validation fails. I'm not entirely sure if this is a general validation issue or specific to this gem. Here is the how to reproduce

class EventFormObject  < SimpleDelegator
  include ActiveModel::Validations

  validates_date :start_at,
                 :end_at,
                 :on_or_after => lambda { Date.current }

  def initialize(event)
    super
  end
end
irb(main):087:0> e = Event.last; ef = EventFormObject.new(e);
=> 1
irb(main):088:0> ef.save
=> true
irb(main):089:0> ef.valid?
=> false