TransferOutValidation.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Module\Transfer\Validations;
  3. use UCore\ValidationCore;
  4. /**
  5. * 转出验证类
  6. */
  7. class TransferOutValidation extends ValidationCore
  8. {
  9. /** @var \App\Module\Transfer\Models\TransferApp|null 转账应用对象,由验证器设置 */
  10. public ?\App\Module\Transfer\Models\TransferApp $transfer_app = null;
  11. /** @var bool 是否跳过密码验证(用于第三方应用) */
  12. public bool $skip_password_validation = false;
  13. /**
  14. * 验证规则
  15. */
  16. public function rules($rules = []): array
  17. {
  18. return [
  19. // 基础验证
  20. ['transfer_app_id,user_id', 'required'],
  21. ['transfer_app_id,user_id', 'integer', 'min' => 1],
  22. ['amount', 'required'],
  23. ['amount', 'float', 'min' => 10, 'max' => 10000000], // 限制最大金额为1000万,防止异常大金额
  24. ['password', 'required', 'string', 'min' => 6],
  25. ['google_code', 'string', 'size' => 6],
  26. ['out_user_id', 'string', 'max' => 50],
  27. ['remark', 'string', 'max' => 255],
  28. ['callback_data', 'array'],
  29. ];
  30. }
  31. /**
  32. * 默认值
  33. */
  34. public function default(): array
  35. {
  36. return [];
  37. }
  38. }