Skip to content

Commit e2ff61f

Browse files
Actionable error message for large json documents (#45)
* Actionable error message for large json documents * Build additional error description statelessly * Update src/Constraint/JsonValueMatchesMany.php Co-authored-by: Martin Helmich <kontakt@martin-helmich.de>
1 parent 87cdc17 commit e2ff61f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Constraint/JsonValueMatchesMany.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,23 @@ protected function matches($other): bool
6666
}
6767
return true;
6868
}
69+
70+
/**
71+
* Returns a string representation of matches that evaluate to false.
72+
*
73+
* @return string
74+
*/
75+
protected function additionalFailureDescription($other): string
76+
{
77+
/** @var string[] */
78+
$failedConstraints = array();
79+
80+
foreach ($this->constraints as $constraint) {
81+
if (!$constraint->evaluate($other, '', true)) {
82+
$failedConstraints[] = $constraint->toString();
83+
}
84+
}
85+
86+
return "\n" . implode("\n", $failedConstraints);
87+
}
6988
}

0 commit comments

Comments
 (0)