Skip to content

Commit

Permalink
fix validation
Browse files Browse the repository at this point in the history
  • Loading branch information
matronator committed Oct 12, 2023
1 parent 0028386 commit 5936e48
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Parsem/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,16 @@ public static function isValid(string $filename, ?string $contents = null): bool
}

$validator = new Validator();
$schema = file_get_contents('https://www.mtrgen.com/storage/schemas/template/latest/mtrgen-template-schema.json');
try {
$schema = file_get_contents('https://www.mtrgen.com/storage/schemas/template/latest/mtrgen-template-schema.json');
} catch (Exception $e) {
try {
$schema = file_get_contents('https://files.matronator.cz/public/mtrgen/latest/mtrgen-template-schema.json');
} catch (Exception $e) {
throw new RuntimeException("Failed to get template schema from remote server: " . $e->getMessage());
}
}

return $validator->validate($parsed, $schema)->isValid();
}

Expand Down

0 comments on commit 5936e48

Please sign in to comment.