# How do i validate if a datetime entered in the form has alre

**URL:** <https://www.ruby-forum.com/t/how-do-i-validate-if-a-datetime-entered-in-the-form-has-alre/111519>\
**Category:** Rails\
**Created:** [August 8, 2007, 7:53am UTC](https://www.ruby-forum.com/t/how-do-i-validate-if-a-datetime-entered-in-the-form-has-alre/111519 "2007-08-08T07:53:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adild99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9fc348/32.png) [@adild99](https://www.ruby-forum.com/u/adild99)\
**Post date:** [August 8, 2007, 7:53am UTC](https://www.ruby-forum.com/t/how-do-i-validate-if-a-datetime-entered-in-the-form-has-alre/111519/1 "2007-08-08T07:53:52Z")

</div>

I am creating a form to capture appointments for specialists and  
members… the schema of the appointments table looks something like  
this…

id (integer)  
specialist\_id (integer)  
member\_id (integer)  
description (string)  
start\_at (datetime)  
duration (integer)

what i want to achieve is when trying to save a new appointment the  
data should be validated to check if an appointment is already booked  
for the specific specialist or member. in other words it should not  
allow me to book duplicate appointments for a specialist or member.  
any help would be highly appreciated.

thanks

---

<div class="post-metadata">

**Author:** ![adild99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9fc348/32.png) [@adild99](https://www.ruby-forum.com/u/adild99)\
**Post date:** [August 8, 2007, 9:07am UTC](https://www.ruby-forum.com/t/how-do-i-validate-if-a-datetime-entered-in-the-form-has-alre/111519/2 "2007-08-08T09:07:18Z")

</div>

Maybe you should do it in model, in save or initialize method.

Regards  
PaweÅ‚ Stawicki
