src/Knp/DictionaryBundle/Validator/Constraints/DictionaryValidator.php
public function validate($value, Constraint $constraint): void
    {
        if (false === $constraint instanceof Dictionary) {
            throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Dictionary');
        }

        if (null === $value || '' === $value) {
            return;
        }

        $dictionary = $this->dictionaries[$constraint->name];
        $values     = $dictionary->getKeys();

        if (false === \in_array($value, $values)) {
            $this->context->addViolation(
                $constraint->message,
                ['{{ key }}' => $value, '{{ keys }}' => implode(', ', $values)]
            );
        }
    }
public function validate($value, Constraint $constraint): void
    {
        if (false === $constraint instanceof Dictionary) {
            throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Dictionary');
        }

        if (null === $value || '' === $value) {
            return;
        }

        $dictionary = $this->dictionaries[$constraint->name];
        $values     = $dictionary->getKeys();

        if (false === \in_array($value, $values)) {
            $this->context->addViolation(
                $constraint->message,
                ['{{ key }}' => $value, '{{ keys }}' => implode(', ', $values)]
            );
        }
    }
{@inheritdoc}