Date_select and date validation


#1

Hi,

I’ve put together a simple form that contains among other things a
date_select:

<%= date_select(:user, :dob, :order => [:day, :month, :year],
:start_year => 1900, :end_year => Date.today.year) %>

In my controller I have some code to create a user entity from the
parameters posted up from the form, like so:

parameters: {“user”=>{“dob(1i)”=>“2006”, “dob(2i)”=>“2”,
“dob(3i)”=>“31”}}

@user = User.new(params[:user])

As if by magic Rails will convert dates like 02/31/2006 into 03/03/2006
so at the model level ‘user.dob’ => ‘03/03/2006’.

Is there a way to switch off this behaviour? In my opinion, an invalid
date shouldn’t result in a valid one being created.

regards,
C.