1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<?php
declare(strict_types=1);
namespace StellarWP\Validation;
use StellarWP\Validation\Rules\Boolean; use StellarWP\Validation\Rules\Currency; use StellarWP\Validation\Rules\DateTime; use StellarWP\Validation\Rules\Email; use StellarWP\Validation\Rules\Exclude; use StellarWP\Validation\Rules\ExcludeIf; use StellarWP\Validation\Rules\ExcludeUnless; use StellarWP\Validation\Rules\In; use StellarWP\Validation\Rules\InStrict; use StellarWP\Validation\Rules\Integer; use StellarWP\Validation\Rules\Max; use StellarWP\Validation\Rules\Min; use StellarWP\Validation\Rules\Nullable; use StellarWP\Validation\Rules\NullableIf; use StellarWP\Validation\Rules\NullableUnless; use StellarWP\Validation\Rules\Numeric; use StellarWP\Validation\Rules\Optional; use StellarWP\Validation\Rules\OptionalIf; use StellarWP\Validation\Rules\OptionalUnless; use StellarWP\Validation\Rules\Required; use StellarWP\Validation\Rules\Size;
class ServiceProvider { private $validationRules = [ Required::class, Min::class, Max::class, Size::class, Numeric::class, In::class, InStrict::class, Integer::class, Email::class, Currency::class, Exclude::class, ExcludeIf::class, ExcludeUnless::class, Nullable::class, NullableIf::class, NullableUnless::class, Optional::class, OptionalIf::class, OptionalUnless::class, DateTime::class, Boolean::class, ];
/** * Registers the validation rules registrar with the container */ public function register() { Config::getServiceContainer()->singleton(ValidationRulesRegistrar::class, function () { $register = new ValidationRulesRegistrar();
foreach ($this->validationRules as $rule) { $register->register($rule); }
do_action(Config::getHookPrefix() . 'register_validation_rules', $register);
return $register; }); } }
|