themsaid/ergodnc

Reservation Validation Rule

Nirajnepal opened this issue · 1 comments

Hey Said,
I am running with some issue within validators which validate the reservation for an office which should always be greater than 1 day.
Lets say i make a reservation for an office from "2021-10-07" to "2021-10-08" on 2021-10-06 since the difference between these two dates is 1 day($numberOfDays = 1 ) and as user are allowed to stay till the last day which is 2021-10-08, technically that makes it reservation for 2 days( $numberOfDays + 1) and following validator will always pass
if($numberOfDays < 2){
throw ValidationException::withMessages([
'start_date' => 'You cannot make reservation for only one day'
]);
}
and user will be allowed to make the reservations which should not be allowed according to the validation rule.

Please let me know if i am mistaken.

I fixed that part in my code. You can check the repo for the latest code. Thanks for letting me know :)