Validate the subject.

@param Sharing $constraint   The sharing constraint
@param string  $subjectClass The subject class
335455
private function validateSubject(Sharing $constraint, $subjectClass): void
    {
        $res = $this->validateClass($constraint, $subjectClass, $constraint->subjectClass);

        if ($res && !$this->sharingManager->hasSharingVisibility(SubjectIdentity::fromClassname($subjectClass))) {
            $this->context->buildViolation($constraint->classNotManagedMessage)
                ->atPath($constraint->subjectClass)
                ->setParameter('%class_property%', $constraint->subjectClass)
                ->setParameter('%class%', $subjectClass)
                ->addViolation()
            ;
        }
    }
79959
public function validate($value, Constraint $constraint)
    {
        /**@var $constraint CodeUnit */
        if (!in_array($value, $this->codes)) {
            $this->context->buildViolation($constraint->message)
                ->setParameter('{{ value }}', $value)
                ->addViolation();
        }
    }
1032368
public function isValidFor($mixed, $subject = null, ArrayAccess $error = null)
    {
        $result = parent::isValid($mixed, $error);
        if ($result === true) {
            $uID = 0;
            if ($subject) {
                if (is_object($subject)) {
                    if (!method_exists($subject, 'getUserID')) {
                        throw new InvalidArgumentException(t('Invalid subject type supplied to validator.'));
                    }
                    $uID = (int) $subject->getUserID();
                } else {
                    $uID = (int) $subject;
                }
            } else {
                $uID = 0;
            }
            $qb = $this->connection->createQueryBuilder();
            $qb
                ->select('u.uID')
                ->from('Users', 'u')
                ->where($qb->expr()->eq('u.uEmail', $qb->createNamedParameter($mixed)))
            ;
            if ($uID !== 0) {
                $qb->andWhere($qb->expr()->neq('u.uID', $qb->createNamedParameter($uID)));
            }
            if ($qb->execute()->fetchColumn() !== false) {
                $result = false;
                if ($error) {
                    $message = $this->getErrorString($uID === 0 ? self::E_EMAIL_IN_USE : self::E_EMAIL_USED_BY_ANOTHER_USER, $mixed);
                    if ($message) {
                        $error[] = $message;
                    }
                }
            }
        }

        return $result;
    }
113503
public function validate($location, Constraint $constraint)
    {
        if (null === $location) {
            $this->context->addViolation($constraint->message);

            return;
        }

        $hasChildren = new HasChildren($this->locationService);

        if (!$hasChildren->isSatisfiedBy($location)) {
            $this->context->addViolation($constraint->message);
        }
    }
1303735
public function validate($value, Constraint $constraint)
    {
        $result = $this->repository->hasOtherNodeWithSameParentAndOrder(
            $value->getParentId(),
            $value->getOrder(),
            $value->getNodeId(),
            $value->getSiteId()
        );

        if (true === $result) {
            $this->context->buildViolation($constraint->message)->addViolation();
        }
    }
1146590
public function validate($propertyValue, Constraint $constraint)
    {
        // Implement your validation logic.
        // Return early if the value is valid
        // For example:
        if ($propertyValue === 'isValid') {
            return;
        }

        // Finally, if not valid, add the violation
        $this->context->buildViolation($constraint->message)
                      ->setParameter('{{ string }}', $propertyValue)
                      ->addViolation();
    }
172916
public function validate($user, Constraint $constraint)
    {
        $code = $user->getAdministrativeCode();
        if (!empty($code) && $this->platformConfigHandler->getParameter('is_user_admin_code_unique')) {
            $tmpUser = $this->om->getRepository('ClarolineCoreBundle:User')->findOneByAdministrativeCode($code);
            if ($tmpUser && $tmpUser->getUsername() !== $user->getUsername()) {
                $this->context->addViolationAt(
                    'administrativeCode',
                    $this->translator->trans($constraint->error, ['%code%' => $code], 'platform')
                );
            }
        }
    }
