SendVerifyCodeRequest.php 874 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Http\Requests\Coach;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. /**
  5. * 发送验证码请求验证
  6. */
  7. class SendVerifyCodeRequest extends FormRequest
  8. {
  9. public function rules(): array
  10. {
  11. return [
  12. 'mobile' => [
  13. 'required',
  14. 'string',
  15. 'size:11',
  16. 'regex:/^1[3-9]\d{9}$/',
  17. ],
  18. 'type' => 'required|string|in:update', // 验证码类型(update:修改手机号)
  19. ];
  20. }
  21. public function messages(): array
  22. {
  23. return [
  24. 'mobile.required' => '手机号不能为空',
  25. 'mobile.size' => '手机号必须是11位',
  26. 'mobile.regex' => '手机号格式不正确',
  27. 'type.required' => '验证码类型不能为空',
  28. 'type.in' => '验证码类型无效',
  29. ];
  30. }
  31. }