code: private DefaultInstalledExtension validateExtension(LocalExtension localExtension, String namespace,
          Map<String, ExtensionDependency> managedDependencies) throws InvalidExtensionException
      {
          DefaultInstalledExtension installedExtension = this.extensions.get(localExtension.getId());
          if (installedExtension != null && installedExtension.isValidated(namespace)) {
              // Already validated
              return installedExtension;
          }
  
          // Actually validate
  
          if (namespace != null && DefaultInstalledExtension.getNamespaces(localExtension) == null) {
              // This extension is supposed to be installed on root namespace only so redirecting to null namespace
              // initialization
              return validateExtension(localExtension, null, managedDependencies);
          }
  
          if (!DefaultInstalledExtension.isInstalled(localExtension, namespace)) {
              throw new InvalidExtensionException(String.format("Extension [%s] is not installed", localExtension));
          }
  
          if (this.coreExtensionRepository.exists(localExtension.getId().getId())) {
              throw new InvalidExtensionException(
                  String.format("Extension [%s] already exists as a core extension", localExtension));
          }
  
          // Validate dependencies
          InvalidExtensionException dependencyException = null;
          for (ExtensionDependency dependency : localExtension.getDependencies()) {
              try {
                  // Replace with managed dependency if any
                  dependency = ExtensionUtils.getDependency(dependency, managedDependencies, localExtension);
  
                  validateDependency(dependency, namespace, ExtensionUtils.append(managedDependencies, localExtension));
              } catch (InvalidExtensionException e) {
                  if (!dependency.isOptional()) {
                      // Continue to make sure all extensions are validated in the right order
                      if (dependencyException == null) {
                          dependencyException = e;
                      }
                  }
              }
          }
  
          // Throw exception if any issue has been found with dependencies
          if (dependencyException != null) {
              throw dependencyException;
          }
  
          // Complete local extension installation
          return localExtension instanceof DefaultInstalledExtension ? (DefaultInstalledExtension) localExtension
              : addInstalledExtension(localExtension, namespace, true);
      }
docs: Check extension validity against a specific namespace.
  
  @param localExtension the extension to validate
  @param namespace the namespace
  @param managedDependencies the managed dependencies
  @return the corresponding {@link DefaultInstalledExtension}
  @throws InvalidExtensionException when the passed extension is fond invalid