This method is called automatically by the EntityFactory when initialisig the Entity, by way of the
EntityDependencyInjector

@param EntityDataValidatorInterface $entityDataValidator
341214
public function injectEntityDataValidator(EntityDataValidatorInterface $entityDataValidator)
    {
        $this->entityDataValidator = $entityDataValidator;
        $this->entityDataValidator->setEntity($this);
    }
1067311
public function valid(EntityContract $entity, $value)
    {
        $validator = Validation::createValidator();

        $violations = $validator->validate($value, [
            new Url(),
        ]);

        return $violations->count() === 0;
    }
685878
public function validateEntity(ExecutionContextInterface $context)
    {
        if ($this->getType() == self::TYPE_PAGE_LINK && !$this->getNodeTranslation()) {
            $context->buildViolation('Please select a page')
              ->atPath('nodeTranslation')
              ->addViolation();
        } elseif ($this->getType() == self::TYPE_URL_LINK) {
            if (strlen($this->getTitle()) == 0) {
                $context->buildViolation('Please set the link title')
                  ->atPath('title')
                  ->addViolation();
            }
            if (strlen($this->getUrl()) == 0) {
                $context->buildViolation('Please set the link URL')
                  ->atPath('url')
                  ->addViolation();
            }
        }
    }
269280
protected function assertEntityIsValid($entity, $scope = null)
    {
        if (!$this->validator) {
            throw new \BadMethodCallException(sprintf(
                'Method %s() cannot be used while validator is not configured.',
                __METHOD__
            ));
        }

        $scopes = $scope ? (array) $scope : null;

        $violationList = $this->validator->validate(
            $entity,
            null,
            $scopes
        );

        if (!count($violationList)) {
            return;
        }

        throw new ValidationException($entity, $violationList, $scopes);
    }
1120160
public void addValidator(Validator validator) {

        if (validator == null) {
            throw new NullPointerException();
        }

        if (validators == null) {
            validators = new AttachedObjectListHolder<Validator>();
        }
        validators.add(validator);

    }
216124
@Override
	public void processValidation(Object entity) {
		
		// Si la liste des validateurs est vide
		if(this.validators == null || this.validators.length == 0) {
						
			// On sort
			return;
		}
		
		// Classe d'execution de la validation
		SizeDAOValidatorRule rule = new SizeDAOValidatorRule();
		
		// Parcours de la liste
		for (Annotation annotation : this.validators) {
			
			// On initialize
			rule.initialize(annotation, entityManager, this.systemDAOMode, this.systemEvaluationTime);
			
			// On valide
			rule.processValidation(entity);
		}
	}
38891
public function initialize(
        SessionInterface $session,
        ObjectTypeInterface $objectType,
        OperationContextInterface $context,
        ObjectDataInterface $objectData = null
    ) {
        if (count($this->getMissingBaseProperties($objectType->getPropertyDefinitions())) !== 0) {
            throw new CmisInvalidArgumentException(
                sprintf(
                    'Object type must have at least the base property definitions! '
                    . 'These property definitions are missing: %s',
                    implode(', ', PropertyIds::getBasePropertyKeys())
                )
            );
        };

        $this->session = $session;
        $this->objectType = $objectType;
        $this->secondaryTypes = null;
        $this->creationContext = clone $context;
        $this->refreshTimestamp = (integer) round(microtime(true) * 1000);

        if ($objectData !== null) {
            $this->initializeObjectData($objectData);
        }
    }
79766
public function onValidate(EiEntry $eiEntry) { 
		$mmi = new MagicMethodInvoker($this->magicContext);
		$mmi->setClassParamObject(Eiu::class, new Eiu($eiEntry, $this->magicContext));
		$mmi->invoke(null, new \ReflectionFunction($this->closure));
	}
777144
public function scheduleForUpdate($entity) : void
    {
        $oid = spl_object_id($entity);

        if (! isset($this->entityIdentifiers[$oid])) {
            throw ORMInvalidArgumentException::entityHasNoIdentity($entity, 'scheduling for update');
        }

        if (isset($this->entityDeletions[$oid])) {
            throw ORMInvalidArgumentException::entityIsRemoved($entity, 'schedule for update');
        }

        if (! isset($this->entityUpdates[$oid]) && ! isset($this->entityInsertions[$oid])) {
            $this->entityUpdates[$oid] = $entity;
        }
    }
512775
private static function annotateAndValidateModel($modelState) {
        foreach ($modelState->items as $item) {
            self::annotateAndValidateModelEntry($modelState, $item->key);
        }
    }
