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

No support for midnight with :time type #188

Open bbugh opened 4 years ago

bbugh commented 4 years ago

When setting 24:00, the gem seems to wrap the expected value to 0, so there seems to be no way to say "before midnight".

validates :w_day_begin, timeliness: { before: '24:00' }
                                                           vvvvvvvv wrap to zero?
 @details={:w_day_begin=>[{:error=>:before, :restriction=>"00:00:00"}]},
 @messages={:w_day_begin=>["before error message"]}>
sherif-nedap commented 2 years ago

@bbugh this is old :), but i just had the same issue,

i have the same issue:

start_time: 23:00 end_time: 24:00

this will trigger this validation to raise exception because 24:00 will be converted to 00:00

validates_time :end_time,
                       after: :start_time, after_message: _('End time should be after start time'),
                       if: :start_time