Validate if the Alias is valid and unique.

@param FormEvent $event
167806
public function validate(FormEvent $event)
    {
        /** @var Alias $alias */
        $alias = $event->getData()->getNode()->alias;

        if ($alias instanceof ValueHolderInterface) {
            $alias = $alias->getWrappedValueHolderValue();
        }

        $violations = $this->validator->validate($alias);

        if (!$violations) {
            return;
        }

        $mapper = new ViolationMapper();
        /** @var ConstraintViolationInterface $violation */
        foreach ($violations as $violation) {
            $mapper->mapViolation($violation, $event->getForm(), true);
        }
    }
1279651
public function onPreSubmit(FormEvent $event)
    {
        $data = $event->getData();

        if ($data['file'] instanceof UploadedFile) {
            $event->getForm()->remove('remove');
        }

        if (empty($data['file']) && (!isset($data['remove']) || !$data['remove'])) {
            $event->setData($event->getForm()->getViewData());
        }
    }
1100577
public function postSubmit(FormEvent $e)
    {
        if ($e->getForm()->has($this->property) && $e->getForm()->getRoot()->isValid()) {
            $menuItem = $e->getForm()->get($this->property)->getData();

            if ($menuItem->isAddToMenu()) {
                if (!$menuItem->getTitle()) {
                    $menuItem->setTitle((string)$e->getData());
                }
                $menuItem->setPath($this->provider->url($e->getData(), array('aliasing' => false)));
                $this->mm->addItem($menuItem);
            } elseif ($menuItem->getId()) {
                $this->mm->removeItem($menuItem);
            }
        }
    }
1347801
public function onPostBind(FormEvent $event)
    {
        $form = $event->getForm();

        $request = $this->container->get('request');
        if (!$request->request->has(Autocomplete::KEY_PATH)) {
            return;
        }

        $name = $request->request->get(Autocomplete::KEY_PATH);
        $parts = $this->parseNameIntoParts($name, $form->getRoot()->getName());

        $field = $form->getRoot();
        foreach ($parts as $part) {
            if (!$field->has($part)) {
                return;
            }
            $field = $field->get($part);
        }

        if ($field !== $form) {
            return;
        }

        $searchFields = $form->getConfig()->getAttribute('search-fields');
        $template = $this->options['template'];
        $extraParams = $this->options['extra_params'];

        $results = $this->resultsFetcher->getPaginatedResults($request, $form->getConfig()->getAttribute('query-builder'), $searchFields);
        // $results still holds the total amount through (count)
        $ttl = count($results);
        $responseData = array();
        $options = array('search-fields' => $searchFields, 'extra_params' => $extraParams);
        foreach ($results as $result) {
            $identifier = $this->options['identifier_propertypath'] ? $this->propertyAccessor->getValue($result, $this->options['identifier_propertypath']) : $result->getId();
            $responseData[] = $this->responseFormatter->formatResultLineForAutocompleteResponse($template, $result, $options, $identifier);
        }
        throw new UnexpectedResponseException(new AutocompleteResponse($responseData, $ttl));
    }
1032969
public function onPreSetData(FormEvent $event)
    {
        /** @var CustomUrlAddData $data */
        $data = $event->getData();
        $location = $data->getLocation();
        if (null === $location) {
            return;
        }
        $contentInfo = $location->getContentInfo();
        $versionInfo = $this->contentService->loadVersionInfo($contentInfo);
        $contentLanguages = $versionInfo->languageCodes;

        $form = $event->getForm();

        $form->add(
            'language',
            ChoiceType::class,
            [
                'multiple' => false,
                'choice_loader' => new CallbackChoiceLoader($this->getCallableFilter($contentLanguages)),
                'choice_value' => 'languageCode',
                'choice_label' => 'name',
            ]
        );
    }
948454
public function validateSegment($element, FormStateInterface $formState)
    {
        $originalValue = trim($formState->getValue('segment'));

        if (!empty($originalValue)) {

            $value = $this->seoService->normalizeSegment($originalValue);

            if ($originalValue !== $value) {
                $formState->setError(
                    $element,
                    $this->t(
                        "The alias '%alias' is invalid and has been normalized to: <strong>%normalized</strong>, please change the value below.",
                        ['%alias' => $originalValue, '%normalized' => $value]
                    )
                );
            }

            $formState->setValueForElement($element, $value);
        }
    }
704987
public boolean validateEventName(String eventName) {
        boolean isValid = false;
        if ((AuditConstants.validEventNamesList).contains(eventName))
            isValid = true;
        return isValid;
    }
