<?php
namespace EasyRestaurantManager\Http\Requests;

class StoreCategoryRequest extends RequestGuard {
    
    /**
     * Define validation rules
     */
    public function rules() {
        return [
            'name' => 'required|string|max:255',
            'description' => 'nullable|string|max:500',
            'branch_id' => 'required|integer',
            'image' => 'string',
        ];
    }

    /**
     * Define custom validation messages
     */
    public function messages() {
        return [
            'name.required' => esc_html__('Category name is required.', 'easy-restaurant-manager'),
            'name.string' => esc_html__('Category name must be a string.', 'easy-restaurant-manager'),
            'name.max' => esc_html__('Category name must not exceed 255 characters.', 'easy-restaurant-manager'),
            'description.string' => esc_html__('Description must be a string.', 'easy-restaurant-manager'),
            'description.max' => esc_html__('Description must not exceed 500 characters.', 'easy-restaurant-manager'),
            'branch_id.required' => esc_html__('Branch id is required.', 'easy-restaurant-manager'),
            'branch_id.integer' => esc_html__('Branch id must be an integer.', 'easy-restaurant-manager'),
        ];
    }

    /**
     * Define sanitization rules
     */
    public function sanitize() {
        return [
            'name' => 'sanitize_text_field',
            'description' => 'wp_kses_post',
            'branch_id' => 'sanitize_text_field',
            'image' => 'sanitize_text_field',
        ];
    }
}
