ConfigUpdateRequest.php 1.43 KB
<?php

namespace App\Http\Container\AdminSection\Requests\System;

use Hikoon\LaravelApi\Support\ApiRequest;

class ConfigUpdateRequest extends ApiRequest
{
    /**
     * @return array<string,mixed>
     */
    public function rules(): array
    {
        return [
            'name'        => 'required|string|between:0,100',
            'expand.type' => 'required|string',
            'content'     => 'max:1000',
            'remark'      => 'nullable|max:400',
            'status'      => 'required|in:0,1',
            'weight'      => 'required|digits_between:0,200|integer'
        ];
    }

    /**
     * @return array<string,string>
     */
    public function messages(): array
    {
        return [
            'name.required'           => '请输入名称',
            'expand.type.required'    => '请选择内容格式',
            'content.required_unless' => '请输入内容',
            'content.max'             => '内容超出长度限制',
            'remark.required'         => '请输入备注',
            'remark.max'              => '备注超过长度限制',
            'status.required'         => '请选择状态',
            'status.in'               => '选择的状态值不在指定范围内',
            'weight.required'         => '请输入权重值',
            'weight.integer'          => '权重值应为整数值',
            'weight.digits_between'   => '权重值应在0~200之间'
        ];
    }
}