354474
public function validate($subject): bool
    {
        $validatedCount = 0;
        foreach ($this->schema['oneOf'] as $schema) {
            $nodeValidator = new NodeValidator($schema, $this->rootSchema);
            if ($nodeValidator->validate($subject)) {
                $validatedCount++;
            }
        }
        return $validatedCount === 1;
    }
362259
protected function _error(Subject $subject)
    {
        $subject->set(['success' => false, 'created' => false]);

        $this->_trigger('afterSave', $subject);
        $this->setFlash('error', $subject);
        $this->_trigger('beforeRender', $subject);
    }
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();
        }
    }
311111
public function validate($subject): bool
    {
        if (\is_array($this->schema['patternProperties'])) {
            foreach ($this->schema['patternProperties'] as $pattern => $patternSchema) {
                foreach ($subject as $propertyName => $propertyData) {
                    if (\preg_match(sprintf('/%s/', $pattern), $propertyName)) {
                        $nodeValidator = new NodeValidator($patternSchema, $this->rootSchema);
                        if (!$nodeValidator->validate($propertyData)) {
                            return false;
                        }
                    }
                }
            }
        }
        return true;
    }
90546
public function validate($value, Constraint $constraint)
    {
        $url = $this->helper->getUrl($value);
        if($this->browser->get($url)->getStatusCode() >= 400) {
            $this->context->addViolation($constraint->message, array('%string%' => $url));
        }
    }
91787
public function validate($group, Constraint $constraint)
    {
        $check = $this->container->get('admin.configuration.configgroup_manager')->getRepository()->findOneBySectionAndGroupName($group->getConfigSection()->getName(), $group->getName());
        if ( $check && $check->getId() != $group->getId()) {
            $message = $this->container->get('translator')->trans(
                $constraint->message,
                array(
                    '%group%' => $group->getName(),
                    '%section%' => $group->getConfigSection()->getName()
                ),
                'VinceTAdminConfigurationBundle'
            );
            $this->context->addViolation($message);
        }
    }
162104
protected function validateDelimiter(Constraint $constraint)
    {
        if (strlen($constraint->delimiter) > 2) {
            throw new ConstraintDefinitionException(sprintf('"%s" is not a valid delimiter', $constraint->delimiter));
        }
    }
500405
public function match($pattern, $subject)
    {
        if (! $this->validate($pattern)) {
            return false;
        }
        
        return $this->getInstance()->match($pattern, $subject);
    }
1146524
public function validate($order, Constraint $constraint): void
    {
        /** @var OrderInterface $order */
        Assert::isInstanceOf($order, OrderInterface::class);

        /** @var OrderShippingMethodEligibility $constraint */
        Assert::isInstanceOf($constraint, OrderShippingMethodEligibility::class);

        $shipments = $order->getShipments();
        if ($shipments->isEmpty()) {
            return;
        }

        foreach ($shipments as $shipment) {
            if (!$this->methodEligibilityChecker->isEligible($shipment, $shipment->getMethod())) {
                $this->context->addViolation(
                    $constraint->message,
                    ['%shippingMethodName%' => $shipment->getMethod()->getName()]
                );
            }
        }
    }
165807
public function validate($subject): bool
    {
        // This keyword's value MUST be an object. Each property specifies a dependency. Each dependency value MUST
        // be an array or a valid JSON Schema.
        if (\is_array($this->schema['dependencies']) && count($this->schema['dependencies']) > 0) {
            foreach ($this->schema['dependencies'] as $propertyName => $dependentProperties) {
                // If the dependency value is an array, each element in the array, if any, MUST be a string, and MUST
                // be unique. If the dependency key is a property in the instance, each of the items in the
                // dependency value must be a property that exists in the instance.
                if (\is_int(\array_keys($dependentProperties)[0])) {
                    if (!$this->validateClassicDependencies($subject, $propertyName, $dependentProperties)) {
                        return false;
                    }
                    // If the dependency value is a subschema, and the dependency key is a property in the instance,
                    // the entire instance must validate against the dependency value.
                } elseif (\is_string(\array_keys($dependentProperties)[0])) {
                    if (!$this->validateSchemaDependencies($subject, $propertyName, $dependentProperties)) {
                        return false;
                    }
                }

            }
        }
        return true;
    }