85546
public function validate() {
		parent::validate();

		if ($this->getEntity() === null) {
			throw new ValidationException("'entity' can't be null", 'entity', $this);
		}
		if ($this->getEntityStates() === null) {
			throw new ValidationException("'entityStates' can't be null", 'entityStates', $this);
		}
		if ($this->getUrl() === null) {
			throw new ValidationException("'url' can't be null", 'url', $this);
		}
	}
117486
private function buildEntityInjectMethodsForEntity(EntityInterface $entity): void
    {
        $reflection = $entity::getDoctrineStaticMeta()->getReflectionClass();
        $entityFqn  = $this->leadingSlash($reflection->getName());
        if (array_key_exists($entityFqn, $this->entityInjectMethods)) {
            return;
        }
        $this->entityInjectMethods[$entityFqn] = [
            self::TYPE_KEY_INSTANCE => [],
            self::TYPE_KEY_STATIC   => [],
        ];

        $methods = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
        foreach ($methods as $method) {
            if (!\ts\stringStartsWith($method->getName(), self::INJECT_DEPENDENCY_METHOD_PREFIX)) {
                continue;
            }
            $typeKey = $method->isStatic() ? self::TYPE_KEY_STATIC : self::TYPE_KEY_INSTANCE;

            $this->entityInjectMethods[$entityFqn][$typeKey][$method->getName()] =
                $this->getDependencyForInjectMethod($method);
        }
    }
348896
@Override
    public boolean validateEntity(Class clazz)
    {
        EntityValidatorAgainstCounterColumn entityValidatorAgainstSchema = new EntityValidatorAgainstCounterColumn();
        return entityValidatorAgainstSchema.validateEntity(clazz);
    }
887810
public function addValidator(ValidatorInterface $validator)
    {
        if ($validator instanceof ObjectValidatorInterface) {
            $validator->setValidatedInstancesContainer = $this->validatedInstancesContainer;
        }
        $this->validators->attach($validator);
    }
493783
function validate(entityAspect, validator, value, context) {
    var ve = validator.validate(value, context);
    if (ve) {
      entityAspect._addValidationError(ve);
      return false;
    } else {
      var key = ValidationError.getKey(validator, context ? context.propertyName : null);
      entityAspect._removeValidationError(key);
      return true;
    }
  }
1149898
protected function failedValidation(Validator $validator)
    {
        if ($this->isApiRequest()) {
            throw new ValidationException($validator, $this->getErrorCodes());
        }

        parent::failedValidation($validator);
    }
1015991
protected function validate()
    {
        if (!$this->validator instanceof ValidatorInterface) {
            return;
        }

        $valid = true;
        if ($this->getEntityContainerMap()->count() > 0) {
            $entityContainers = $this->getEntityContainerMap()->getAll();

            $this->logger->debug('start form entity valiation', array('name' => $this->getName()));

            /**
             * @var $entityContainer    \Naucon\Form\Mapper\EntityContainerInterface
             */
            foreach ($entityContainers as $entityContainer) {
                if ($entityContainer->hasValidate()) {
                    $this->logger->debug('invoke form prevalidator hook', array('name' => $this->getName(), 'entity' => $entityContainer->getName()));
                    // prevalidation hook
                    $entityContainer->invokeHook('prevalidatorHook');

                    $violations = $this->validator->validate($entityContainer->getEntity(), null, $this->configuration->get('validation_groups'));
                    if (is_array($violations) && count($violations)) {
                        // TODO set FormValidations to $entityContainer
                        /**
                         * @var \Naucon\Form\Validator\ViolationInterface $violation
                         */
                        $violationsDump = array();
                        foreach ($violations as $violation) {
                            $violationsDump[$violation->getName()] = $violation->getMessage();
                            $entityContainer->setError($violation->getName(), new FormError($violation->getName(), $violation->getMessage()));
                        }
                        $valid = false;

                        $this->logger->debug('form entity violations', array('name' => $this->getName(), 'entity' => $entityContainer->getName(), 'violations' => $violationsDump));
                    }

                    // postvalidation hook
                    $this->logger->debug('invoke form postvalidator hook', array('name' => $this->getName(), 'entity' => $entityContainer->getName()));
                    $entityContainer->invokeHook('postvalidatorHook');

                    if ($entityContainer->hasErrors()) {
                        $valid = false;
                    }
                }
            }
        }

        if ($valid) {
            $this->logger->debug('finished form entity valiation successful', array('name' => $this->getName()));
        } else {
            $this->logger->debug('finished form entity valiation failed', array('name' => $this->getName()));
        }
        $this->setValid($valid);
    }