-
-
Notifications
You must be signed in to change notification settings - Fork 962
Open
Description
API Platform version(s) affected: 4.2.16
Description
Error in file ValidatorPropertyMetadataFactory.php:186-188:
foreach ($validatorPropertyMetadata->findConstraints($validationGroup) as $propertyConstraint) {
if ($propertyConstraint instanceof Sequentially || $propertyConstraint instanceof Compound) {
$constraints[] = $propertyConstraint->getNestedConstraints(); // <-- problem here
}
}
Chain:
- getValidationGroups() → returns ['Default'] (when there are no explicit validation_groups in the operation)
- findConstraints('Default') → finds Assert\Sequentially([...]) because Sequentially itself has no group and belongs to Default ✓
- getNestedConstraints() → returns all nested constraints without checking their groups
- Among them it turns out NotBlank(groups: ['some group'])
- isRequired(NotBlank) → return true
When expanding Sequentially/Compound constraints, nested constraint groups are not checked. getNestedConstraints() returns a raw array without group filtering.
How to reproduce
#[Assert\Sequentially([
new Assert\NotBlank(groups: ['some group']),
new Assert\Range(min: '0.01'),
])]
private ?string $someField = null; <- field will be required in OpenApi
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels