Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 |
<?php
|
|
2 |
|
|
3 |
namespace Nuwave\Lighthouse\Validation; |
|
4 |
|
|
5 |
use Illuminate\Support\Arr; |
|
6 |
use Nuwave\Lighthouse\Execution\Arguments\ArgumentSet; |
|
7 |
use Nuwave\Lighthouse\Support\Contracts\ArgumentSetValidation; |
|
8 |
|
|
9 |
abstract class Validator implements ArgumentSetValidation |
|
10 |
{
|
|
11 |
/**
|
|
12 |
* The slice of incoming arguments to validate.
|
|
13 |
*
|
|
14 |
* @var \Nuwave\Lighthouse\Execution\Arguments\ArgumentSet
|
|
15 |
*/
|
|
16 |
protected $args; |
|
17 |
|
|
18 | 1 |
public function messages(): array |
19 |
{
|
|
20 | 1 |
return []; |
21 |
}
|
|
22 |
|
|
23 | 1 |
public function attributes(): array |
24 |
{
|
|
25 | 1 |
return []; |
26 |
}
|
|
27 |
|
|
28 |
/**
|
|
29 |
* Set the slice of args to validate.
|
|
30 |
*/
|
|
31 | 1 |
public function setArgs(ArgumentSet $args): void |
32 |
{
|
|
33 | 1 |
$this->args = $args; |
34 |
}
|
|
35 |
|
|
36 |
/**
|
|
37 |
* Retrieve the value of an argument.
|
|
38 |
*
|
|
39 |
* @param string $key The key of the argument, may use dot notation to get nested values.
|
|
40 |
* @param mixed|null $default Returned in case the argument is not present.
|
|
41 |
* @return mixed The value of the argument or the default.
|
|
42 |
*/
|
|
43 |
protected function arg(string $key, $default = null) |
|
44 |
{
|
|
45 |
return Arr::get( |
|
46 |
$this->args->toArray(), |
|
47 |
$key, |
|
48 |
$default
|
|
49 |
);
|
|
50 |
}
|
|
51 |
}
|
Read our documentation on viewing source code .