# Date Validation for date\_select

**URL:** <https://www.ruby-forum.com/t/date-validation-for-date-select/162814>\
**Category:** Rails\
**Created:** [March 14, 2009, 2:11am UTC](https://www.ruby-forum.com/t/date-validation-for-date-select/162814 "2009-03-14T02:11:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![siddharth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@siddharth](https://www.ruby-forum.com/u/siddharth)\
**Post date:** [March 14, 2009, 2:11am UTC](https://www.ruby-forum.com/t/date-validation-for-date-select/162814/1 "2009-03-14T02:11:25Z")

</div>

I am new to Rails and I am building this website based on the tutorials  
from a book called Railspace. My problem is I have a form page which  
accepts the date for  
a birthdate field

```
  <div class="form_row">
    <label for="birthdate"> Birthdate </label>
    <%= date_select :spec, :birthdate,
                                      :start_year=>Spec::START_YEAR,
                                      :end_year=>Time.now.year,
                                      :include_blank=>true,
                                      :order =>[:month, :day, :year]

```

%\>

```
  </div>

```

It works fine when I enter correct dates but when I try entering  
something like Feb 31 2009 it gives me the following error.

```
   1 error(s) on assignment of multiparameter attributes

```

My parameter variable shows that its being passed as 3 seperate values  
(that is my understanding please correct me if I am wrong)

{“commit”=\>“Update”, “spec”=\>{“city”=\>“Atlanta”, “occupation”=\>“Software  
programmer”, “zip\_code”=\>“21312”, “birthdate(1i)”=\>“1907”,  
“gender”=\>“Male”, “birthdate(2i)”=\>“2”, “birthdate(3i)”=\>“31”,  
“first\_name”=\>“Dilbert”, “last\_name”=\>“Dilbert”, “state”=\>“Georgia”}}

I cannot seem to validate this using the validate method on the  
controller as I am unable to fetch the values of the parameters.  
Ive tried using something like

def validate  
if (birthdate.month==2 && birthdate.day \> 29)  
errors.add(:birthdate, “Invalida date”)  
end

but its seems to completely bypass this. It works correctly when i  
simply type  
if(birthdate.month==2 )  
errors.add(…)  
but I dont seem to understand why I cannot validate it.

Could someone explain this to me.  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![siddharth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@siddharth](https://www.ruby-forum.com/u/siddharth)\
**Post date:** [March 14, 2009, 2:13am UTC](https://www.ruby-forum.com/t/date-validation-for-date-select/162814/2 "2009-03-14T02:13:54Z")

</div>

Im sorry the validate method in the model (Spec which stores  
specifications of the registered users)
