v2board/app/Http/Requests/Admin/ServerTrojanSave.php

43 lines
1.2 KiB
PHP
Raw Normal View History

2019-10-29 15:33:36 +08:00
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
2020-06-11 20:47:02 +08:00
class ServerTrojanSave extends FormRequest
2019-10-29 15:33:36 +08:00
{
2020-02-10 15:51:01 +08:00
CONST RULES = [
'show' => '',
'name' => 'required',
'group_id' => 'required|array',
2020-06-11 20:47:02 +08:00
'host' => 'required|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
2020-02-10 15:51:01 +08:00
'port' => 'required',
2020-03-05 02:30:02 +08:00
'tags' => 'nullable|array',
2020-06-11 20:47:02 +08:00
'rate' => 'required|numeric'
2020-02-10 15:51:01 +08:00
];
2019-10-29 15:33:36 +08:00
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
2020-02-10 15:51:01 +08:00
return self::RULES;
2019-10-29 15:33:36 +08:00
}
2020-01-11 13:36:52 +08:00
2019-10-29 15:33:36 +08:00
public function messages()
{
return [
'name.required' => '节点名称不能为空',
2020-01-11 13:36:52 +08:00
'group_id.required' => '权限组不能为空',
2019-10-29 15:33:36 +08:00
'group_id.array' => '权限组格式不正确',
'host.required' => '节点地址不能为空',
2020-06-11 20:47:02 +08:00
'host.regex' => '节点地址必须为域名',
2019-10-29 15:33:36 +08:00
'port.required' => '连接端口不能为空',
'tags.array' => '标签格式不正确',
'rate.required' => '倍率不能为空',
2020-06-11 20:47:02 +08:00
'rate.numeric' => '倍率格式不正确'
2019-10-29 15:33:36 +08:00
];
}
}