obi101
1 week ago
102
1
Laravel

Laravel time validation

Posted 1 week ago by obi101

Hey everyone, first of all, thank you in advance for your time. I am having a problem validating data through Laravel validation, the user will send me two values of type time under the format 'hours:minutes' ex: 14:30 and 16:30. These two values should verify this condition : 08:00 < value 1 < value 2 < 19:00. To fulfill this I made this validation :

$validatedData = $request->validate(
            [
                'heure_debut' => 'required|date_format:H:i|after_or_equal:8:00',
                'heure_debut' => 'required|date_format:H:i|before: heure_fin',
                'heure_fin' => 'required|date_format:H:i|after: heure_debut',
                'heure_fin' => 'required|date_format:H:i|before_or_equal:19:00',
               
            ],
        );

where 'heure_debut' equals value 1 and 'heure_fin' equals value 2.

Please sign in or create an account to participate in this conversation.