You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
974 B

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Request;
  4. use Hyperf\Validation\Request\FormRequest;
  5. class ImageBase64Request extends FormRequest
  6. {
  7. /**
  8. * Determine if the user is authorized to make this request.
  9. */
  10. public function authorize(): bool
  11. {
  12. return true;
  13. }
  14. /**
  15. * Get the validation rules that apply to the request.
  16. */
  17. public function rules(): array
  18. {
  19. return [
  20. 'upload' => 'required|nonempty|base64:image',
  21. 'type' => 'nonempty|alpha'
  22. ];
  23. }
  24. public function messages(): array
  25. {
  26. return [
  27. 'upload.required' => '未选择上传的文件',
  28. 'upload.base64' => '文件不是正常的图片',
  29. 'upload.nonempty' => '文件异常',
  30. 'type.nonempty' => '图片类型参数异常',
  31. ];
  32. }
  33. public function attributes(): array
  34. {
  35. return [
  36. 'upload' => '图片'
  37. ];
  38. }
  39. }