Skip to content

Commit c8d1624

Browse files
committed
Display field errors
1 parent d7f2a53 commit c8d1624

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/publications/src/Commands/ValidatePublicationsCommand.php

+15-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Hyde\Publications\Commands;
66

77
use Hyde\Hyde;
8+
use function array_filter;
89
use function basename;
910
use function collect;
1011
use Exception;
@@ -279,12 +280,25 @@ protected function validateSchemaFiles(): void
279280
if (empty($errors['schema'])) {
280281
$this->line('<info> No top-level schema errors found</info>');
281282
} else {
282-
$this->line(sprintf(" <fg=red>Found %s errors:</>", count($errors['schema'])));
283+
$this->line(sprintf(" <fg=red>Found %s top-level schema errors:</>", count($errors['schema'])));
283284
foreach ($errors['schema'] as $error) {
284285
$this->line(sprintf(" <fg=red>%s</> <comment>%s</comment>", self::CROSS_MARK, implode(' ', $error)));
285286
}
286287
}
287288

289+
if (empty(array_filter($errors['fields']))) {
290+
$this->line('<info> No field-level schema errors found</info>');
291+
} else {
292+
$this->newLine();
293+
$this->line(sprintf(" <fg=red>Found errors in %s field definitions:</>", count($errors['fields'])));
294+
foreach ($errors['fields'] as $fieldNumber => $fieldErrors) {
295+
$this->line(sprintf(" <fg=cyan>Field #%s:</>", $fieldNumber+1));
296+
foreach ($fieldErrors as $error) {
297+
$this->line(sprintf(" <fg=red>%s</> <comment>%s</comment>", self::CROSS_MARK, implode(' ', $error)));
298+
}
299+
}
300+
}
301+
288302
if ($number !== count($schemaFiles) - 1) {
289303
$this->newLine();
290304
}

0 commit comments

Comments
 (0)