You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
965 B
46 lines
965 B
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Request;
|
|
|
|
use Hyperf\Validation\Request\FormRequest;
|
|
|
|
class ImageRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'upload' => 'required|nonempty|file|image',
|
|
'type' => 'nonempty|alpha'
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'upload.required' => '未选择上传的文件',
|
|
'upload.image' => '文件不是正常的图片',
|
|
'upload.nonempty' => '文件异常',
|
|
'type.nonempty' => '图片类型参数异常',
|
|
];
|
|
}
|
|
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'upload' => '图片'
|
|
];
|
|
}
|
|
}
|