Hook for the entity validation.
@param  \Asgard\Hook\Chain                    $chain
@param  \Asgard\Entity\Entity                 $entity
@param  \Asgard\Validation\ValidatorInterface $validator
768992
public function hookValidation(\Asgard\Hook\Chain $chain, \Asgard\Entity\Entity $entity, \Asgard\Validation\ValidatorInterface $validator) {
		$this->getDataMapper()->prepareValidator($entity, $validator);
	}
691344
private function validate_validator( $value, ExtendedValidatorInterface $validator, $key, $message ) {

		$valid = $validator->is_valid( $value );
		if ( $valid ) {
			return TRUE;
		}

		if ( $validator instanceof MultiValidatorInterface ) {
			$data = $validator->get_error_data();
			foreach ( $data as $code => $code_data ) {
				foreach ( $code_data as $error_data ) {
					$this->validator_log_error( $code, $error_data, $key, $message );
				}
			}

			return FALSE;
		}

		$this->validator_log_error( $validator->get_error_code(), $validator->get_input_data(), $key, $message );

		return FALSE;
	}
149315
private void validate(Entity entity) {
    MailSettingsImpl mailSettings = new MailSettingsImpl(entity);
    if (mailSettings.isTestConnection()
        && mailSettings.getUsername() != null
        && mailSettings.getPassword() != null) {
      mailSenderFactory.validateConnection(mailSettings);
    }
  }
366716
public static function isValid($validator, $value)
    {
        /** @var ValidatorInterface $validator */
        $validator = static::create($validator);
        $result = $validator->isValid($value);
        static::$_messages = $validator->getMessages();
        return $result;
    }
1042039
public function validate(EntityInterface $entity)
    {
        if (!$entity instanceof ApplicationGroup) {
            throw new Exception(
                sprintf('The Entity to validate must be an instance of %s', Role::class)
            );
        }

        $this->validateName($entity->getName());
        $errors = $this->getErrors();

        return empty($errors);
    }
1160558
private function loadValidatorLoader(string $entityManagerName, ContainerBuilder $container) : void
    {
        if (! interface_exists(LoaderInterface::class) || ! class_exists(DoctrineLoader::class)) {
            return;
        }

        $validatorLoaderDefinition = $container->register(sprintf('doctrine.orm.%s_entity_manager.validator_loader', $entityManagerName), DoctrineLoader::class);
        $validatorLoaderDefinition->addArgument(new Reference(sprintf('doctrine.orm.%s_entity_manager', $entityManagerName)));

        $validatorLoaderDefinition->addTag('validator.auto_mapper', ['priority' => -100]);
    }
704732
protected function registerValidators(RequestValidator $validator)
    {
        $validator->registerValidator('post_edit_handler', 'FluxBB\Validation\PostValidator');
        $validator->registerValidator('reply_handler', 'FluxBB\Validation\PostValidator');
        $validator->registerValidator('new_topic_handler', 'FluxBB\Validation\PostValidator');
        $validator->registerValidator('admin.options.set', 'FluxBB\Validation\OptionsValidator');
        $validator->registerValidator('handle_registration', 'FluxBB\Validation\UserValidator');
    }
968935
public function validator($entity, $data)
    {
        return ValidationManager::validator(self::getInstance()->getEntityStructure($entity), $data);
    }
1253231
private function parseChain($chain = []): void
    {
        if (!\is_array($chain)) {
            throw new InvalidArgumentException('Validators chain must be an array');
        }
        foreach ($chain as $k => $v) {
            if ($v instanceof AbstractSpecific) {
                // value is an instance of AbstractSpecific
                $reflection = new \ReflectionClass($v);
                $name = \str_replace($reflection->getNamespaceName().'\\', '', $reflection->getName());
                $this->chain[$name] = $v;
            } elseif (\is_string($k) && \is_array($v)) {
                // key is a string (validator name) and value is an array (validator options)
                $className = '\\MS\\LightFramework\\Validator\\Specific\\'.$k;
                if (!\class_exists($className)) {
                    throw new InvalidArgumentException('Validator "'.$k.'" not found');
                }
                $this->chain[$k] = new $className($v);
            } elseif (\is_numeric($k) && \is_array($v)) {
                // key is a numeric and value is an array (validator name => validator options)
                $this->parseChain($v);
            } else {
                // incorrect chain format
                $exMsg = 'Validator chain element must be either instance of AbstractValidator ';
                $exMsg .= 'or array("validatorName" => array(options))';
                throw new InvalidArgumentException($exMsg);
            }
        }
    }
619776
public function validate(BaseEntityInterface $entity, array $groups = [])
    {
        if ($this->validator) {
            $violations = $this->validator->validate($entity, null, $groups);

            if ($violations->count()) {
                throw new EntityValidateException('Validation error', $violations, 400);
            }
        }

        return $entity;
    }
