# fluent-cart/1.6.4/app/Http/Requests/FrontendRequests/CustomerAddressRequest.php

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version 1.6.4. 80 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/1.6.4/code/app/Http/Requests/FrontendRequests/CustomerAddressRequest.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.6.4/raw/app/Http/Requests/FrontendRequests/CustomerAddressRequest.php
- Modified: 2026-01-20T13:25:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-cart/1.6.4/code/app/Http/Requests/FrontendRequests/CustomerAddressRequest.php#L10-L20`.

```php
<?php

namespace FluentCart\App\Http\Requests\FrontendRequests;

use FluentCart\App\App;
use FluentCart\App\Services\Localization\LocalizationManager;
use FluentCart\Framework\Foundation\RequestGuard;
use FluentCart\Framework\Support\Arr;

class CustomerAddressRequest extends RequestGuard
{

    /**
     * @return array
     */
    public function rules()
    {
        $data = $this->all();
        $type = $this->get('type') . '_';
        $prefix = $type === 'billing_' ? 'billing' : 'shipping';
        $rules = App::localization()->getValidationRule($data, $prefix);

        return array_merge($rules, [
            'type'              => 'required|sanitizeText',
            $type . 'label'     => 'required|sanitizeText|maxLength:15',
            $type . 'name'      => 'nullable|sanitizeText|maxLength:255',
            $type . 'address_1' => 'required|sanitizeText',
            $type . 'address_2' => 'nullable|sanitizeText',
            $type . 'city'      => 'required|sanitizeText|maxLength:255',
        ]);
    }

    /**
     * @return array
     */
    public function messages()
    {
        $type = $this->get('type') . '_';

        return [
            $type . 'address_1.required' => esc_html__('Street Address field is required.', 'fluent-cart'),
            $type . 'label.max'          => esc_html__('Label may not be greater than 15 characters.', 'fluent-cart'),
            $type . 'city.required'      => esc_html__('City field is required.', 'fluent-cart'),
            $type . 'state.required'     => esc_html__('State field is required.', 'fluent-cart'),
            $type . 'postcode.required'  => esc_html__('Postcode field is required.', 'fluent-cart'),
            $type . 'country.required'   => esc_html__('Country field is required.', 'fluent-cart'),
            $type . 'label.required'     => esc_html__('Label field is required.', 'fluent-cart')
        ];
    }

    /**
     * @return array
     */
    public function sanitize()
    {
        $type = $this->get('type') . '_';

        return [
            'type'              => 'sanitize_text_field',
            $type . 'status'    => 'sanitize_text_field',
            $type . 'label'     => 'sanitize_text_field',
            $type . 'name'      => 'sanitize_text_field',
            $type . 'address_1' => 'sanitize_text_field',
            $type . 'address_2' => 'sanitize_text_field',
            $type . 'city'      => 'sanitize_text_field',
            $type . 'state'     => 'sanitize_text_field',
            $type . 'phone'     => 'sanitize_text_field',
            $type . 'postcode'  => 'sanitize_text_field',
            $type . 'country'   => 'sanitize_text_field',
            $type . 'email'     => function ($value) {
                if(empty($value)) {
                    return '';
                }

                return sanitize_email($value);
            },
        ];
    }
}

```
