src/Checkout/Component/AddressBook.php
public function validateData(Order $order, array $data)
    {
        $result = ValidationResult::create();
        $existingID =
            !empty($data[$this->addresstype . 'AddressID']) ? (int)$data[$this->addresstype . 'AddressID'] : 0;

        if ($existingID) {
            $member = Security::getCurrentUser();
            // If existing address selected, check that it exists in $member->AddressBook
            if (!$member || !$member->AddressBook()->byID($existingID)) {
                $result->addError('Invalid address supplied', $this->addresstype . 'AddressID');
                throw new ValidationException($result);
            }
        } else {
            // Otherwise, require the normal address fields
            $required = parent::getRequiredFields($order);
            $addressLabels = singleton(\SilverShop\Model\Address::class)->fieldLabels(false);

            foreach ($required as $fieldName) {
                if (empty($data[$fieldName])) {
                    // attempt to get the translated field name
                    $fieldLabel = isset($addressLabels[$fieldName]) ? $addressLabels[$fieldName] : $fieldName;
                    $errorMessage = _t(
                        'SilverShop\Forms.FIELDISREQUIRED',
                        '{name} is required',
                        array('name' => $fieldLabel)
                    );

                    $result->addError($errorMessage, $fieldName);
                    throw new ValidationException($result);
                }
            }
        }
    }
public function validateData(Order $order, array $data)
    {
        $result = ValidationResult::create();
        $existingID =
            !empty($data[$this->addresstype . 'AddressID']) ? (int)$data[$this->addresstype . 'AddressID'] : 0;

        if ($existingID) {
            $member = Security::getCurrentUser();
            // If existing address selected, check that it exists in $member->AddressBook
            if (!$member || !$member->AddressBook()->byID($existingID)) {
                $result->addError('Invalid address supplied', $this->addresstype . 'AddressID');
                throw new ValidationException($result);
            }
        } else {
            // Otherwise, require the normal address fields
            $required = parent::getRequiredFields($order);
            $addressLabels = singleton(\SilverShop\Model\Address::class)->fieldLabels(false);

            foreach ($required as $fieldName) {
                if (empty($data[$fieldName])) {
                    // attempt to get the translated field name
                    $fieldLabel = isset($addressLabels[$fieldName]) ? $addressLabels[$fieldName] : $fieldName;
                    $errorMessage = _t(
                        'SilverShop\Forms.FIELDISREQUIRED',
                        '{name} is required',
                        array('name' => $fieldLabel)
                    );

                    $result->addError($errorMessage, $fieldName);
                    throw new ValidationException($result);
                }
            }
        }
    }
@param Order $order
@param array $data

@throws ValidationException