PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.13
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.13
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Services / Settings / Validator / Confirmations.php

Confirmations.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.13, at app/Services/Settings/Validator/Confirmations.php

47 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Services\Settings\Validator;
4
5 use FluentForm\Framework\Validator\Validator;
6
7 class Confirmations extends Validate
8 {
9 /**
10 * Produce the necessary validation rules and corresponding messages
11 *
12 * @return array
13 */
14 public static function validations()
15 {
16 return [
17 [
18 'redirectTo' => 'required',
19 'customPage' => 'required_if:redirectTo,customPage',
20 'customUrl' => 'required_if:redirectTo,customUrl',
21 ],
22 [
23 'redirectTo.required' => __('The Confirmation Type field is required.', 'fluentform'),
24 'customPage.required_if' => __('The Page field is required when Confirmation Type is Page.', 'fluentform'),
25 'customUrl.required_if' => __('The Redirect URL field is required when Confirmation Type is Redirect.', 'fluentform'),
26 'customUrl.required' => __('The Redirect URL format is invalid.', 'fluentform'),
27 ],
28 ];
29 }
30
31 /**
32 * Add conditional validations to the validator.
33 *
34 * @param \FluentForm\Framework\Validator\Validator $validator
35 *
36 * @return \FluentForm\Framework\Validator\Validator
37 */
38 public static function conditionalValidations(Validator $validator)
39 {
40 $validator->sometimes('customUrl', 'required', function ($input) {
41 return isset($input['redirectTo']) && 'customUrl' === $input['redirectTo'];
42 });
43
44 return $validator;
45 }
46 }
47