Throwing ValidationException from afterStateUpdated

Hi, is it possible to throw a ValidationException from the afterStateUpdated lifehook on a form field? Is there any other way to do it using halts?
>afterStateUpdated(function ($state, Get $get, callable $set) {
if($pivotData->isValidTimeSlot($state)){
// Do something
else{
throw ValidationException::withMessages(['start_datetime' => 'Datetime is invalid']);
}
}
>afterStateUpdated(function ($state, Get $get, callable $set) {
if($pivotData->isValidTimeSlot($state)){
// Do something
else{
throw ValidationException::withMessages(['start_datetime' => 'Datetime is invalid']);
}
}
But this doesnt seem to work. I can send Notifications but I want the validation error to trigger
Solution:
I figured this out, apparently the field has to be called data.start_datetime instead of just start_datetime so throw ValidationException::withMessages(['data.start_datetime' => "error here"]);...
Jump to solution
1 Reply
Solution
DarkCoder
DarkCoder9mo ago
I figured this out, apparently the field has to be called data.start_datetime instead of just start_datetime so throw ValidationException::withMessages(['data.start_datetime' => "error here"]);
Want results from more Discord servers?
Add your server