public function validate($value, Constraint $constraint): void
    {
        // Build a list of values.
        $item_values = [];
        foreach ($value as $item) {
            $item_value = $this->property_accessor->getValue($item, $constraint->property);

            // If any value is repeated build a violation.
            if (isset($item_values[$item_value])) {
                $this->context->buildViolation($constraint->message)
                    ->setParameter('{{ string }}', $constraint->property)
                    ->addViolation();
            }
            $item_values[$item_value] = true;
        }
    }
public function validate($value, Constraint $constraint): void
    {
        // Build a list of values.
        $item_values = [];
        foreach ($value as $item) {
            $item_value = $this->property_accessor->getValue($item, $constraint->property);

            // If any value is repeated build a violation.
            if (isset($item_values[$item_value])) {
                $this->context->buildViolation($constraint->message)
                    ->setParameter('{{ string }}', $constraint->property)
                    ->addViolation();
            }
            $item_values[$item_value] = true;
        }
    }
public function validate ( $ value , Constraint $ constraint ) : void { // Build a list of values. $ item_values = [ ] ; foreach ( $ value as $ item ) { $ item_value = $ this -> property_accessor -> getValue ( $ item , $ constraint -> property ) ; // If any value is repeated build a violation. if ( isset ( $ item_values [ $ item_value ] ) ) { $ this -> context -> buildViolation ( $ constraint -> message ) -> setParameter ( '{{ string }}' , $ constraint -> property ) -> addViolation ( ) ; } $ item_values [ $ item_value ] = true ; } }
Validate a constraint.

@param mixed      $value      The value being passed in.
@param Constraint $constraint The constraint to be checked.

@return void
Validate a constraint .