| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Http\Requests; |
| 4 |
|
| 5 |
use FluentCart\Framework\Foundation\RequestGuard; |
| 6 |
|
| 7 |
class EmailSettingsRequest extends RequestGuard |
| 8 |
{ |
| 9 |
public function rules(): array |
| 10 |
{ |
| 11 |
return [ |
| 12 |
'from_name' => 'required|sanitizeText|maxLength:255', |
| 13 |
'from_email' => 'required|email|maxLength:255', |
| 14 |
'reply_to_name' => 'nullable|sanitizeText|maxLength:255', |
| 15 |
'reply_to_email' => 'nullable|email|maxLength:255', |
| 16 |
'email_footer' => 'nullable|string', |
| 17 |
'admin_email' => 'required|string', |
| 18 |
'show_email_footer' => 'nullable|string', |
| 19 |
]; |
| 20 |
} |
| 21 |
|
| 22 |
public function messages(): array |
| 23 |
{ |
| 24 |
return [ |
| 25 |
'from_name.required' => __('From Name field is required.', 'fluent-cart'), |
| 26 |
'from_email.required' => __('From Email field is required.', 'fluent-cart'), |
| 27 |
'from_email.email' => __('From Email must be a valid email address.', 'fluent-cart'), |
| 28 |
'reply_to_email.email' => __('Reply To Email must be a valid email address.', 'fluent-cart'), |
| 29 |
'admin_email.required' => __('Admin Email field is required.', 'fluent-cart') |
| 30 |
]; |
| 31 |
} |
| 32 |
|
| 33 |
public function sanitize(): array |
| 34 |
{ |
| 35 |
return [ |
| 36 |
'from_name' => 'sanitize_text_field', |
| 37 |
'from_email' => function ($value) { |
| 38 |
if(empty($value)) { |
| 39 |
return ''; |
| 40 |
} |
| 41 |
|
| 42 |
return sanitize_email($value); |
| 43 |
}, |
| 44 |
'reply_to_name' => 'sanitize_text_field', |
| 45 |
'reply_to_email' => function ($value) { |
| 46 |
if(empty($value)) { |
| 47 |
return ''; |
| 48 |
} |
| 49 |
|
| 50 |
return sanitize_email($value); |
| 51 |
}, |
| 52 |
'email_footer' => 'wp_kses_post', |
| 53 |
'admin_email' => 'sanitize_text_field', |
| 54 |
'show_email_footer' => 'sanitize_text_field', |
| 55 |
]; |
| 56 |
} |
| 57 |
} |
| 58 |
|