Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

FabienArr's avatar

Laravel validator on date is always pass

Hello,

This is my code :

            $input = [
                'user_id' => Auth::id(),
                'date' => null,
                'timestamp_demande' => now(),
                'timestamp_modification' => now(),
                'statut' => $demande['statut'],
                ];
            $validator = Validator::make($input, [
                'user_id' => 'required',
                'date' => 'required|date|date_format:Y-m-d',
                'timestamp_demande' => 'required',
                'timestamp_modification' => 'required',
                'statut' => 'required',
            ]);

Why the validator is ok whereas the 'date' field is null ?

Regards

1 like
2 replies
JussiMannisto's avatar

Show the full code where you're running the validation and checking its result.

1 like

Please or to participate in this conversation.