[Validator] Allow empty keys in the validation config
This commit is contained in:
parent
6bcd0a2d40
commit
8702ea5f6d
@ -58,24 +58,28 @@ class YamlFileLoader extends FileLoader
|
||||
$metadata->setGroupSequenceProvider((bool)$yaml['group_sequence_provider']);
|
||||
}
|
||||
|
||||
if (isset($yaml['constraints'])) {
|
||||
if (isset($yaml['constraints']) && is_array($yaml['constraints'])) {
|
||||
foreach ($this->parseNodes($yaml['constraints']) as $constraint) {
|
||||
$metadata->addConstraint($constraint);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($yaml['properties'])) {
|
||||
if (isset($yaml['properties']) && is_array($yaml['constraints'])) {
|
||||
foreach ($yaml['properties'] as $property => $constraints) {
|
||||
foreach ($this->parseNodes($constraints) as $constraint) {
|
||||
$metadata->addPropertyConstraint($property, $constraint);
|
||||
if (null !== $constraints) {
|
||||
foreach ($this->parseNodes($constraints) as $constraint) {
|
||||
$metadata->addPropertyConstraint($property, $constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($yaml['getters'])) {
|
||||
foreach ($yaml['getters'] as $getter => $constraints) {
|
||||
foreach ($this->parseNodes($constraints) as $constraint) {
|
||||
$metadata->addGetterConstraint($getter, $constraint);
|
||||
if (null !== $constraints) {
|
||||
foreach ($this->parseNodes($constraints) as $constraint) {
|
||||
$metadata->addGetterConstraint($getter, $constraint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ Symfony\Component\Validator\Tests\Fixtures\Entity:
|
||||
- Min: 5
|
||||
# Constraint with options
|
||||
- Choice: { choices: [A, B], message: Must be one of %choices% }
|
||||
dummy:
|
||||
|
||||
getters:
|
||||
lastName:
|
||||
|
Reference in New Issue
Block a user