1 |
<?php
|
|
2 |
|
|
3 |
namespace Nuwave\Lighthouse\Exceptions; |
|
4 |
|
|
5 |
use Exception; |
|
6 |
use Illuminate\Contracts\Validation\Validator; |
|
7 |
|
|
8 |
class ValidationException extends Exception implements RendersErrorsExtensions |
|
9 |
{
|
|
10 |
const CATEGORY = 'validation'; |
|
11 |
|
|
12 |
/**
|
|
13 |
* @var \Illuminate\Contracts\Validation\Validator
|
|
14 |
*/
|
|
15 |
protected $validator; |
|
16 |
|
|
17 | 1 |
public function __construct(string $message, Validator $validator) |
18 |
{
|
|
19 | 1 |
parent::__construct($message); |
20 |
|
|
21 | 1 |
$this->validator = $validator; |
22 |
}
|
|
23 |
|
|
24 | 1 |
public function isClientSafe(): bool |
25 |
{
|
|
26 | 1 |
return true; |
27 |
}
|
|
28 |
|
|
29 | 1 |
public function getCategory(): string |
30 |
{
|
|
31 | 1 |
return self::CATEGORY; |
32 |
}
|
|
33 |
|
|
34 | 1 |
public function extensionsContent(): array |
35 |
{
|
|
36 |
return [ |
|
37 | 1 |
'validation' => $this->validator->errors()->messages(), |
38 |
];
|
|
39 |
}
|
|
40 |
}
|
Read our documentation on viewing source code .