# Validates\_format\_of date

**URL:** <https://www.ruby-forum.com/t/validates-format-of-date/117633>\
**Category:** Rails\
**Created:** [October 18, 2007, 8:12pm UTC](https://www.ruby-forum.com/t/validates-format-of-date/117633 "2007-10-18T20:12:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 18, 2007, 8:12pm UTC](https://www.ruby-forum.com/t/validates-format-of-date/117633/1 "2007-10-18T20:12:47Z")

</div>

Can someone tell me why this returns ‘dob is invalid’ when dob is  
‘01/01/1969’?

validates\_format\_of :dob, :with =\> /[0-9]{2}.[0-9]{2}.[0-9]  
{4}/, :message =\> ‘is invalid’

I’m trying to validate a date entred into a form. I suppose there are  
different ways to accomplish this, and because it doesn’t work, I’m  
going to be using them, but this seems like a basic format that should  
work.

irb gives me this:

> > “01/01/2007” =~ /[0-9]{2}.[0-9]{2}.[0-9]{4}/  
> > =\> 0

> > “01/01/2007” =~ %r{[0-9]{2}/[0-9]{2}/[0-9]{4}}  
> > =\> 0

> > “01/01/2007” =~ %r{^[0-9]{2}/[0-9]{2}/[0-9]{4}$}  
> > =\> 0

none of these combinations work in validates\_format\_of.

Ideas? Things to try?

Mike B.
