← All changes
|
app/Modules/Form/Settings/Validator/Notifications.php
+16
-16
3.6.41
→
6.2.14
View file →
| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace FluentForm\App\Modules\Form\Settings\Validator; |
| 4 | 4 | |
| 5 | 5 | use FluentForm\Framework\Helpers\ArrayHelper; |
| 6 | -use FluentValidator\Validator as FluentValidator; | |
| 6 | +use FluentForm\Framework\Validator\Validator; | |
| 7 | 7 | |
| 8 | 8 | class Notifications |
| 9 | 9 | { |
| 10 | 10 | /** |
| @@ -19,9 +19,9 @@ | ||
| 19 | 19 | // Prepare the validation rules & messages. |
| 20 | 20 | list($rules, $messages) = static::validations(); |
| 21 | 21 | |
| 22 | 22 | // Make validator instance. |
| 23 | - $validator = FluentValidator::make($data, $rules, $messages); | |
| 23 | + $validator = wpFluentForm('validator')->make($data, $rules, $messages); | |
| 24 | 24 | |
| 25 | 25 | // Add conditional validations if there's any. |
| 26 | 26 | $validator = static::conditionalValidations($validator); |
| 27 | 27 | |
| @@ -41,21 +41,21 @@ | ||
| 41 | 41 | public static function validations() |
| 42 | 42 | { |
| 43 | 43 | return [ |
| 44 | 44 | [ |
| 45 | - 'sendTo.type' => 'required', | |
| 46 | - 'sendTo.email' => 'required_if:sendTo.type,email', | |
| 47 | - 'sendTo.field' => 'required_if:sendTo.type,field', | |
| 45 | + 'sendTo.type' => 'required', | |
| 46 | + 'sendTo.email' => 'required_if:sendTo.type,email', | |
| 47 | + 'sendTo.field' => 'required_if:sendTo.type,field', | |
| 48 | 48 | 'sendTo.routing' => 'required_if:sendTo.type,routing', |
| 49 | - 'subject' => 'required', | |
| 50 | - 'message' => 'required', | |
| 49 | + 'subject' => 'required', | |
| 50 | + 'message' => 'required', | |
| 51 | 51 | ], |
| 52 | 52 | [ |
| 53 | - 'sendTo.type.required' => 'The Send To field is required.', | |
| 54 | - 'sendTo.email.required_if' => 'The Send to Email field is required.', | |
| 55 | - 'sendTo.field.required_if' => 'The Send to Field field is required.', | |
| 56 | - 'sendTo.routing' => 'Please fill all the routing rules above.', | |
| 57 | - ] | |
| 53 | + 'sendTo.type.required' => 'The Send To field is required.', | |
| 54 | + 'sendTo.email.required_if' => 'The Send to Email field is required.', | |
| 55 | + 'sendTo.field.required_if' => 'The Send to Field field is required.', | |
| 56 | + 'sendTo.routing' => 'Please fill all the routing rules above.', | |
| 57 | + ], | |
| 58 | 58 | ]; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| @@ -60,16 +60,16 @@ | ||
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Add conditional validations to the validator. |
| 63 | 63 | * |
| 64 | - * @param FluentValidator $validator | |
| 64 | + * @param \FluentForm\Framework\Validator\Validator $validator | |
| 65 | 65 | * |
| 66 | - * @return FluentValidator | |
| 66 | + * @return \FluentForm\Framework\Validator\Validator | |
| 67 | 67 | */ |
| 68 | - public static function conditionalValidations(FluentValidator $validator) | |
| 68 | + public static function conditionalValidations(Validator $validator) | |
| 69 | 69 | { |
| 70 | 70 | $validator->sometimes('sendTo.routing', 'required', function ($input) { |
| 71 | - if (ArrayHelper::get($input, 'sendTo.type') !== 'routing') { | |
| 71 | + if ('routing' !== ArrayHelper::get($input, 'sendTo.type')) { | |
| 72 | 72 | return false; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $routingInputs = ArrayHelper::get($input, 'sendTo.routing'); |