PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.7
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.7
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 / Notifications.php

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

65 lines 2.0 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\Helpers\ArrayHelper;
6 use FluentForm\Framework\Validator\Validator;
7
8 class Notifications extends Validate
9 {
10 /**
11 * Produce the necessary validation rules and corresponding messages
12 *
13 * @return array
14 */
15 public static function validations()
16 {
17 return [
18 [
19 'sendTo.type' => 'required',
20 'sendTo.email' => 'required_if:sendTo.type,email',
21 'sendTo.field' => 'required_if:sendTo.type,field',
22 'sendTo.routing' => 'required_if:sendTo.type,routing',
23 'subject' => 'required',
24 'message' => 'required',
25 ],
26 [
27 'sendTo.type.required' => 'The Send To field is required.',
28 'sendTo.email.required_if' => 'The Send to Email field is required.',
29 'sendTo.field.required_if' => 'The Send to Field field is required.',
30 'sendTo.routing' => 'Please fill all the routing rules above.',
31 ],
32 ];
33 }
34
35 /**
36 * Add conditional validations to the validator.
37 *
38 * @param \FluentForm\Framework\Validator\Validator $validator
39 *
40 * @return \FluentForm\Framework\Validator\Validator
41 */
42 public static function conditionalValidations(Validator $validator)
43 {
44 $validator->sometimes('sendTo.routing', 'required', function ($input) {
45 if ('routing' !== ArrayHelper::get($input, 'sendTo.type')) {
46 return false;
47 }
48
49 $routingInputs = ArrayHelper::get($input, 'sendTo.routing');
50 $required = false;
51
52 foreach ($routingInputs as $routingInput) {
53 if (!$routingInput['input_value'] || !$routingInput['field']) {
54 $required = true;
55 break;
56 }
57 }
58
59 return $required;
60 });
61
62 return $validator;
63 }
64 }
65