Skip to content

Commit

Permalink
I think that's it
Browse files Browse the repository at this point in the history
The only issue is that when rendering full messages we might want to
render the parent if it has path, otherwise it can be a bit confusing
when there are multiple children.

I don't mind seeing the values in the full message, and in the array, in
fact, I think it's probably what we want to do, because the path will be
there already. The most important place where we should show the full
path is in the main message.

It seems like in some nested cases, the main message isn't rendering the
full path, it's getting lost at some point. I'm gonna check that when
I'm back to this.
  • Loading branch information
henriquemoody committed Dec 27, 2024
1 parent 83cd040 commit c518582
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
7 changes: 0 additions & 7 deletions library/Message/StandardFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ public function full(
$rendered = '';
if ($this->isAlwaysVisible($result, ...$siblings) || $isFinalTemplate) {
$indentation = str_repeat(' ', $depth * 2);
// Something here
// if ($parent && $parent->path !== null && $result->path !== null && $result->path !== $parent->path) {
// $result = $result->withPath($parent->path);
// } else
if ($parent && $parent->path !== null && $result->path === null) {
$result = $result->withPath($parent->path);
}
$rendered .= sprintf(
'%s- %s' . PHP_EOL,
$indentation,
Expand Down
8 changes: 4 additions & 4 deletions library/Rules/AllOf.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
#[Template(
'These rules must pass for {{name}}',
'These rules must not pass for {{name}}',
'{{name}} must pass these rules',
'{{name}} must not pass these rules',
self::TEMPLATE_SOME,
)]
#[Template(
'All the required rules must pass for {{name}}',
'None of these rules must pass for {{name}}',
'{{name}} must pass all the required rules',
'{{name}} must not pass all the required rules',
self::TEMPLATE_NONE,
)]
final class AllOf extends Composite
Expand Down
10 changes: 5 additions & 5 deletions tests/feature/Rules/EachTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@
<<<'FULL_MESSAGE'
- Each item in `[2, 4]` must be valid
- All the required rules must pass for `.0`
- 2 must be between 5 and 7
- 2 must be an odd number
- `.0` must be between 5 and 7
- `.0` must be an odd number
- All the required rules must pass for `.1`
- 4 must be between 5 and 7
- 4 must be an odd number
- `.1` must be between 5 and 7
- `.1` must be an odd number
FULL_MESSAGE,
[
'__root__' => 'Each item in `[2, 4]` must be valid',
Expand All @@ -277,7 +277,7 @@
- These rules must pass for `.1`
- `.my_int` must be an odd number
- All the required rules must pass for `.2`
- "not an array" must be an array
- `.2` must be an array
- `.my_int` must be present
FULL_MESSAGE,
[
Expand Down

0 comments on commit c518582

Please sign in to comment.