# fluent-cart/1.6.4/app/Modules/Shipping/Http/Requests/ShippingClassRequest.php

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

- Page: https://pluginprobe.com/plugins/fluent-cart/1.6.4/code/app/Modules/Shipping/Http/Requests/ShippingClassRequest.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.6.4/raw/app/Modules/Shipping/Http/Requests/ShippingClassRequest.php
- Modified: 2026-04-20T13:45:50+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/Modules/Shipping/Http/Requests/ShippingClassRequest.php#L10-L20`.

```php
<?php

namespace FluentCart\App\Modules\Shipping\Http\Requests;

use FluentCart\Framework\Foundation\RequestGuard;
use FluentCart\Framework\Support\Arr;

class ShippingClassRequest extends RequestGuard
{

    public function beforeValidation()
    {
        $data = $this->all();

        $data['per_item'] = (string)(Arr::get($data, 'per_item', 0)) === '1' ? 1 : 0;
        return $data;
    }

    /**
     * @return array
     */
    public function rules()
    {
        return [
            'name'        => 'required|string|maxLength:192',
            'description' => 'nullable|string|maxLength:500',
            'cost'        => 'required|numeric|min:0',
            'type'        => 'required|string|in:fixed,percentage',
            'per_item'    => 'nullable|integer|in:0,1',
        ];
    }

    /**
     * @return array
     */
    public function messages()
    {
        return [
            'name.required' => esc_html__('Shipping class name is required.', 'fluent-cart'),
            'cost.required' => esc_html__('Shipping class cost is required.', 'fluent-cart'),
            'type.required' => esc_html__('Shipping class type is required.', 'fluent-cart')
        ];
    }

    /**
     * @return array
     */
    public function sanitize()
    {
        return [
            'name'        => 'sanitize_text_field',
            'description' => 'sanitize_textarea_field',
            'cost'        => 'sanitize_text_field',
            'type'        => 'sanitize_text_field',
            'per_item'    => 'intval'
        ];
    }

}

```
