public function __invoke($schema, OutputInterface $output) { $schema = Util::loadJson($schema); $metaSchema = (new Dereferencer())->dereference('file://' . Util::schemaPath('draft4.json')); $validator = new Validator($schema, $metaSchema); if ($validator->passes()) { $output->writeln('<info>✓ Valid draft-04 JSON Schema</info>'); } else { $output->writeln('<error>✗ Invalid draft-04 JSON Schema</error>'); Util::renderErrorTable($output, $validator->errors()); } }
public function __invoke($data, $schema, OutputInterface $output) { $schema = Util::loadJson($schema); $data = Util::loadJson($data); $schema = (new Dereferencer())->dereference($schema); $validator = new Validator($data, $schema); if ($validator->passes()) { $output->writeln('<info>✓ Validation passed</info>'); } else { $output->writeln('<error>✗ Validation failed</error>'); Util::renderErrorTable($output, $validator->errors()); } }