221
Views
8
Comments
Solved
Time input validation
Application Type
Mobile

Hi ,

I'm making a room booking platform and have encountered an issue during input validation, My current validations stop the user from booking a room at an already booked time , but the user is able to book a room in between the start and end time of a booking. 

For example : user A books a room from 12 to  1.

User B tries to book the room at 12 or 1 = the application stops the user from doing so 

but

User B is able book the room in between 12:01 to 12:59  = this shouldn't happen , I haven't been able to work out a solution to this problem

Any help would be appreciated .


2022-10-17 06-51-09
Shweta Gedam
Solution
  1. Put this (BookingStartTime >= Entity.StartTime and BookingStartTime <=Entity.EndTime) and (BookingEndTime >= Entity.StartTime and BookingEndTime <= Entity.EndTime) condition in your DB aggregate .
  2. In your action,  refresh this aggregate.
  3. At the last, use an IF to check if Aggregate is empty or not, if it is empty, allow user to book time else throw exception.

Hope i'm clear to you, Thanks

2022-10-17 06-51-09
Shweta Gedam

Hi Noor,

What should happen if your booking time is from 11 to 12? It will allow user or not then?

And one more, What inputs user have to book time for a room?

Please confirm so that, it would be helpful for us to give you solution.

Thanks

UserImage.jpg
Noor Syed

It will allow the user to book the room if no one else has booked the room at 11 or 12. 

I have attached a photo of the required inputs from users

Screenshot20210107000349.png
2022-10-17 06-51-09
Shweta Gedam

You can try using following validation rule if you have two inputs for BookingStartTime and BookingEndTime

If((BookingStartTime >= Entity.StartTime and BookingStartTime <=Entity.EndTime) and (BookingEndTime >= Entity.StartTime and BookingEndTime <= Entity.EndTime))

True{

//Show Validations

}

False{

//Allow Booking

}

Hope this helps, Thanks :)

UserImage.jpg
Noor Syed

I tried your expression and its giving me the same problem , basically the  Entity.StartTime  is showing up as 00:00:00 when i try to compare to BookingStartTime  .

UserImage.jpg
Noor Syed
Screenshot20210107001645.png
2022-10-17 06-51-09
Shweta Gedam

Entity.StartTime is the time stored in your Database. You have to compare your inputted time with time stored in DB.

It would be great if you can share OML here to know what is exactly going wrong.

Thanks

2022-10-17 06-51-09
Shweta Gedam
Solution
  1. Put this (BookingStartTime >= Entity.StartTime and BookingStartTime <=Entity.EndTime) and (BookingEndTime >= Entity.StartTime and BookingEndTime <= Entity.EndTime) condition in your DB aggregate .
  2. In your action,  refresh this aggregate.
  3. At the last, use an IF to check if Aggregate is empty or not, if it is empty, allow user to book time else throw exception.

Hope i'm clear to you, Thanks

UserImage.jpg
Noor Syed

Thanks for the help it worked perfectly .

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.