|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace FigTree\Validation\Tests\Dummies; |
|
4
|
|
|
|
|
5
|
|
|
use FigTree\Validation\AbstractFilter; |
|
6
|
|
|
|
|
7
|
|
|
class DummyFilter extends AbstractFilter |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @return \FigTree\Validation\RuleFactory |
|
11
|
|
|
*/ |
|
12
|
|
|
protected function rules() |
|
13
|
|
|
{ |
|
14
|
|
|
return $this->ruleFactory; |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function getRules(): array |
|
18
|
|
|
{ |
|
19
|
|
|
return [ |
|
20
|
|
|
'test_valid_bool' => $this->rules()->validBool(), |
|
21
|
|
|
'test_valid_domain' => $this->rules()->validDomain(), |
|
22
|
|
|
'test_valid_email' => $this->rules()->validEmail(), |
|
23
|
|
|
'test_valid_float' => $this->rules()->validFloat(-100, 100, 2), |
|
24
|
|
|
'test_valid_int' => $this->rules()->validInt(-100, 100), |
|
25
|
|
|
'test_valid_ip_address' => $this->rules()->validIpAddress(), |
|
26
|
|
|
'test_valid_mac_address' => $this->rules()->validMacAddress(), |
|
27
|
|
|
'test_valid_regexp' => $this->rules()->validRegExp('/^valid value$/i'), |
|
28
|
|
|
|
|
29
|
|
|
'test_add_slashes' => $this->rules()->addSlashes(), |
|
30
|
|
|
'test_clean_email' => $this->rules()->cleanEmail(), |
|
31
|
|
|
'test_clean_encoded' => $this->rules()->cleanEncodedString(), |
|
32
|
|
|
'test_clean_float' => $this->rules()->cleanFloat(), |
|
33
|
|
|
'test_clean_full_special_chars' => $this->rules()->cleanFullSpecialChars(), |
|
34
|
|
|
'test_clean_int' => $this->rules()->cleanInt(), |
|
35
|
|
|
'test_clean_special_chars' => $this->rules()->cleanSpecialChars(), |
|
36
|
|
|
'test_clean_string' => $this->rules()->cleanString(), |
|
37
|
|
|
'test_clean_unsafe' => $this->rules()->cleanUnsafe(), |
|
38
|
|
|
'test_clean_url' => $this->rules()->cleanUrl(), |
|
39
|
|
|
|
|
40
|
|
|
'test_callable' => $this->rules()->withCallable('trim'), |
|
41
|
|
|
'test_closure' => $this->rules()->withClosure($this->mult(2)), |
|
42
|
|
|
]; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function mult(int $factor) |
|
46
|
|
|
{ |
|
47
|
|
|
return fn ($value) => intval($value) * $factor; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|