@@ 12-28 (lines=17) @@ | ||
9 | use Albert221\Validation\Verdict; |
|
10 | use Albert221\Validation\VerdictInterface; |
|
11 | ||
12 | class EmailValidator extends RuleValidator |
|
13 | { |
|
14 | /** |
|
15 | * {@inheritdoc} |
|
16 | */ |
|
17 | public function verdict($value, Rule $rule): VerdictInterface |
|
18 | { |
|
19 | if (is_null($value)) { |
|
20 | return Verdict::create(true, $rule); |
|
21 | } |
|
22 | ||
23 | return Verdict::create( |
|
24 | (bool) filter_var($value, FILTER_VALIDATE_EMAIL), |
|
25 | $rule |
|
26 | ); |
|
27 | } |
|
28 | } |
|
29 |
@@ 12-25 (lines=14) @@ | ||
9 | use Albert221\Validation\Verdict; |
|
10 | use Albert221\Validation\VerdictInterface; |
|
11 | ||
12 | class RequiredValidator extends RuleValidator |
|
13 | { |
|
14 | /** |
|
15 | * {@inheritdoc} |
|
16 | */ |
|
17 | public function verdict($value, Rule $rule): VerdictInterface |
|
18 | { |
|
19 | if (null !== $value) { |
|
20 | return Verdict::create(true, $rule); |
|
21 | } |
|
22 | ||
23 | return Verdict::create(false, $rule); |
|
24 | } |
|
25 | } |
|
26 |