1, 'msg' => '{attr}必须是大于0的整数' ], [ 'instance_id', 'integer', 'min' => 0, 'msg' => '{attr}必须是大于等于0的整数' ], // 验证物品是否为宝箱类型 [ 'item_id', new ChestItemValidator($this, ['chest_item']), 'msg' => '物品验证失败' ], // 验证用户是否拥有该宝箱 [ 'item_id', new ChestOwnershipValidator($this, ['user_id', 'instance_id']), 'msg' => '宝箱不存在或不属于当前用户' ], // 验证开启消耗是否充足 [ 'item_id', new ChestConsumeValidator($this, ['user_id', 'quantity']), 'msg' => '开启消耗不足' ] ]; } /** * 设置默认值 * * @return array */ public function default(): array { return [ 'instance_id' => 0, 'quantity' => 1 ]; } }