PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 1.2.4
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v1.2.4
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 3.6.66 All 195 releases
fluentform / app / Modules / Form / Settings / Validator / MailChimps.php

MailChimps.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 1.2.4, at app/Modules/Form/Settings/Validator/MailChimps.php

67 lines 1.7 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\Modules\Form\Settings\Validator;
4
5 use FluentValidator\Validator;
6
7 class MailChimps
8 {
9 /**
10 * Validates mailchimp feed settings data.
11 *
12 * @param array $data
13 *
14 * @return bool
15 */
16 public static function validate($data = [])
17 {
18 // Prepare the validation rules & messages.
19 list($rules, $messages) = static::validations();
20
21 // Make validator instance.
22 $validator = Validator::make($data, $rules, $messages);
23
24 // Add conditional validations if there's any.
25 $validator = static::conditionalValidations($validator);
26
27 // Validate and process response.
28 if ($validator->validate()->fails()) {
29 wp_send_json_error(['errors' => $validator->errors()], 423);
30 }
31
32 return true;
33 }
34
35 /**
36 * Produce the necessary validation rules and corresponding messages
37 *
38 * @return array
39 */
40 public static function validations()
41 {
42 return [
43 [
44 'name' => 'required',
45 'list' => 'required',
46 'fieldEmailAddress' => 'required',
47 ],
48 [
49 'name.required' => 'The Name field is required.',
50 'list.required' => 'The MailChimp List field is required.',
51 'fieldEmailAddress.required' => 'The Email Address field is required.',
52 ]
53 ];
54 }
55
56 /**
57 * Add conditional validations to the validator.
58 *
59 * @param \FluentValidator\Validator $validator
60 *
61 * @return \FluentValidator\Validator
62 */
63 public static function conditionalValidations(Validator $validator)
64 {
65 return $validator;
66 }
67 }