ServerShadowsocksSave.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App\Http\Requests\Admin;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class ServerShadowsocksSave extends FormRequest
  5. {
  6. /**
  7. * Get the validation rules that apply to the request.
  8. *
  9. * @return array
  10. */
  11. public function rules()
  12. {
  13. return [
  14. 'show' => '',
  15. 'name' => 'required',
  16. 'group_id' => 'required|array',
  17. 'parent_id' => 'nullable|integer',
  18. 'route_id' => 'nullable|array',
  19. 'host' => 'required',
  20. 'port' => 'required',
  21. 'server_port' => 'required',
  22. 'cipher' => 'required|in:aes-128-gcm,aes-192-gcm,aes-256-gcm,chacha20-ietf-poly1305,2022-blake3-aes-128-gcm,2022-blake3-aes-256-gcm',
  23. 'obfs' => 'nullable|in:http',
  24. 'obfs_settings' => 'nullable|array',
  25. 'tags' => 'nullable|array',
  26. 'rate' => 'required|numeric'
  27. ];
  28. }
  29. public function messages()
  30. {
  31. return [
  32. 'name.required' => '节点名称不能为空',
  33. 'group_id.required' => '权限组不能为空',
  34. 'group_id.array' => '权限组格式不正确',
  35. 'route_id.array' => '路由组格式不正确',
  36. 'parent_id.integer' => '父节点格式不正确',
  37. 'host.required' => '节点地址不能为空',
  38. 'port.required' => '连接端口不能为空',
  39. 'server_port.required' => '后端服务端口不能为空',
  40. 'cipher.required' => '加密方式不能为空',
  41. 'tags.array' => '标签格式不正确',
  42. 'rate.required' => '倍率不能为空',
  43. 'rate.numeric' => '倍率格式不正确',
  44. 'obfs.in' => '混淆格式不正确',
  45. 'obfs_settings.array' => '混淆设置格式不正确'
  46. ];
  47. }
  48. }