1
1
<?php
2
2
3
+ /*
4
+ * This file is part of the API Platform project.
5
+ *
6
+ * (c) Kévin Dunglas <[email protected] >
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
3
12
declare (strict_types=1 );
4
13
5
14
namespace Workbench \App \Http \Requests ;
@@ -23,8 +32,8 @@ protected function prepareForValidation(): void
23
32
'pickupDate ' => $ this ->query ('pickupDate ' ),
24
33
'pickupSlotId ' => $ this ->query ('pickupSlotId ' ),
25
34
]);
26
-
27
35
}
36
+
28
37
/**
29
38
* Get the validation rules that apply to the request.
30
39
*
@@ -42,14 +51,9 @@ public function rules(): array
42
51
protected function failedValidation (Validator $ validator ): void
43
52
{
44
53
$ violations = collect ($ validator ->errors ())
45
- ->map (fn ($ m , $ f ) => ['propertyPath ' => $ f , 'message ' => $ m [0 ]]) //** @phpstan-ignore-line */
54
+ ->map (fn ($ m , $ f ) => ['propertyPath ' => $ f , 'message ' => $ m [0 ]]) // ** @phpstan-ignore-line */
46
55
->values ()->all ();
47
56
48
- throw new \ApiPlatform \Laravel \ApiResource \ValidationError (
49
- $ violations [0 ]['message ' ] ?? 'Validation failed. ' ,
50
- hash ('xxh3 ' , implode (', ' , array_column ($ violations , 'propertyPath ' ))),
51
- new \Illuminate \Validation \ValidationException ($ validator ),
52
- $ violations
53
- );
57
+ throw new \ApiPlatform \Laravel \ApiResource \ValidationError ($ violations [0 ]['message ' ] ?? 'Validation failed. ' , hash ('xxh3 ' , implode (', ' , array_column ($ violations , 'propertyPath ' ))), new \Illuminate \Validation \ValidationException ($ validator ), $ violations );
54
58
}
55
59
}
0 commit comments