1, 'msg' => '{attr}必须是大于0的整数' ], [ 'item_instance_id', 'integer', 'min' => 0, 'msg' => '{attr}必须是大于等于0的整数' ], // 验证土地是否属于用户 [ 'land_id', new LandOwnershipValidator($this, ['user_id', 'land']), 'msg' => '土地不存在或不属于当前用户' ], // 验证土地状态是否允许种植 [ 'land_id', new LandStatusValidator($this, ['land']), 'msg' => '土地状态不允许种植' ], // 验证物品是否为种子类型 [ 'item_id', new SeedItemValidator($this, ['seed_item']), 'msg' => '物品不是种子类型' ], // 验证用户是否拥有该种子 [ 'item_id', new SeedOwnershipValidator($this, ['user_id', 'item_instance_id']), 'msg' => '您没有该种子' ] ]; } /** * 设置默认值 * * @return array */ public function default(): array { return [ 'item_instance_id' => 0 ]; } }