| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace App\Module\Farm\Validations;
- use App\Module\Farm\Validators\GodActivationValidator;
- use UCore\ValidationCore;
- /**
- * 神像激活验证类
- *
- * 用于验证神像激活操作的输入数据,包括用户ID、神像ID和物品ID
- */
- class GodActivationValidation extends ValidationCore
- {
- /**
- * 验证规则
- *
- * @param array $rules 自定义规则
- * @return array
- */
- public function rules($rules = []): array
- {
- return [
- [
- 'user_id,god_id,item_id', 'required'
- ],
- [
- 'user_id,god_id,item_id', 'integer', 'min' => 1,
- 'msg' => '{attr}必须是大于0的整数'
- ],
- // 验证神像激活相关逻辑
- [
- 'god_id', new GodActivationValidator($this, ['user_id', 'item_id']),
- 'msg' => '神像激活验证失败'
- ]
- ];
- }
- /**
- * 设置默认值
- *
- * @return array
- */
- public function default(): array
- {
- return [];
- }
- }
|