483744
protected function validateAndCompleteEntity($entityIdentifier, $entityDefinition)
	{
		if(!isset($entityDefinition['label']))
		{
			throw MappingException::requiredMapping($this->itemClass, 'label', $entityIdentifier);
		}
		elseif(!settype($entityDefinition['label'], 'string'))
		{
			throw MappingException::invalidMappingType($this->itemClass, 'label', 'string', $entityIdentifier);
		}
		else
		{
			$this->entityLabels[$entityIdentifier] = $entityDefinition['label'];
		}

		if(!isset($entityDefinition['entityClass']))
		{
			throw MappingException::requiredMapping($this->itemClass, 'entityClass', $entityIdentifier);
		}
		elseif(!settype($entityDefinition['entityClass'], 'string'))
		{
			throw MappingException::invalidMappingType($this->itemClass, 'entityClass', 'string', $entityIdentifier);
		}
		else
		{
			$this->entityClasses[$entityIdentifier] = $entityDefinition['entityClass'];
		}
	}
1067311
public function valid(EntityContract $entity, $value)
    {
        $validator = Validation::createValidator();

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

        return $violations->count() === 0;
    }
1158687
public function setValidator(Validator $validator)
    {
        $this->validator = $validator;
        
        $validator->configureRule($this);
        
        return $this;
    }
954009
public function setValidator(Validator $validator) {
        $this->_validator = $validator;

        // Only set model events if we plan on validating
        $this->on('model', $this);

        return $this;
    }
56101
public function withValidator($validator)
    {
        if ($validator->passes()) {
            $validator->after(function ($validator) {

                try {
                    // get validated data
                    $data = $this->validated();

                    // Set temporary DB connection
                    config(['database.connections.mysql' => [
                        'driver' => 'mysql',
                        'host' =>  $data['DB_HOST'],
                        'database' => $data['DB_DATABASE'],
                        'prefix' => $data['DB_PREFIX'],
                        'username' => $data['DB_USERNAME'],
                        'password' => $data['DB_PASSWORD'],
                        'charset' => 'utf8',
                        'collation' => 'utf8_unicode_ci',
                        'strict' => true,
                        'engine' => 'InnoDB',
                    ]]);

                    // Check DB connection and exists table
                    \DB::purge('mysql');
                    \DB::reconnect('mysql');
                    \DB::setTablePrefix($data['DB_PREFIX']);
                    \DB::connection()->getPdo();
                    if (is_null(\DB::connection('mysql')->getDatabaseName())) {
                        throw new InstallerFailed(__('msg.not_dbconnect'));
                    }

                    // 3 Manipulation of the database
                    \DB::beginTransaction();

                    // Make migrate
                    $exitCode = \Artisan::call('migrate', ['--force' => true]);
                    $outputMigrate = \Artisan::output();
                    session()->flash('flash_output_migrate', $outputMigrate);

                    \DB::commit();
                } catch (\InstallerFailed $e) {
                    $validator->errors()->add('database', $e->getMessage());
                } catch (\PDOException $e) {
                    $validator->errors()->add('database', $e->getMessage());
                } finally {
                    \DB::rollback();
                }

            });
        }

        return $validator;
    }
700626
protected function failedValidation(Validator $validator)
    {
        throw (new ValidationException($validator))
                    ->errorBag($this->errorBag)
                    ->redirectTo($this->getRedirectUrl());
    }
829
public function prepareValidator(\Asgard\Validation\ValidatorInterface $validator, array $locales=[]) {
		$this->getDefinition()->trigger('validation', [$this, $validator], function($chain, $entity, $validator) use($locales) {
			$messages = [];

			foreach($this->getDefinition()->properties() as $name=>$property) {
				if($locales && $property->get('i18n')) {
					foreach($locales as $locale) {
						if($property->get('many')) {
							if($this->get($name, null, false) instanceof ManyCollection) {
								foreach($this->get($name, null, false) as $k=>$v) {
									$propValidator = $validator->attribute($name.'.'.$locale.'.'.$k);
									$property->prepareValidator($propValidator);
									$propValidator->formatParameters(function(&$params) use($name) {
										$params['attribute'] = $name;
									});
									$propValidator->ruleMessages($property->getMessages());
								}
							}
						}
						else {
							$propValidator = $validator->attribute($name.'.'.$locale);
							$property->prepareValidator($propValidator);
							$propValidator->formatParameters(function(&$params) use($name) {
								$params['attribute'] = $name;
							});
							$propValidator->ruleMessages($property->getMessages());
						}
					}
				}
				else {
					if($property->get('many')) {
						if($this->get($name, null, false) instanceof ManyCollection) {
							foreach($this->get($name, null, false) as $k=>$v) {
								$propValidator = $validator->attribute($name.'.'.$k);
								$property->prepareValidator($propValidator);
								$propValidator->formatParameters(function(&$params) use($name) {
									$params['attribute'] = $name;
								});
								$propValidator->ruleMessages($property->getMessages());
							}
						}
					}
					else {
						$propValidator = $validator->attribute($name);
						$property->prepareValidator($propValidator);
						$propValidator->ruleMessages($property->getMessages());
					}
				}
			}

			$messages = array_merge($messages, $this->getDefinition()->messages());
			$validator->attributesMessages($messages);

			$validator->set('entity', $this);
		});

		return $validator;
	}