LoginRequest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Http\Requests\Admin;
  3. use App\Models\User;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. use Illuminate\Validation\Rules;
  6. class LoginRequest extends FormRequest
  7. {
  8. /**
  9. * Determine if the user is authorized to make this request.
  10. */
  11. public function authorize(): bool
  12. {
  13. return true;
  14. }
  15. /**
  16. * Get the validation rules that apply to the request.
  17. *
  18. * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
  19. */
  20. public function rules(): array
  21. {
  22. return [
  23. 'username' => ['required', 'string', 'lowercase', 'max:255'],
  24. 'password' => ['required']
  25. // 'password' => ['required', 'regex:/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!$%@#£€*?&]{6,}$/']
  26. // 'password' => ['required', Rules\Password::defaults()]
  27. ];
  28. }
  29. public function messages(): array
  30. {
  31. return [
  32. 'username.required' => '请输入用户名',
  33. 'password.required' => '请输入密码',
  34. ];
  35. }
  36. }