public function validateChangeLayoutType(Layout $layout, LayoutTypeInterface $targetLayoutType, array $zoneMappings, bool $preserveSharedZones = true): void
    {
        $seenZones = [];
        foreach ($zoneMappings as $newZone => $oldZones) {
            if (!$targetLayoutType->hasZone($newZone)) {
                throw ValidationException::validationFailed(
                    'zoneMappings',
                    sprintf(
                        'Zone "%s" does not exist in "%s" layout type.',
                        $newZone,
                        $targetLayoutType->getIdentifier()
                    )
                );
            }

            if (!is_array($oldZones)) {
                throw ValidationException::validationFailed(
                    'zoneMappings',
                    sprintf(
                        'The list of mapped zones for "%s" zone must be an array.',
                        $newZone
                    )
                );
            }

            $oldLayoutZones = [];

            foreach ($oldZones as $oldZone) {
                if (in_array($oldZone, $seenZones, true)) {
                    throw ValidationException::validationFailed(
                        'zoneMappings',
                        sprintf(
                            'Zone "%s" is specified more than once.',
                            $oldZone
                        )
                    );
                }

                $seenZones[] = $oldZone;
                $oldLayoutZones[] = $layout->getZone($oldZone);
            }

            if ($preserveSharedZones && count($oldLayoutZones) > 1) {
                foreach ($oldLayoutZones as $oldZone) {
                    if ($oldZone->getLinkedZone() instanceof Zone) {
                        throw ValidationException::validationFailed(
                            'zoneMappings',
                            sprintf(
                                'When preserving shared layout zones, mapping for zone "%s" needs to be 1:1.',
                                $newZone
                            )
                        );
                    }
                }
            }
        }
    }