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

robertp1980's avatar

Validation Rule for date.

I need some help. I need a rule to check the date. On create: required|date|greater:yesterday. Thats fine, cause i want only to set dates from today or higher. My problem is, how can i check the date on edit. Cause, when i edit it 2 days later, i got an validation error, cause date is less then today. I would like, when i edit, it should pass on the same date as already saved, or when date changed, it must be greater then yesterday (today).

thanks.

0 likes
6 replies
Sinnbeck's avatar

Or perhaps you could use the "created_at" date when updating

'required|date|after_or_equal:' . $model->created_at->toDateString()
robertp1980's avatar

Hi Sinnbeck, thats exactly what i need, but is it possible to set? After or equal like today OR equal like model->created_at ?

Sinnbeck's avatar

@robertp1980

//on update
'required|date|after_or_equal:' . $model->created_at->toDateString()

//on new/create
'required|date|after_or_equal:' . now()->toDateString()
Sinnbeck's avatar

@robertp1980 if it was solved then please consider marking a best answer to set the thread as solved

Please or to participate in this conversation.