← All changes
|
app/Modules/Form/Settings/Validator/Confirmations.php
+12
-12
3.6.41
→
6.2.15
View file →
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentForm\App\Modules\Form\Settings\Validator; |
| 4 | 4 | |
| 5 | -use FluentValidator\Validator as FluentValidator; | |
| 5 | +use FluentForm\Framework\Validator\Validator; | |
| 6 | 6 | |
| 7 | 7 | class Confirmations |
| 8 | 8 | { |
| 9 | 9 | /** |
| @@ -18,9 +18,9 @@ | ||
| 18 | 18 | // Prepare the validation rules & messages. |
| 19 | 19 | list($rules, $messages) = static::validations(); |
| 20 | 20 | |
| 21 | 21 | // Make validator instance. |
| 22 | - $validator = FluentValidator::make($data, $rules, $messages); | |
| 22 | + $validator = wpFluentForm('validator')->make($data, $rules, $messages); | |
| 23 | 23 | |
| 24 | 24 | // Add conditional validations if there's any. |
| 25 | 25 | $validator = static::conditionalValidations($validator); |
| 26 | 26 | |
| @@ -26,9 +26,9 @@ | ||
| 26 | 26 | |
| 27 | 27 | // Validate and process response. |
| 28 | 28 | if ($validator->validate()->fails()) { |
| 29 | 29 | wp_send_json_error([ |
| 30 | - 'errors' => $validator->errors() | |
| 30 | + 'errors' => $validator->errors(), | |
| 31 | 31 | ], 422); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | return true; |
| @@ -44,16 +44,16 @@ | ||
| 44 | 44 | return [ |
| 45 | 45 | [ |
| 46 | 46 | 'redirectTo' => 'required', |
| 47 | 47 | 'customPage' => 'required_if:redirectTo,customPage', |
| 48 | - 'customUrl' => 'required_if:redirectTo,customUrl', | |
| 48 | + 'customUrl' => 'required_if:redirectTo,customUrl', | |
| 49 | 49 | ], |
| 50 | 50 | [ |
| 51 | - 'redirectTo.required' => __('The Confirmation Type field is required.', 'fluentform'), | |
| 51 | + 'redirectTo.required' => __('The Confirmation Type field is required.', 'fluentform'), | |
| 52 | 52 | 'customPage.required_if' => __('The Page field is required when Confirmation Type is Page.', 'fluentform'), |
| 53 | - 'customUrl.required_if' => __('The Redirect URL field is required when Confirmation Type is Redirect.', 'fluentform'), | |
| 54 | - 'customUrl.required' => __('The Redirect URL format is invalid.', 'fluentform'), | |
| 55 | - ] | |
| 53 | + 'customUrl.required_if' => __('The Redirect URL field is required when Confirmation Type is Redirect.', 'fluentform'), | |
| 54 | + 'customUrl.required' => __('The Redirect URL format is invalid.', 'fluentform'), | |
| 55 | + ], | |
| 56 | 56 | ]; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| @@ -58,16 +58,16 @@ | ||
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * Add conditional validations to the validator. |
| 61 | 61 | * |
| 62 | - * @param FluentValidator $validator | |
| 62 | + * @param \FluentForm\Framework\Validator\Validator $validator | |
| 63 | 63 | * |
| 64 | - * @return FluentValidator | |
| 64 | + * @return \FluentForm\Framework\Validator\Validator | |
| 65 | 65 | */ |
| 66 | - public static function conditionalValidations(FluentValidator $validator) | |
| 66 | + public static function conditionalValidations(Validator $validator) | |
| 67 | 67 | { |
| 68 | 68 | $validator->sometimes('customUrl', 'required', function ($input) { |
| 69 | - return $input['redirectTo'] === 'customUrl'; | |
| 69 | + return 'customUrl' === $input['redirectTo']; | |
| 70 | 70 | }); |
| 71 | 71 | |
| 72 | 72 | return $validator; |
| 73 | 73 | } |