File size: 457 Bytes
b2dcf0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php

namespace App\Shared\Exceptions;

use Illuminate\Validation\ValidationException;

class ValidationExceptionMapper
{
    public static function details(ValidationException $exception): array
    {
        return collect($exception->errors())
            ->map(fn (array $messages, string $field): array => [
                'field' => $field,
                'messages' => $messages,
            ])
            ->values()
            ->all();
    }
}