Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Exception/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ class ValidationException extends \InvalidArgumentException
public function __construct(string $message, ValidationResult $validationResult)
{
$this->validationResult = $validationResult;
$errors = $validationResult->getErrors();
$i = 1;
foreach ($errors as $error) {
$pointer = implode(" -> ", $error->dataPointer());
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separator ' -> ' is hardcoded. Consider extracting it as a class constant (e.g., POINTER_SEPARATOR) to improve maintainability and make it easier to change the formatting consistently if needed in the future.

Copilot uses AI. Check for mistakes.
$invalidValue = $error->data();
if (is_array($invalidValue) || is_object($invalidValue)) {
$invalidValue = json_encode($invalidValue);
}
$message .= "\n {$i}) {$pointer}: '{$invalidValue}'";
$i++;
Comment on lines +29 to +37
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name i is ambiguous for a counter in this context. Consider renaming it to errorNumber or errorIndex to better convey its purpose as an error counter in the formatted output.

Suggested change
$i = 1;
foreach ($errors as $error) {
$pointer = implode(" -> ", $error->dataPointer());
$invalidValue = $error->data();
if (is_array($invalidValue) || is_object($invalidValue)) {
$invalidValue = json_encode($invalidValue);
}
$message .= "\n {$i}) {$pointer}: {$invalidValue}";
$i++;
$errorIndex = 1;
foreach ($errors as $error) {
$pointer = implode(" -> ", $error->dataPointer());
$invalidValue = $error->data();
if (is_array($invalidValue) || is_object($invalidValue)) {
$invalidValue = json_encode($invalidValue);
}
$message .= "\n {$errorIndex}) {$pointer}: {$invalidValue}";
$errorIndex++;

Copilot uses AI. Check for mistakes.
}
parent::__construct($message);
}

Expand Down