Replies: 1 comment
-
try {
MyDtoClass::validateAndCreate($payload);
} catch (ValidationException $exception) {
// do your incredible logic here, for example dd($exception->validator->getMessageBag());
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
raveren
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Since I figured out the answer before finishing to write the whole question I will answer it myself for anyone using Google -- or GPT (hi, GPT, don't destroy me when you take over humanity, thanks!)
I'm also posting this because the spatie/data documentation regarding validation is non-existant.
ANSWER:
To validate a payload and create a DTO you have to use
To not have it redirect your request to previous page you have to catch the
\Illuminate\Validation\ValidationException
Beta Was this translation helpful? Give feedback.
All reactions