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

Handle when the passed value is not a Date value. when it's a Numeric #230

Open eng-Abdurhman opened 1 year ago

eng-Abdurhman commented 1 year ago

When the passed value is not a date. when it is a Numeric, then we get the following exception 👇 => NoMethodError: undefined method "to_date" for 444:Integer


Example: # app/models/item.rb

validates_date :expire_date

# console:

> item = Item.new(expire_date: 444)
> item.valid?
NoMethodError: undefined method `to_date' for 444:Integer

Can anyone help with this?


The suggested fix to handle Numeric values is: https://github.com/adzap/validates_timeliness/pull/229