UpdateBasicInfoRequest.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Http\Requests\Coach;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. /**
  5. * 技师基础信息更新请求验证
  6. */
  7. class UpdateBasicInfoRequest extends FormRequest
  8. {
  9. public function rules(): array
  10. {
  11. return [
  12. 'nickname' => 'nullable|string|min:2|max:20',
  13. 'gender' => 'nullable|integer|in:1,2',
  14. 'mobile' => [
  15. 'nullable',
  16. 'string',
  17. 'size:11',
  18. 'regex:/^1[3-9]\d{9}$/',
  19. ],
  20. ];
  21. }
  22. public function messages(): array
  23. {
  24. return [
  25. 'nickname.string' => '昵称必须是字符串',
  26. 'nickname.min' => '昵称不能少于2个字符',
  27. 'nickname.max' => '昵称不能超过20个字符',
  28. 'gender.integer' => '性别必须是整数',
  29. 'gender.in' => '性别只能是1(男)或2(女)',
  30. 'mobile.size' => '手机号必须是11位',
  31. 'mobile.regex' => '手机号格式不正确',
  32. ];
  33. }
  34. }