Checks if the given value is a unique entity depending on it's identity properties or
custom configured identity properties.

@param mixed $value The value that should be validated
@return void
@throws InvalidValidationOptionsException
@api
548577
protected function isValid($value)
    {
        if (!is_object($value)) {
            throw new InvalidValidationOptionsException('The value supplied for the UniqueEntityValidator must be an object.', 1358454270);
        }

        $classSchema = $this->reflectionService->getClassSchema(TypeHandling::getTypeForValue($value));
        if ($classSchema === null || $classSchema->getModelType() !== ClassSchema::MODELTYPE_ENTITY) {
            throw new InvalidValidationOptionsException('The object supplied for the UniqueEntityValidator must be an entity.', 1358454284);
        }

        if ($this->options['identityProperties'] !== null) {
            $identityProperties = $this->options['identityProperties'];
            foreach ($identityProperties as $propertyName) {
                if ($classSchema->hasProperty($propertyName) === false) {
                    throw new InvalidValidationOptionsException(sprintf('The custom identity property name "%s" supplied for the UniqueEntityValidator does not exists in "%s".', $propertyName, $classSchema->getClassName()), 1358960500);
                }
            }
        } else {
            $identityProperties = array_keys($classSchema->getIdentityProperties());
        }

        if (count($identityProperties) === 0) {
            throw new InvalidValidationOptionsException('The object supplied for the UniqueEntityValidator must have at least one identity property.', 1358459831);
        }

        $identifierProperties = $this->reflectionService->getPropertyNamesByAnnotation($classSchema->getClassName(), 'Doctrine\ORM\Mapping\Id');
        if (count($identifierProperties) > 1) {
            throw new InvalidValidationOptionsException('The object supplied for the UniqueEntityValidator must only have one identifier property @ORM\Id.', 1358501745);
        }

        $identifierPropertyName = count($identifierProperties) > 0 ? array_shift($identifierProperties) : 'Persistence_Object_Identifier';

        $query = $this->persistenceManager->createQueryForType($classSchema->getClassName());
        $constraints = [$query->logicalNot($query->equals($identifierPropertyName, $this->persistenceManager->getIdentifierByObject($value)))];
        foreach ($identityProperties as  $propertyName) {
            $constraints[] = $query->equals($propertyName, ObjectAccess::getProperty($value, $propertyName));
        }

        if ($query->matching($query->logicalAnd($constraints))->count() > 0) {
            $this->addError('Another entity with the same unique identifiers already exists', 1355785874);
        }
    }
975764
public static function assertExists($value)
    {
        if (static::exists($value) == false) {
            $class = substr(strrchr(get_called_class(), '\\'), 1);
            throw new \InvalidArgumentException(sprintf('"%s" is not a valid %s value.', $value, $class));
        }
    }
1162151
protected function isValid($value) {

		if(!($value instanceof PersistentResource)) {
			$this->addError('Given value is no Flow Resource', 1433344498);
		}

		$fileMimeType = $value->getMediaType();

		if(!\in_array($fileMimeType, $this->options['allowedMimeTypes'], true)) {
			$this->addError(
				'The given asset was not of type %1$s but is of type %2$s',
				1433343575,
				array(
					implode(', ', $this->options['allowedMimeTypes']),
					$fileMimeType
				)
		);
		}

	}
75918
public function setOption($name, $value)
    {
        if (! in_array($name, $this->validOptions)) {
            throw new Error('Invalid option ' . $name . '. Valid options are : ' . join(', ', $this->validOptions));
        }
        // Check duplicate fields in header
        if ('header' == $name) {
            $cnt = array_count_values($value);
            $duplicates = array();
            foreach ($cnt as $f => $c) {
                if ($c > 1) {
                    $duplicates[$f] = $c;
                }
            }
            if (sizeof($duplicates) > 0) {
                $msg = 'Duplicate fields found in header : ' . join(', ', array_keys($duplicates));
                throw new Error($msg);
            }
        }
        $this->$name = $value;

        return $this;
    }
72094
public function isValid($value)
    {
        if (false === Core::get()->classExists($value)) {
            $errorMessage = $this->translateErrorMessage(
                'validator.class_exists.not_valid',
                'configuration_object',
                [$value]
            );

            $this->addError($errorMessage, self::ERROR_CODE_CLASS_NOT_FOUND);
        } elseif (false === in_array($this->options['class'], class_parents($value))) {
            $errorMessage = $this->translateErrorMessage(
                'validator.class_extends_class.not_valid',
                'configuration_object',
                [$value, $this->options['class']]
            );

            $this->addError($errorMessage, self::ERROR_CODE_CLASS_NOT_VALID);
        }
    }
972491
protected function _validate_unique($value)
    {
        $context = $this->_context;

        $modelName = $context->model;
        return ($value && $modelName::exists([$context->field => $value])) ? null : $value;
    }
