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

Date of birth is not a valid date each time setting the date properly #158

Closed anjolovic closed 6 years ago

anjolovic commented 7 years ago

Hi

I am trying to validate date_of_birth using the following code:

validates_date :date_of_birth, :before => lambda { 18.years.ago },
                         :before_message => "must be at least 18 years old"

In my form, I have the following:

<%= form.text_field :date_of_birth, type: 'date', id: :profile_data_of_birth %>

Standard. Nothing particuler. But when I set the date, I keep getting the following error:

Date of birth is not a valid date

Any thoughts why this is happening?

Thanks very much!

adzap commented 6 years ago

what format is the DOB you're inputting?