getDomainUrls example

$definition = $this->getCustomerCreateValidationDefinition($isGuest$data$context);

        if ($additionalValidations) {
            foreach ($additionalValidations->getProperties() as $key => $validation) {
                $definition->add($key, ...$validation);
            }
        }

        if ($validateStorefrontUrl) {
            $definition
                ->add('storefrontUrl', new NotBlank()new Choice(array_values($this->getDomainUrls($context))));
        }

        $accountType = $data->get('accountType', CustomerEntity::ACCOUNT_TYPE_PRIVATE);
        $definition->addSub('billingAddress', $this->getCreateAddressValidationDefinition($data$accountType$data->get('billingAddress')$context));

        if ($data->has('shippingAddress')) {
            /** @var DataBag $shippingAddress */
            $shippingAddress = $data->get('shippingAddress');
            $shippingAccountType = $shippingAddress->get('accountType', CustomerEntity::ACCOUNT_TYPE_PRIVATE);
            $definition->addSub('shippingAddress', $this->getCreateAddressValidationDefinition($data$shippingAccountType$shippingAddress$context));
        }

        


        if (!empty($dataBag->get('lastName'))) {
            $definition->add('lastName', new NotBlank()new Regex([
                'pattern' => self::DOMAIN_NAME_REGEX,
                'match' => false,
            ]));
        }

        if ($validateStorefrontUrl) {
            $definition
                ->add('storefrontUrl', new NotBlank()new Choice(array_values($this->getDomainUrls($context))));
        }

        $validationEvent = new BuildValidationEvent($definition$dataBag$context->getContext());
        $this->eventDispatcher->dispatch($validationEvent$validationEvent->getName());

        return $definition;
    }

    /** * @param SubscribeRequest $data * * @return array{id: string, languageId: string, salesChannelId: string, status: string, hash: string, email: string, storefrontUrl: string, firstName?: string, lastName?: string, zipCode?: string, city?: string, street?: string, salutationId?: string} */

        $validation = new DataValidationDefinition('customer.email.recover');

        $validation
            ->add(
                'email',
                new Email()
            );

        if ($validateStorefrontUrl) {
            $validation
                ->add('storefrontUrl', new NotBlank()new Choice(array_values($this->getDomainUrls($context))));
        }

        $this->dispatchValidationEvent($validation$data$context->getContext());

        $this->validator->validate($data->all()$validation);

        $this->tryValidateEqualtoConstraint($data->all(), 'email', $validation);
    }

    /** * @return string[] */
Home | Imprint | This part of the site doesn't use cookies.