PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / app / Http / Requests / UpdateVendorIdsRequest.php

UpdateVendorIdsRequest.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Http/Requests/UpdateVendorIdsRequest.php

49 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Http\Requests;
4
5 use FluentCart\Framework\Foundation\RequestGuard;
6 use FluentCart\Framework\Support\Arr;
7
8 class UpdateVendorIdsRequest extends RequestGuard
9 {
10 public function beforeValidation()
11 {
12 return Arr::get($this->all(), 'data', []);
13 }
14
15 public function rules()
16 {
17 // Both ids are interpolated into gateway API paths (Stripe
18 // subscriptions/{id}, Mollie customers/{cid}/subscriptions/{id}), so the
19 // character set is constrained here rather than at each call site.
20 $format = function ($attribute, $value) {
21 if ($value && !preg_match('/^[a-zA-Z0-9_.-]+$/', $value)) {
22 return __('Vendor IDs may only contain letters, numbers, dots, dashes and underscores.', 'fluent-cart');
23 }
24 return null;
25 };
26
27 return [
28 'vendor_subscription_id' => ['nullable', 'sanitizeText', 'maxLength:45', 'validFormat' => $format],
29 'vendor_customer_id' => ['nullable', 'sanitizeText', 'maxLength:45', 'validFormat' => $format],
30 ];
31 }
32
33 public function messages()
34 {
35 return [
36 'vendor_subscription_id.maxLength' => esc_html__('Vendor Subscription ID cannot be longer than 45 characters.', 'fluent-cart'),
37 'vendor_customer_id.maxLength' => esc_html__('Vendor Customer ID cannot be longer than 45 characters.', 'fluent-cart'),
38 ];
39 }
40
41 public function sanitize()
42 {
43 return [
44 'vendor_subscription_id' => 'sanitize_text_field',
45 'vendor_customer_id' => 'sanitize_text_field',
46 ];
47 }
48 }
49