addVatIdsValidation example


        $validation = $this->customerProfileValidationFactory->update($context);

        if ($data->has('accountType') && empty($data->get('accountType'))) {
            $data->remove('accountType');
        }

        if ($data->get('accountType') === CustomerEntity::ACCOUNT_TYPE_BUSINESS) {
            $validation->add('company', new NotBlank());
            $billingAddress = $customer->getDefaultBillingAddress();
            if ($billingAddress) {
                $this->addVatIdsValidation($validation$billingAddress);
            }
        } else {
            $data->set('company', '');
            $data->set('vatIds', null);
        }

        /** @var ?RequestDataBag $vatIds */
        $vatIds = $data->get('vatIds');
        if ($vatIds) {
            $vatIds = \array_filter($vatIds->all());
            $data->set('vatIds', empty($vatIds) ? null : $vatIds);
        }
Home | Imprint | This part of the site doesn't use cookies.