Skip to content

Commit db108d5

Browse files
committed
fix: allow multiple validation with :property placeholder
1 parent 494c1bf commit db108d5

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

src/Doctrine/Odm/Filter/OrderFilter.php

-9
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,6 @@ protected function filterProperty(string $property, $value, Builder $aggregation
278278
*/
279279
public function getSchema(Parameter $parameter): array
280280
{
281-
if (str_contains($parameter->getKey(), ':property')) {
282-
$properties = [];
283-
foreach (array_keys($parameter->getExtraProperties()['_properties'] ?? []) as $property) {
284-
$properties[] = [$property => ['type' => 'string', 'enum' => ['asc', 'desc']]];
285-
}
286-
287-
return ['type' => 'object', 'properties' => $properties];
288-
}
289-
290281
return ['type' => 'string', 'enum' => ['asc', 'desc']];
291282
}
292283
}

src/Doctrine/Orm/Filter/OrderFilter.php

-9
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,6 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB
285285
*/
286286
public function getSchema(Parameter $parameter): array
287287
{
288-
if (str_contains($parameter->getKey(), ':property')) {
289-
$properties = [];
290-
foreach (array_keys($parameter->getExtraProperties()['_properties'] ?? []) as $property) {
291-
$properties[] = [$property => ['type' => 'string', 'enum' => ['asc', 'desc']]];
292-
}
293-
294-
return ['type' => 'object', 'properties' => $properties];
295-
}
296-
297288
return ['type' => 'string', 'enum' => ['asc', 'desc']];
298289
}
299290
}

src/Symfony/Validator/State/ParameterValidatorProvider.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
6161
$value = null;
6262
}
6363

64-
$violations = $this->validator->validate($value, $constraints);
64+
$violations = [];
65+
if (\is_array($value) && $properties = $parameter->getExtraProperties()['_properties'] ?? []) {
66+
foreach ($properties as $property) {
67+
$violations = [...$violations, ...$this->validator->validate($value[$property] ?? null, $constraints)];
68+
}
69+
} else {
70+
$violations = $this->validator->validate($value, $constraints);
71+
}
72+
6573
foreach ($violations as $violation) {
6674
$constraintViolationList->add(new ConstraintViolation(
6775
$violation->getMessage(),

0 commit comments

Comments
 (0)