validateTemplatePath
Validate the template directories.

@return void
@throws \InvalidArgumentException
162803
protected function validateTemplatePath()
    {
        array_walk($this->templatePath, function($val, $key) {
            if (!is_dir($val)) {
                throw new \InvalidArgumentException(sprintf('Invalid template path: %s', $val));
            }
        });
    }
1001021
private function validateTemplate($type, $template)
    {
        $status = '<info>ok</info>';

        try {
            $this->validateTwigTemplate($template);
        } catch (\Exception $e) {
            $status = sprintf('<error>failed: %s</error>', $e->getMessage());
            $this->errors[] = $e->getMessage();
        }

        $this->output->writeln(
            sprintf(
                '    %s: %s -> %s',
                $type,
                $template,
                $status
            )
        );
    }
50146
protected function validate()
    {
        $realPath = $this->realPath();

        if (! $realPath) {
            throw new \InvalidArgumentException("Path can not be empty");
        }

        if (! file_exists($realPath)) {
            throw new PathNotFoundException("Path does not exist: [{$realPath}]");
        }

        if (! $this->composer('type')) {
            throw new \Exception('Composer type not provided in composer.json');
        }

        if (! str_is('*.*.*', $this->slug)) {
            throw new \Exception('Slug should be snake case and formatted like: {vendor}.{type}.{name}');
        }
    }
385988
public function setTemplatePathAndFilename($templatePathAndFilename)
    {
        $this->baseRenderingContext->getTemplatePaths()->setTemplatePathAndFilename($templatePathAndFilename);

        $partialRootPaths = $this->baseRenderingContext->getTemplatePaths()->getPartialRootPaths();
        $layoutRootPaths = $this->baseRenderingContext->getTemplatePaths()->getLayoutRootPaths();
        array_unshift($partialRootPaths, Files::concatenatePaths([dirname($templatePathAndFilename), 'Partials']));
        array_unshift($layoutRootPaths, Files::concatenatePaths([dirname($templatePathAndFilename), 'Layouts']));
        $this->baseRenderingContext->getTemplatePaths()->setPartialRootPaths($partialRootPaths);
        $this->baseRenderingContext->getTemplatePaths()->setLayoutRootPaths($layoutRootPaths);
    }
872455
public function initCustomTemplates()
    {
        $directory = MUNICIPIO_PATH . 'library/Controller/';

        foreach (@glob($directory . "*.php") as $file) {
            $class = '\Municipio\Controller\\' . basename($file, '.php');

            if (!class_exists($class)) {
                continue;
            }

            if (!method_exists($class, 'registerTemplate')) {
                continue;
            }

            $class::registerTemplate();
            unset($class);
        }
    }
92165
def validate(template)
      skeleton = Skeletons::Loader.load_template(template)
      validator = Grayskull::Validator.new(skeleton,Skeletons::Skeleton::SCHEMA_FILE)
      results = validator.validate

      if !results['result']
        puts 'Validation Failed with ' + results['errors'].count.to_s + ' errors';
            puts ''
            results["errors"].each{
              |error|
              puts error            
            }
      else
        puts 'Validated Successfully!'
      end
    end
701653
public function validateNamespace()
    {
        $this->ns = ltrim($this->ns, '\\');
        $path = Yii::getAlias('@' . str_replace('\\', '/', $this->ns), false);
        if ($path === false) {
            $this->addError('ns', 'Namespace must be associated with an existing directory.');
        }
    }
1087834
private function setTemplatePath($templatePath)
  {
    $return = false;

    if (is_string($templatePath)) {
      if ($this->checkTemplatePath($templatePath) === true) {
        $this->templatePath[] = $templatePath;

        $return = true;
      }
    }
    else if (is_array($templatePath)) {
      foreach ($templatePath as $path) {
        if ($this->checkTemplatePath($path) === true) {
          $this->templatePath[] = $path;

          $return = true;
        }
      }
    }

    return $return;
  }
1275374
def Validate(self):
    """"""
    self._ValidateReturnedTypes()
    self._ValidatePaths()
    self._ValidateType()
    self._ValidateRequiredAttributes()
    self._ValidateCommandArgs()
25754
public function isValidAbsolutePath()
    {
        if (!Path::isAbsolute($this->string)) {
            return false;
        }

        if (!is_dir($this->string)) {
            return false;
        }

        return true;
    }
809200
public function getTemplateDirectories($templateType)
    {
        if (! isset($this->templateDirectories[$templateType])) {
            throw new InvalidArgumentException("Failed to get template type %", $templateType);
        }

        return $this->templateDirectories[$templateType];
    }
550511
private function getTemplateDirectory()
    {
        $templateDirectory = realpath($this->templateDirectory . '/_template');

        if ($this->files->exists($templateDirectory) && $this->files->isDirectory($templateDirectory)) {
            $this->generator->setInsideTemplateDirectory(true);

            return $templateDirectory;
        }

        return $this->templateDirectory;
    }
746424
public function validate(): bool
    {
        $valid = true;
        $this->_errors = [];
        foreach ($this->_paths as $key => $path) {
            if ($path === null) {
                continue;
            }
            if (!$path->validate()) {
                $valid = false;
            }
            if (strpos($key, '/') !== 0) {
                $this->_errors[] = "Path must begin with /: $key";
            }
        }
        return $valid && empty($this->_errors);
    }
584496
public function isValid()
    {
        if (null === $this->_isValid) {
            $this->_isValid = false;

            if (null !== $data_object = $this->getDataObject()) {
                if (true === property_exists($data_object, 'templateLayouts')
                        && true === is_array($data_object->templateLayouts)
                        && 0 < count($data_object->templateLayouts)) {
                    $this->_isValid = true;

                    foreach ($data_object->templateLayouts as $zone) {
                        if (false === property_exists($zone, 'id')
                                || false === property_exists($zone, 'defaultContainer')
                                || false === property_exists($zone, 'target')
                                || false === property_exists($zone, 'gridClassPrefix')
                                || false === property_exists($zone, 'gridSize')) {
                            $this->_isValid = false;
                            break;
                        }
                    }
                }
            }
        }

        return $this->_isValid;
    }
56780
private function validateRegisterFilepath($registerFilepath)
    {
        if (false === file_exists($registerFilepath)) {
            throw new \InvalidArgumentException("File $registerFilepath does not exist");
        }

        $yamlPattern = '#' . '(.*)\.yml$' . '#';

        $isAYamlFile = preg_match($yamlPattern, $registerFilepath);
        if (false === $isAYamlFile) {
            throw new \InvalidArgumentException("File $registerFilepath is not a YAML file");
        }
    }
319853
protected void validateResultsDirectories() {
        for (String result : results) {
            if (Files.notExists(Paths.get(result))) {
                throw new AllureCommandException(String.format("Report directory <%s> not found.", result));
            }
        }
    }
582816
protected function _validateTasks()
    {
        foreach ($this->_taskMap as $taskName => $task) {
            $class = App::className($task['class'], 'Shell/Task', 'Task');
            if (!class_exists($class)) {
                throw new RuntimeException(sprintf(
                    'Task `%s` not found. Maybe you made a typo or a plugin is missing or not loaded?',
                    $taskName
                ));
            }
        }
    }