598741
protected function checkType($value)
    {
        if (is_string($value) !== true) {
            $msg = "The Identifier Datatype only accepts to store identifier values.";
            throw new InvalidArgumentException($msg);
        } elseif ($value === '') {
            $msg = "The Identifier Datatype do not accept empty strings as valid identifiers.";
            throw new InvalidArgumentException($msg);
        }
    }
158181
public function isValid($value = null, array $options = []): bool
    {
        if (\count($options) > 0) {
            $this->setOptions($options);
        }
        $this->setValue(\str_replace(' ', '', (string)$value));
        $this->errors = [];

        if ($this->options['type'] == 'any') {
            $types = \array_keys($this->validationData);
        } elseif (\array_key_exists($this->options['type'], $this->validationData)) {
            $types = [$this->options['type']];
        } else {
            throw new DomainException('Unsopported credit card type: '.$this->options['type']);
        }

        $validType = $this->validateType($types);
        $validNumber = $this->validateNumber();

        return $validType && $validNumber;
    }
18623
public function setValue($value)
    {
        if ($this->validation && !$this->validates($value)) {
            throw new Invalid($this->getValidationMessage($value));
        }

        if ($this->isMultiple()) {
            $this->value = $this->value === null ? [ $value ] : array_merge($this->value, [ $value ]);
        } else {
            $this->value = $value;
        }

        return $this;
    }
1189180
public function isValid($value)
    {
        $valid = true;
        $this->setValue($value);

        $result = $this->query($value);
        if (!$result) {
            if ($result === false) {
                $valid = false;
                $this->error(self::ERROR_NOT_ACTIVE);
            } elseif ($this->getOption('property') !== 'NOT_ACTIVE') {
                $valid = false;
                $this->error(self::ERROR_NO_RECORD_FOUND);
            }
        }

        return $valid;
    }
620328
public function setValue($value)
    {
        if (!is_string($value) || (is_object($value) && !method_exists($value, "__toString"))) {
            throw new InvalidArgumentException(sprintf(
                "Invalid argument given to %s, expected a string, %s given",
                __METHOD__,
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        $value = (string) $value;

        if (null !== $regex = $this->getValidationRegex()) {
            if (! preg_match($regex, $value)) {
                throw new InvalidArgumentException(sprintf(
                    "The given value '%s' doesn't match the validation regular expression: %s",
                    $value,
                    $regex
                ));
            }
        }

        $this->value = $value;

        return $this;
    }
852801
public function checkType($value): bool
    {
        if (!$this->hasTypeDeclaration) {
            return true;
        }

        if ($this->isNullable && $value === null) {
            return true;
        }

        foreach ($this->types as $currentType) {
            $isValidType = $this->assertTypeEquals($currentType, $value);

            if ($isValidType) {
                return true;
            }
        }

        $type = \gettype($value);

        $expectedTypes = \implode('|', $this->getTypes());

        throw new \InvalidArgumentException("Invalid type: expected {$this->name} to be of type {{$expectedTypes}}, instead got value `" . \print_r($value, true) . "` with type {{$type}}.");
    }
769914
public function isValid($value = null, array $options = []): bool
    {
        if (\count($options) > 0) {
            $this->setOptions($options);
        }
        $this->setValue($value);
        $this->errors = [];

        switch ($this->options['type']) {
            case 'equals':
                $isValid = $this->validateEquals();
                break;
            case 'lower-than':
                $isValid = $this->validateLowerThan();
                break;
            case 'greater-than':
                $isValid = $this->validateGreaterThan();
                break;
            default:
                $isValid = $this->validateEquals();
                break;
        }

        return $isValid;
    }
775168
protected function checkType($value)
    {
        if (gettype($value) !== 'string') {
            $msg = "IdentifierCollection class only accept string values, '" . gettype($value) . "' given.";
            throw new InvalidArgumentException($msg);
        } elseif (!Format::isIdentifier($value)) {
            $msg = "IdentifierCollection class only accept valid QTI Identifiers, '${value}' given.";
            throw new InvalidArgumentException($msg);
        }
    }
1287058
protected function setIdAttr($value)
    {
        if (!is_null($value) && !preg_match('/^[0-9]+$/D', $value)) {
            throw new InvalidIdException('Invalid id: ' . $value);
        }

        $this->id = $value;
    }
1215652
public function isValueValid($value) {
		return $value instanceof Type\PropertyValueType || $value instanceof DataType\TextType || $value instanceof DataType\URLType;
	}
322439
public function isValid($value)
    {
        if ($value == $this->allowName) {
            return true;
        }
        
        foreach ($this->getUser()->getGroups() as $group) {
            if ($group->getName() == $value) {
                $this->error(self::MSG_NOT_UNIQUE, $value);
                return false;
            }
        }
        return true;
    }