@param Constraint $constraint
@param string     $documentationKey

@return mixed|null Return null if value does not exist
506146
protected function getPayloadDocValue(Constraint $constraint, string $documentationKey)
    {
        return $this->hasPayloadDocKey($constraint, $documentationKey)
            ? $constraint->payload[self::PAYLOAD_DOCUMENTATION_KEY][$documentationKey]
            : null
        ;
    }
317642
protected function getDocument($key)
    {
        if (!$this->documentExists($key)) {
            return null;
        }

        return $this->convertDocument($this->documents[$key]);
    }
665386
protected function guessTypeFromConstraint(Constraint $constraint) : ?TypeDoc
    {
        if (null !== ($type = $this->guessPrimaryTypeFromConstraint($constraint))) {
            return $type;
        }

        // If primary type is still not defined
        $constraintClass = get_class($constraint);
        if (Assert\Count::class == $constraintClass) {
            return new CollectionDoc();
        }

        return null;
    }
148206
public function getIssueByKey($key)
    {
        if (array_key_exists($key, $this->issues) && isset($this->issues[$key])) {
            return $this->issues[$key];
        }

        return null;
    }
716331
public function validate($entity, Constraint $constraint)
    {
        if (!$entity instanceof ClientDetails) {
            throw new \InvalidArgumentException('Expected instance of ClientDetails');
        }
        
        $username = $entity->getUsername();
        $result   = $this->clientRepository->findOneBy(['clientDetails.username' => $username]);
        
        if (null === $result) {
            return;
        }
        
        if ($this->context instanceof ExecutionContextInterface) {
            $this->context
                ->buildViolation($constraint->message)
                ->setParameter('{{ url }}', $this->routerHelper->generateUrl('front.client.login'))
                ->atPath('username')
                ->setInvalidValue($username)
                ->addViolation();
        }
    }
459059
private function findFieldCriteria(array $criteria, Constraint $constraint, ObjectManager $em, ClassMetadata $class, $entity, $fieldName)
    {
        $this->validateFieldCriteria($class, $fieldName);

        /* @var \Doctrine\ORM\Mapping\ClassMetadata $class */
        $criteria[$fieldName] = $class->reflFields[$fieldName]->getValue($entity);

        /** @var UniqueEntity $constraint */
        if ($constraint->ignoreNull && null === $criteria[$fieldName]) {
            $criteria = null;
        } else {
            $this->findFieldCriteriaStep2($criteria, $em, $class, $fieldName);
        }

        return $criteria;
    }
792804
private function isRequired(Constraint $constraint): bool
    {
        foreach (self::REQUIRED_CONSTRAINTS as $requiredConstraint) {
            if ($constraint instanceof $requiredConstraint) {
                return true;
            }
        }

        return false;
    }
46458
public function validate($location, Constraint $constraint)
    {
        if (null === $location) {
            return;
        }

        $isWithinCopySubtreeLimit = new IsWithinCopySubtreeLimit($this->copySubtreeLimit, $this->searchService);
        try {
            if (!$isWithinCopySubtreeLimit->isSatisfiedBy($location)) {
                $this
                    ->context
                    ->buildViolation($constraint->message)
                    ->setParameter('%currentLimit%', $this->copySubtreeLimit)
                    ->addViolation();
            }
        } catch (InvalidArgumentException $e) {
            $this->context->addViolation($e->getMessage());
        }
    }
637065
public function addConstraint(Constraint $constraint) : void
    {
        $constraint->setValidator($this);
        array_push($this->constraints, $constraint);
    }
312563
function resolveDocumentConstraint(constraintDefinition) {
    if (typeof constraintDefinition === 'function') {
      var dbName = userContext ? userContext.db : null;

      return constraintDefinition(newDoc, oldDoc, dbName);
    } else {
      return constraintDefinition;
    }
  }
578332
private function getStringType(Constraint $constraint) : ?string
    {
        $stringType = null;
        if (null !== ($typeFromPayload = $this->constraintPayloadDocHelper->getTypeIfExist($constraint))) {
            $stringType = $typeFromPayload;
        } elseif ($constraint instanceof Assert\Type) {
            $stringType = strtolower($constraint->type);
        } elseif ($constraint instanceof Assert\IdenticalTo) {// Strict comparison so value define the type
            $stringType = gettype($constraint->value);
        }

        return $stringType;
    }
470164
protected function getConstraint($foreign)
    {
        foreach ($this->getConstraints() as $constraint) {
            if ($constraint->foreign == $foreign) {
                return (object) $constraint;
            }
        }

        return null;
    }
1229411
public function checkConstraint($constraint)
    {
        if (!$constraint instanceof ConstraintContract && !$constraint instanceof ConstraintGroupContract) {
            throw new InvalidArgumentException("Constraint has to be Constraint or ConstraintGroup, not " . Type::of($constraint));
        }
        if ($this->allowedOperators && $constraint instanceof Constraint) {
            $constraint->allowOperators($this->allowedOperators);
        }
        return $constraint;
    }
883813
protected function getRelationshipFromMethod($key, $camelKey)
	{
		$relations = $this->$camelKey();

		if ( ! $relations instanceof Relation)
		{
			throw new LogicException('Relationship method must return an object of type '
				. 'Fly\Database\ActiveRecord\Relations\Relation');
		}

		return $this->relations[$key] = $relations->getResults();
	}
899988
private static function validateConstraint(Constraint $constraint): void
    {
        if (!$constraint instanceof UniqueEntity) {
            throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\UniqueEntity');
        }

        if (!\is_array($constraint->fields) && !\is_string($constraint->fields)) {
            throw new UnexpectedTypeException($constraint->fields, 'array');
        }

        if (null !== $constraint->errorPath && !\is_string($constraint->errorPath)) {
            throw new UnexpectedTypeException($constraint->errorPath, 'string or null');
        }

        if (0 === \count((array) $constraint->fields)) {
            throw new ConstraintDefinitionException('At least one field has to be specified.');
        }
    }
328466
public function find( $key, $disableLateLoading = null )
    {

        // $disableLateLoading default value management
        if( !is_bool( $disableLateLoading ) ) {
            $disableLateLoading = false;
        }

        // empty key
        if( is_null( $key ) or !is_scalar( $key ) or strlen( trim( $key ) ) === 0 ) {
            return null;
        }

        $class = $this->entityClass;

        try {
            return $this->entityFactory( $key, $disableLateLoading );
        } catch( \Exception $e ) {
            return null;
        }

    }
345943
public function getForeignKey($constraintName)
    {
        $constraintName = $this->normalizeIdentifier($constraintName);
        if (! $this->hasForeignKey($constraintName)) {
            throw SchemaException::foreignKeyDoesNotExist($constraintName, $this->_name);
        }

        return $this->_fkConstraints[$constraintName];
    }