Hi @chaudigv
Try with this:
protected $rules = [
'start_date' => ['required', 'before_or_equal:today'],
]
Hope this works for you!
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Using livewire $rules to validate date.
protected $rules = [
'start_date' => ['required', 'before_or_equal:' . Carbon::today()],
]
gives error Constant expression contains invalid operations
I even moved the initialisation to mount(), but it produces the same error.
public $today;
protected $rules = [
'start_date' => ['required', 'before_or_equal:' . $this->today],
]
public function mount()
{
$this->today = Carbon::today();
}
Am I missing something here?
Hi @chaudigv
Try with this:
protected $rules = [
'start_date' => ['required', 'before_or_equal:today'],
]
Hope this works for you!
Please or to participate in this conversation.