52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Request;
|
|
|
|
use App\Constants\HttpEnumCode;
|
|
use Hyperf\Validation\Request\FormRequest;
|
|
|
|
class ArticleRequest extends FormRequest
|
|
{
|
|
protected array $scenes = [
|
|
'getArticleScienceList' => [
|
|
'keyword',
|
|
'is_top',
|
|
'source_id',
|
|
'basic_class_id',
|
|
],
|
|
];
|
|
|
|
/**
|
|
* 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 [
|
|
'is_top' => ['sometimes','numeric','min:0','max:1'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 获取已定义验证规则的错误消息.
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'is_top.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'is_top.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'is_top.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
'is_top.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
|
];
|
|
}
|
|
}
|