809274
public static function normalize(FormEvent $event)
    {
        $data = $event->getData();

        unset(
            $data['type'],
            $data['creator'],
            $data['linked'],
            $data['changer'],
            $data['breadcrumb'],
            $data['originTemplate'],
            $data['changed'],
            $data['changer'],
            $data['path'],
            $data['nodeState'],
            $data['internal'],
            $data['availableLocales'],
            $data['contentLocales'],
            $data['hasSub'],
            $data['published'],
            $data['shadowLocales'],
            $data['shadowEnabled'],
            $data['publishedState'],
            $data['created'],
            $data['_embedded'],
            $data['_links'],
            $data['navigation'],
            $data['id'],
            $data['parentUuid']
        );

        $normalized = [
            'title' => self::getAndUnsetValue($data, 'title'),
            'resourceSegment' => isset($data['url']) ? $data['url'] : null,
            'redirectType' => self::getAndUnsetRedirectType($data),
            'extensions' => self::getAndUnsetValue($data, 'ext'),
            'redirectTarget' => self::getAndUnsetValue($data, 'internal_link'),
            'redirectExternal' => self::getAndUnsetValue($data, 'external'),
            'navigationContexts' => self::getAndUnsetValue($data, 'navContexts'),
            'shadowLocale' => self::getAndUnsetValue($data, 'shadowBaseLanguage'),
            'structureType' => self::getAndUnsetValue($data, 'template'),
            'shadowLocaleEnabled' => self::getAndUnsetValue($data, 'shadowOn') ? true : false,
            'parent' => self::getAndUnsetValue($data, 'parent'),
            'workflowStage' => self::getAndUnsetValue($data, 'workflowStage'),
            'authored' => self::getAndUnsetValue($data, 'authored'),
            'author' => self::getAndUnsetValue($data, 'author'),
            'structure' => $data,
        ];

        foreach ($normalized as $key => $value) {
            if (null === $value) {
                unset($normalized[$key]);
            }
        }

        $event->setData($normalized);
    }
243469
function validEvent(eventKeys, typeKeys, emitter, typeName) {

    if (eventKeys.length > typeKeys.length) {
      emitter.emit('error', 'An event has more properties than its type, ' + typeName +
        '. Event properties: [' + eventKeys + ']. ' + typeName + ' properties: [' + typeKeys + '].');
      return false;
    } else {

      for (var i = 0; i < eventKeys.length; i++) {
        if (typeKeys.indexOf(eventKeys[i]) === -1) {
          emitter.emit('error', 'An event has property "' + eventKeys[i] + '" which is not in its type, ' + typeName +
            '. Event properties: [' + eventKeys + ']. ' + typeName + ' properties: [' + typeKeys + '].');
          return false;
        }
      }
      return true;
    }
  }
1274919
public function preBind(FormEvent $event)
    {
        // BC prevention for class extending this one.
        if (self::class !== \get_called_class()) {
            @trigger_error(
                __METHOD__.' method is deprecated since 2.3 and will be renamed in 4.0.'
                .' Use '.__CLASS__.'::preSubmit instead.',
                E_USER_DEPRECATED
            );
        }

        $this->preSubmit($event);
    }
1186628
public function setRedirect(FormEvent $event)
    {
        $targetPath = $this->getTargetPath($event->getRequest());

        if ($targetPath) {
            $event->setResponse(new RedirectResponse($targetPath));

            return;
        }

        $this->setRedirecToLogin($event);
    }
645642
public function onPreSubmit(FormEvent $event)
    {
        $contentLanguages = [];
        $form = $event->getForm();
        $data = $event->getData();

        if (isset($data['contentType'])) {
            try {
                $contentType = $this->contentTypeService->loadContentTypeByIdentifier($data['contentType']);
            } catch (NotFoundException $e) {
                $contentType = null;
            }

            if (null !== $contentType) {
                $contentLanguages = array_keys($contentType->getNames());
            }
        }

        $this->addLanguageFields($form, $contentLanguages);
    }
253831
public function onEvent(Event $event): void
    {
        if (!$event instanceof GetResponseEvent || !$this->injected) {
            if (null !== ($filter = $this->getFilter())) {
                $this->injectParameters($filter);
            }
        }
    }
776004
public function preSetData(FormEvent $event)
    {
        $user = $event->getData();
        if (null === $user) {
            return;
        }
        if($this->currentUser !== null && $this->currentUser !== $user) {
            $event->getForm()->add($this->factory->createNamed('activated', 'checkbox', null, array(
                'data' => $user->getRegistrationToken() ? false : true,
                'auto_initialize' => false,
                'label' => 'Activated',
                'required' => false,
                'mapped' => false)));
        }
    }
193012
public function preSetData(FormEvent $event)
    {
        $form = $event->getForm();

        foreach ($form as $name => $child) {
            $form->remove($name);
        }
    }
76212
public function preSetData(FormEvent $event)
    {
        $form = $event->getForm();
        $data = $event->getData();

        if (null === $data) {
            throw new \InvalidArgumentException('Can\'t handle null datas.');
        }

        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
            throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
        }

        foreach ($form as $name => $child) {
            $form->remove($name);
        }

        foreach ($this->schema->getGroups() as $schemaGroup) {
            $form->add($schemaGroup->getName(), new GroupType(), array('label' => $schemaGroup->getTitle()));
            $groupForm = $form->get($schemaGroup->getName());
            foreach ($schemaGroup->getDefinitions() as $schemaDefinition) {
                if (true === $schemaDefinition->getVirtual()) {
                    continue;
                }
                $this->appendProperForm($groupForm, $schemaDefinition);
                $this->appendProperData($data, $schemaDefinition);
            }
        }

        $event->setData($data);
    }
498037
public function preSetData(FormEvent $event)
    {
        $entity = $event->getData();
    
        if ($entity instanceof FileInterface && null !== $entity->getId()){
            try {
                $this->fileManager->copyFileToTemporaryDirectory($entity);
            } catch (\Gaufrette\Exception\FileNotFound $e) {
                $event->setData(null);
            }
        }
    }