# How to validate TimeWithZone model attribute

**URL:** <https://www.ruby-forum.com/t/how-to-validate-timewithzone-model-attribute/147224>\
**Category:** Rails\
**Created:** [August 29, 2008, 3:48pm UTC](https://www.ruby-forum.com/t/how-to-validate-timewithzone-model-attribute/147224 "2008-08-29T15:48:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgagnon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e95f7d/32.png) [@rgagnon](https://www.ruby-forum.com/u/rgagnon)\
**Post date:** [August 29, 2008, 3:48pm UTC](https://www.ruby-forum.com/t/how-to-validate-timewithzone-model-attribute/147224/1 "2008-08-29T15:48:47Z")

</div>

I try to validate the format of a date field but as soon a user set a  
wrong date format in the form, the date (TimeWithZone) is set to nil so  
I can’t validate the format.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![rgagnon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e95f7d/32.png) [@rgagnon](https://www.ruby-forum.com/u/rgagnon)\
**Post date:** [September 2, 2008, 2:38pm UTC](https://www.ruby-forum.com/t/how-to-validate-timewithzone-model-attribute/147224/2 "2008-09-02T14:38:09Z")

</div>

RÃ©mi Gagnon wrote:

> I try to validate the format of a date field but as soon a user set a  
> wrong date format in the form, the date (TimeWithZone) is set to nil so  
> I can’t validate the format.
> 
> Any suggestions?

I’m surprised to see there is no response to my issue. Is it enough  
clear?

Need you help.
