public function isValid($value, $context = null)
    {
        if (! $this->useContext) {
            $context = (array) $value;
        }

        $cleanedValue = $this->cleanSearchValue($value);
        $match        = $this->objectRepository->findOneBy($cleanedValue);

        if (! is_object($match)) {
            return true;
        }

        $expectedIdentifiers = $this->getExpectedIdentifiers($context);
        $foundIdentifiers    = $this->getFoundIdentifiers($match);

        if (count(array_diff_assoc($expectedIdentifiers, $foundIdentifiers)) == 0) {
            return true;
        }

        $this->error(self::ERROR_OBJECT_NOT_UNIQUE, $value);
        return false;
    }
public function isValid($value, $context = null)
    {
        if (! $this->useContext) {
            $context = (array) $value;
        }

        $cleanedValue = $this->cleanSearchValue($value);
        $match        = $this->objectRepository->findOneBy($cleanedValue);

        if (! is_object($match)) {
            return true;
        }

        $expectedIdentifiers = $this->getExpectedIdentifiers($context);
        $foundIdentifiers    = $this->getFoundIdentifiers($match);

        if (count(array_diff_assoc($expectedIdentifiers, $foundIdentifiers)) == 0) {
            return true;
        }

        $this->error(self::ERROR_OBJECT_NOT_UNIQUE, $value);
        return false;
    }
public function isValid ( $ value , $ context = null ) { if ( ! $ this -> useContext ) { $ context = ( array ) $ value ; } $ cleanedValue = $ this -> cleanSearchValue ( $ value ) ; $ match = $ this -> objectRepository -> findOneBy ( $ cleanedValue ) ; if ( ! is_object ( $ match ) ) { return true ; } $ expectedIdentifiers = $ this -> getExpectedIdentifiers ( $ context ) ; $ foundIdentifiers = $ this -> getFoundIdentifiers ( $ match ) ; if ( count ( array_diff_assoc ( $ expectedIdentifiers , $ foundIdentifiers ) ) == 0 ) { return true ; } $ this -> error ( self :: ERROR_OBJECT_NOT_UNIQUE , $ value ) ; return false ; }
Returns false if there is another object with the same field values but other identifiers.

@param  mixed $value
@param  array $context
@return boolean
Returns false if there is another object with the same field values but other identifiers .