1, 'msg' => '{attr}必须是大于0的整数' ], // 验证宠物是否存在 [ 'pet_id', new PetExistsValidator($this), 'msg' => '宠物不存在或不属于当前用户' ], // 验证宠物状态是否正常 [ 'pet_id', new PetStatusValidator($this, [PetStatus::NORMAL]), 'msg' => '宠物状态不允许喂食' ], // 验证物品是否为宠物口粮 [ 'item_id', new PetFoodValidator($this), 'msg' => '该物品不是宠物口粮' ] ]; } /** * 设置默认值 * * @return array */ public function default(): array { return [ 'num' => 1 ]; } }