Concerns
3 years ago
Contracts
3 years ago
Exceptions
3 years ago
Rules
3 years ago
Config.php
3 years ago
ServiceProvider.php
3 years ago
ValidationRuleSet.php
3 years ago
ValidationRulesRegistrar.php
3 years ago
Validator.php
3 years ago
ServiceProvider.php
53 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * |
| 5 | * Modified by impress-org on 27-April-2023 using Strauss. |
| 6 | * @see https://github.com/BrianHenryIE/strauss |
| 7 | */ |
| 8 | |
| 9 | declare(strict_types=1); |
| 10 | |
| 11 | namespace Give\Vendors\StellarWP\Validation; |
| 12 | |
| 13 | use Give\Vendors\StellarWP\Validation\Rules\Currency; |
| 14 | use Give\Vendors\StellarWP\Validation\Rules\Email; |
| 15 | use Give\Vendors\StellarWP\Validation\Rules\Integer; |
| 16 | use Give\Vendors\StellarWP\Validation\Rules\Max; |
| 17 | use Give\Vendors\StellarWP\Validation\Rules\Min; |
| 18 | use Give\Vendors\StellarWP\Validation\Rules\Numeric; |
| 19 | use Give\Vendors\StellarWP\Validation\Rules\Required; |
| 20 | use Give\Vendors\StellarWP\Validation\Rules\Size; |
| 21 | |
| 22 | class ServiceProvider |
| 23 | { |
| 24 | private $validationRules = [ |
| 25 | Required::class, |
| 26 | Min::class, |
| 27 | Max::class, |
| 28 | Size::class, |
| 29 | Numeric::class, |
| 30 | Integer::class, |
| 31 | Email::class, |
| 32 | Currency::class, |
| 33 | ]; |
| 34 | |
| 35 | /** |
| 36 | * Registers the validation rules registrar with the container |
| 37 | */ |
| 38 | public function register() |
| 39 | { |
| 40 | Config::getServiceContainer()->singleton(ValidationRulesRegistrar::class, function () { |
| 41 | $register = new ValidationRulesRegistrar(); |
| 42 | |
| 43 | foreach ($this->validationRules as $rule) { |
| 44 | $register->register($rule); |
| 45 | } |
| 46 | |
| 47 | do_action(Config::getHookPrefix() . 'register_validation_rules', $register); |
| 48 | |
| 49 | return $register; |
| 50 | }); |
| 51 | } |
| 52 | } |
| 53 |