public static function validateJson($json, $errorMessages = false)
    {
        if (is_string($json) && is_readable($json) && !is_dir($json)) {
            $json = json_decode((new File($json))->read(), true);
        }

        $errors = [];
        if (!is_array($json) || empty($json)) {
            $errors[] = __d('cms', 'Corrupt JSON information.');
        } else {
            if (!isset($json['type'])) {
                $errors[] = __d('cms', 'Missing field: "{0}"', 'type');
            }

            if (!isset($json['name'])) {
                $errors[] = __d('cms', 'Missing field: "{0}"', 'name');
            } elseif (!preg_match('/^(.+)\/(.+)+$/', $json['name'])) {
                $errors[] = __d('cms', 'Invalid field: "{0}" ({1}). It should be: {2}', 'name', $json['name'], '{author-name}/{package-name}');
            } elseif (str_ends_with(strtolower($json['name']), 'theme')) {
                if (!isset($json['extra']['regions'])) {
                    $errors[] = __d('cms', 'Missing field: "{0}"', 'extra.regions');
                }
            }
        }

        if ($errorMessages) {
            return $errors;
        }

        return empty($errors);
    }