Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Jun 26, 2023
1 parent 534faea commit 32f9168
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- New #610: Add `$escape` parameter to methods `Result::getAttributeErrorMessagesIndexedByPath()` and
`Result::getErrorMessagesIndexedByPath()` that allow change or disable symbol which will be escaped in value path
elements (@vjik)
- Bug #612: Disable escaping of asterisk char in value path that returns by `Error::getValuePath(true)` (@vjik)
- Bug #612: Disable escaping of asterisk char in value path returned by `Error::getValuePath(true)` (@vjik)

## 1.1.0 April 06, 2023

Expand Down
4 changes: 2 additions & 2 deletions docs/guide/en/result.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ A path can contain integer elements too (when using the `Each` rule for example)

#### Resolving special characters collision in attribute names

When the attribute name contains a path separator (dot `.` by default), they're automatically escaped using
a backslash (`\`) in the error messages list:
When the attribute name in the error messages list contains a path separator (dot `.` by default),
it is automatically escaped using a backslash (`\`):

```php
[
Expand Down
8 changes: 4 additions & 4 deletions src/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ public function getParameters(): array
* A getter for {@see $valuePath} property. Returns a sequence of keys determining where a value caused the
* validation error is located within a nested structure.
*
* @param bool|string|null $escape Symbol that will be escaped with a backslash char (`\`) into path elements.
* When is null value path returns without escaping.
* Boolean value is deprecated and will be removed in the next major release. Boolean value processing so:
* @param bool|string|null $escape Symbol that will be escaped with a backslash char (`\`) in path elements.
* When it's null path is returned without escaping.
* Boolean value is deprecated and will be removed in the next major release. Boolean value processed in the following way:
* - `false` as null,
* - `true` as dot (`.`).
*
Expand All @@ -116,7 +116,7 @@ public function getValuePath(bool|string|null $escape = false): array
}

if (mb_strlen($escape) !== 1) {
throw new InvalidArgumentException('Escape symbol must contain exactly one character.');
throw new InvalidArgumentException('Escape symbol must be exactly one character.');
}

return array_map(
Expand Down
8 changes: 4 additions & 4 deletions src/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public function getErrorMessages(): array
* Each value is an array of error message strings.
*
* @param string $separator Attribute path separator. Dot is used by default.
* @param string|null $escape Symbol that will be escaped with a backslash char (`\`) into path elements.
* When is null value path returns without escaping.
* @param string|null $escape Symbol that will be escaped with a backslash char (`\`) in path elements.
* When it's null path is returned without escaping.
*
* @return array Arrays of error messages indexed by attribute path.
*
Expand Down Expand Up @@ -160,8 +160,8 @@ public function getAttributeErrorMessages(string $attribute): array
*
* @param string $attribute Attribute name.
* @param string $separator Attribute path separator. Dot is used by default.
* @param string|null $escape Symbol that will be escaped with a backslash char (`\`) into path elements.
* When is null value path returns without escaping.
* @param string|null $escape Symbol that will be escaped with a backslash char (`\`) in path elements.
* When it's null path is returned without escaping.
*
* @return array Arrays of error messages for the attribute specified indexed by attribute path.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/ErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testTooLongEscapeSymbol(): void
$error = new Error('');

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Escape symbol must contain exactly one character.');
$this->expectExceptionMessage('Escape symbol must be exactly one character.');
$error->getValuePath('..');
}
}

0 comments on commit 32f9168

Please sign in to comment.