[Validator] fixed remaining notice
This commit is contained in:
parent
d752f74161
commit
f187d9aa1c
@ -90,6 +90,14 @@ class CollectionValidator extends ConstraintValidator
|
|||||||
if (!$constraint->allowExtraFields) {
|
if (!$constraint->allowExtraFields) {
|
||||||
foreach ($value as $field => $fieldValue) {
|
foreach ($value as $field => $fieldValue) {
|
||||||
if (!isset($constraint->fields[$field])) {
|
if (!isset($constraint->fields[$field])) {
|
||||||
|
if ($context instanceof ExecutionContextInterface) {
|
||||||
|
$context->buildViolation($constraint->extraFieldsMessage)
|
||||||
|
->atPath('['.$field.']')
|
||||||
|
->setParameter('{{ field }}', $this->formatValue($field))
|
||||||
|
->setInvalidValue($fieldValue)
|
||||||
|
->setCode(Collection::NO_SUCH_FIELD_ERROR)
|
||||||
|
->addViolation();
|
||||||
|
} else {
|
||||||
$this->buildViolationInContext($context, $constraint->extraFieldsMessage)
|
$this->buildViolationInContext($context, $constraint->extraFieldsMessage)
|
||||||
->atPath('['.$field.']')
|
->atPath('['.$field.']')
|
||||||
->setParameter('{{ field }}', $this->formatValue($field))
|
->setParameter('{{ field }}', $this->formatValue($field))
|
||||||
@ -100,4 +108,5 @@ class CollectionValidator extends ConstraintValidator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user