validate() public method

validate some data array
public validate ( array $data )
$data array
Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config = $this->getHelper('config')->getConfiguration();
     $loader = new YamlLoader();
     $array = $loader->loadFromFile(__DIR__ . '/../../resources/schema.yml');
     $schema = new MetaYaml($array);
     $schema->validate($config);
     $output->writeln('<info>Configuration is valid</info>');
 }
 /**
  * {@inheritdoc}
  */
 public function validate(array $data)
 {
     $loader = new YamlLoader();
     $schemaContent = $loader->loadFromFile(__DIR__ . '/../definitionSchema.yml');
     $schema = new MetaYaml($schemaContent);
     try {
         $schema->validate($data);
     } catch (\Exception $e) {
         throw new \LogicException($e->getMessage(), $e->getCode(), $e);
     }
 }
Esempio n. 3
0
 public function validate($yamlFile, $dataToValidate, $validateSchema = false)
 {
     if (empty($yamlFile)) {
         return true;
     }
     if (!is_file($yamlFile)) {
         throw new SphringException("File '%s' cannot be found.", $yamlFile);
     }
     $this->yamlarh->setFileName($yamlFile);
     $schema = $this->yamlarh->parse();
     $schema = new MetaYaml($schema, $validateSchema);
     return $schema->validate($dataToValidate);
 }
Esempio n. 4
0
 public static function setupConfig(Application $app)
 {
     $loader = new YamlLoader();
     $schema = new MetaYaml($loader->loadFromFile(__DIR__ . '/config_schema.yml'));
     $schema->validate($config = $loader->loadFromFile(__DIR__ . '/../config/config.yml'));
     foreach ($config as $key => $value) {
         $app->setConfig($key, $value);
     }
     if (array_key_exists('SCRIPT_NAME', $_SERVER) && is_string($_SERVER['SCRIPT_NAME']) && !empty($_SERVER['SCRIPT_NAME'])) {
         $dir = dirname($_SERVER['SCRIPT_NAME']);
     } else {
         $dir = '/';
     }
     $app->setConfig('dir', $dir);
 }
 private function validateNodeType($data)
 {
     $schema = Yaml::parse(file_get_contents(__DIR__ . '/schema/node-type.yml'));
     $schema = new MetaYaml($schema);
     // $schema->validateSchema();
     $this->normalizeNodeType($data);
     $schema->validate($data);
 }
Esempio n. 6
0
<?php

/*
 * This file is part of the Supervisor Monitor project.
 *
 * (c) Márk Sági-Kazár <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
use RomaricDrigon\MetaYaml\Loader\YamlLoader;
use RomaricDrigon\MetaYaml\MetaYaml;
use Supervisor\Monitor\Manager;
return ['di' => ['manager' => ['definition' => function () {
    $loader = new YamlLoader();
    $schema = new MetaYaml($loader->loadFromFile(__DIR__ . '/schema.yml'));
    $schema->validate($config = $loader->loadFromFile(__DIR__ . '/../config/supervisor.yml'));
    return new Manager($config);
}], 'twig_loader' => ['class' => 'Twig_Loader_Filesystem', 'arguments' => [__DIR__ . '/views']], 'twig_extension' => ['class' => 'Supervisor\\Monitor\\TwigExtension'], 'twig' => ['class' => 'Twig_Environment', 'arguments' => ['twig_loader'], 'methods' => ['addExtension' => ['twig_extension']]], 'controller' => ['class' => 'Supervisor\\Monitor\\Controller', 'arguments' => ['app']]]];
Esempio n. 7
0
 public function testRoot()
 {
     $this->if($yaml_loader = new YamlLoader())->and($schema = $yaml_loader->loadFromFile('test/data/TestRoot/Schema.yml'))->and($data = $yaml_loader->loadFromFile('test/data/TestRoot/TestBase.yml'))->and($object = new testedClass($schema, true))->then->object($object)->isInstanceOf('RomaricDrigon\\MetaYaml\\MetaYaml')->boolean($object->validate($data))->isEqualTo(true);
 }