Overview
  • Package
  • Class
  • Tree
  • Todo

Packages

  • AddonValue
    • Interfaces
  • ApiV2Controllers
  • Category
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Providers
    • Repositories
    • Storages
  • Customer
    • Address
    • Country
    • CountryZone
    • Interfaces
    • Validation
    • ValueObjects
  • Email
    • Collections
    • Entities
    • Exceptions
    • Interfaces
    • Repository
    • ValueObjects
  • Http
    • Collections
    • Exceptions
    • Factories
    • Interfaces
    • ValueObjects
  • Loaders
    • CrossCuttingLoader
    • GXCoreLoader
    • Interfaces
  • None
  • Order
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Repositories
    • Storages
    • ValueObjects
  • Product
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Providers
    • Repositories
    • Storages
  • ProductModule
    • Collections
    • Deleter
    • Entities
    • Factories
    • Interface
    • Interfaces
    • Reader
    • Repositories
    • Writer
  • Shared
    • Exceptions
    • FileSystem
    • Interfaces
    • Storage
    • Types
  • Statistics
    • Interfaces
  • UserConfiguration
    • Interfaces
    • Repository

Classes

  • AbstractAddonValueServiceFactory
  • AbstractAddonValueStorage
  • AbstractApiV2Controller
  • AbstractCategoryServiceFactory
  • AbstractCollection
  • AbstractCustomerFactory
  • AbstractCustomerServiceFactory
  • AbstractFileStorage
  • AbstractHttpContextFactory
  • AbstractHttpViewControllerRegistryFactory
  • AbstractImagesApiV2Controller
  • AbstractOrderServiceFactory
  • AbstractProductAttributeServiceFactory
  • AbstractProductServiceFactory
  • AddonValueService
  • AddonValueServiceFactory
  • AddonValueStorageFactory
  • AddressBlock
  • AddressBookService
  • AddressClass
  • AddressesApiV2Controller
  • AddressFormatProvider
  • AdminHttpViewController
  • AdminPageHttpControllerResponse
  • Asset
  • AssetCollection
  • AttachmentCollection
  • AttachmentName
  • AttachmentPath
  • AttachmentsApiV2Controller
  • AttachmentsHandler
  • BoolType
  • CategoriesApiV2Controller
  • Category
  • CategoryAddonValueStorage
  • CategoryFactory
  • CategoryIconsApiV2Controller
  • CategoryImagesApiV2Controller
  • CategoryListItem
  • CategoryListItemCollection
  • CategoryListProvider
  • CategoryListProviderFactory
  • CategoryObjectService
  • CategoryReadService
  • CategoryRepository
  • CategoryRepositoryDeleter
  • CategoryRepositoryReader
  • CategoryRepositoryWriter
  • CategoryServiceFactory
  • CategorySettings
  • CategorySettingsRepository
  • CategorySettingsRepositoryReader
  • CategorySettingsRepositoryWriter
  • CategoryWriteService
  • ContactCollection
  • ContactName
  • ContactType
  • CountriesApiV2Controller
  • CountryService
  • CrossCuttingLoader
  • CurrencyCode
  • Customer
  • CustomerAccountInputValidator
  • CustomerAddress
  • CustomerAddressDeleter
  • CustomerAddressInputValidator
  • CustomerAddressReader
  • CustomerAddressRepository
  • CustomerAddressWriter
  • CustomerB2BStatus
  • CustomerCallNumber
  • CustomerCity
  • CustomerCompany
  • CustomerCountry
  • CustomerCountryIso2
  • CustomerCountryIso3
  • CustomerCountryName
  • CustomerCountryReader
  • CustomerCountryRepository
  • CustomerCountryZone
  • CustomerCountryZoneIsoCode
  • CustomerCountryZoneName
  • CustomerCountryZoneReader
  • CustomerCountryZoneRepository
  • CustomerDateOfBirth
  • CustomerDeleter
  • CustomerEmail
  • CustomerFactory
  • CustomerFirstname
  • CustomerGender
  • CustomerInputValidator
  • CustomerInputValidatorSettings
  • CustomerLastname
  • CustomerNumber
  • CustomerPassword
  • CustomerPostcode
  • CustomerReader
  • CustomerReadService
  • CustomerRegistrationInputValidatorService
  • CustomerRepository
  • CustomersApiV2Controller
  • CustomerService
  • CustomerServiceFactory
  • CustomerServiceSettings
  • CustomerStatusInformation
  • CustomerStatusProvider
  • CustomerStreet
  • CustomerSuburb
  • CustomerVatNumber
  • CustomerWriter
  • CustomerWriteService
  • DecimalType
  • DefaultApiV2Controller
  • EditableCollection
  • EditableKeyValueCollection
  • Email
  • EmailAddress
  • EmailAttachment
  • EmailCollection
  • EmailContact
  • EmailContent
  • EmailDeleter
  • EmailFactory
  • EmailReader
  • EmailRepository
  • EmailsApiV2Controller
  • EmailService
  • EmailStringType
  • EmailSubject
  • EmailWriter
  • EmptyCurrencyCode
  • EmptyDateTime
  • EmptyLanguageCode
  • EmptyOrderItemDownloadInformation
  • EmptyProductImage
  • EnvCategoryServiceSettings
  • EnvironmentHttpContextFactory
  • EnvironmentHttpViewControllerRegistryFactory
  • EnvProductImageFileStorageSettings
  • ExistingDirectory
  • ExistingFile
  • FilenameStringType
  • GXCoreLoader
  • GXCoreLoaderSettings
  • GXEngineOrder
  • GXEngineProduct
  • HttpApiV2Controller
  • HttpContext
  • HttpContextReader
  • HttpControllerResponse
  • HttpDispatcher
  • HttpResponseProcessor
  • HttpService
  • HttpServiceFactory
  • HttpViewController
  • HttpViewControllerFactory
  • HttpViewControllerRegistry
  • IdCollection
  • IdType
  • ImageFileStorage
  • IntType
  • JsonHttpControllerResponse
  • KeyValueCollection
  • LanguageCode
  • LegacyProductImageProcessing
  • MailerAdapter
  • NonEmptyStringType
  • OrderAddonValueStorage
  • OrderFactory
  • OrderItem
  • OrderItemAddonValueStorage
  • OrderItemAttribute
  • OrderItemAttributeCollection
  • OrderItemAttributeFactory
  • OrderItemAttributeRepository
  • OrderItemAttributeRepositoryDeleter
  • OrderItemAttributeRepositoryFactory
  • OrderItemAttributeRepositoryReader
  • OrderItemAttributeRepositoryWriter
  • OrderItemCollection
  • OrderItemDownloadInformation
  • OrderItemFactory
  • OrderItemProperty
  • OrderItemPropertyFactory
  • OrderItemPropertyRepository
  • OrderItemPropertyRepositoryDeleter
  • OrderItemPropertyRepositoryReader
  • OrderItemPropertyRepositoryWriter
  • OrderItemRepository
  • OrderItemRepositoryDeleter
  • OrderItemRepositoryReader
  • OrderItemRepositoryWriter
  • OrderListGenerator
  • OrderListItem
  • OrderListItemCollection
  • OrderObjectService
  • OrderPaymentType
  • OrderReadService
  • OrderRepository
  • OrderRepositoryDeleter
  • OrderRepositoryReader
  • OrderRepositoryWriter
  • OrdersApiV2Controller
  • OrderServiceFactory
  • OrderServiceSettings
  • OrderShippingType
  • OrdersHistoryApiV2Controller
  • OrdersItemsApiV2Controller
  • OrdersItemsAttributesApiV2Controller
  • OrderStatusHistoryListItem
  • OrderStatusHistoryListItemCollection
  • OrderStatusHistoryStorage
  • OrdersTotalsApiV2Controller
  • OrderTotal
  • OrderTotalCollection
  • OrderTotalFactory
  • OrderTotalRepository
  • OrderTotalRepositoryDeleter
  • OrderTotalRepositoryReader
  • OrderTotalRepositoryWriter
  • OrderWriteService
  • ProductAddonValueStorage
  • ProductAttribute
  • ProductAttributeCollection
  • ProductAttributeFactory
  • ProductAttributeObjectService
  • ProductAttributeRepository
  • ProductAttributeRepositoryDeleter
  • ProductAttributeRepositoryReader
  • ProductAttributeRepositoryWriter
  • ProductAttributeService
  • ProductAttributeServiceFactory
  • ProductCategoryLinker
  • ProductFactory
  • ProductImage
  • ProductImageCollection
  • ProductImageContainer
  • ProductImageContainerRepository
  • ProductImageFileStorage
  • ProductImagesApiV2Controller
  • ProductListItem
  • ProductListItemCollection
  • ProductListProvider
  • ProductListProviderFactory
  • ProductObjectService
  • ProductPermissionSetter
  • ProductReadService
  • ProductRepository
  • ProductRepositoryDeleter
  • ProductRepositoryReader
  • ProductRepositoryWriter
  • ProductsApiV2Controller
  • ProductServiceFactory
  • ProductSettings
  • ProductSettingsRepository
  • ProductSettingsRepositoryReader
  • ProductSettingsRepositoryWriter
  • ProductsLinksApiV2Controller
  • ProductWriteService
  • RedirectHttpControllerResponse
  • StaticCrossCuttingLoader
  • StaticGXCoreLoader
  • StatisticsService
  • StoredCategory
  • StoredOrderItem
  • StoredOrderItemAttribute
  • StoredOrderItemAttributeCollection
  • StoredOrderItemCollection
  • StoredOrderItemProperty
  • StoredOrderTotal
  • StoredOrderTotalCollection
  • StoredProduct
  • StoredProductAttribute
  • StoredProductAttributeCollection
  • StringCollection
  • StringType
  • UserConfigurationReader
  • UserConfigurationService
  • UserConfigurationWriter
  • VatNumberValidator
  • WritableDirectory
  • WritableFile
  • YetAnotherLanguageProvider
  • ZonesApiV2Controller

Interfaces

  • AddonValueContainerInterface
  • AddonValueServiceInterface
  • AddonValueStorageFactoryInterface
  • AddressBlockInterface
  • AddressBookServiceInterface
  • AddressClassInterface
  • AddressFormatProviderInterface
  • AssetCollectionInterface
  • AssetInterface
  • AttachmentCollectionInterface
  • AttachmentNameInterface
  • AttachmentPathInterface
  • AttachmentsHandlerInterface
  • CategoryFactoryInterface
  • CategoryInterface
  • CategoryListProviderFactoryInterface
  • CategoryListProviderInterface
  • CategoryObjectServiceInterface
  • CategoryReadServiceInterface
  • CategoryRepositoryDeleterInterface
  • CategoryRepositoryInterface
  • CategoryRepositoryReaderInterface
  • CategoryRepositoryWriterInterface
  • CategoryServiceSettingsInterface
  • CategorySettingsInterface
  • CategorySettingsRepositoryInterface
  • CategorySettingsRepositoryReaderInterface
  • CategorySettingsRepositoryWriterInterface
  • CategoryWriteServiceInterface
  • ContactCollectionInterface
  • ContactNameInterface
  • ContactTypeInterface
  • ContentViewInterface
  • CountryServiceInterface
  • CrossCuttingLoaderInterface
  • CrossCuttingObjectInterface
  • CustomerAccountInputValidatorInterface
  • CustomerAddressDeleterInterface
  • CustomerAddressInputValidatorInterface
  • CustomerAddressInterface
  • CustomerAddressReaderInterface
  • CustomerAddressRepositoryInterface
  • CustomerAddressWriterInterface
  • CustomerB2BStatusInterface
  • CustomerCallNumberInterface
  • CustomerCityInterface
  • CustomerCompanyInterface
  • CustomerCountryInterface
  • CustomerCountryIso2Interface
  • CustomerCountryIso3Interface
  • CustomerCountryNameInterface
  • CustomerCountryReaderInterface
  • CustomerCountryRepositoryInterface
  • CustomerCountryZoneInterface
  • CustomerCountryZoneIsoCodeInterface
  • CustomerCountryZoneNameInterface
  • CustomerCountryZoneReaderInterface
  • CustomerCountryZoneRepositoryInterface
  • CustomerDeleterInterface
  • CustomerEmailInterface
  • CustomerFirstnameInterface
  • CustomerGenderInterface
  • CustomerInputValidatorInterface
  • CustomerInputValidatorSettingsInterface
  • CustomerInterface
  • CustomerLastnameInterface
  • CustomerNumberInterface
  • CustomerPasswordInterface
  • CustomerPostcodeInterface
  • CustomerReaderInterface
  • CustomerReadServiceInterface
  • CustomerRegistrationInputValidatorServiceInterface
  • CustomerRepositoryInterface
  • CustomerServiceInterface
  • CustomerServiceSettingsInterface
  • CustomerStatusProviderInterface
  • CustomerStreetInterface
  • CustomerSuburbInterface
  • CustomerVatNumberInterface
  • CustomerWriterInterface
  • CustomerWriteServiceInterface
  • EmailAddressInterface
  • EmailAttachmentInterface
  • EmailCollectionInterface
  • EmailContactInterface
  • EmailContentInterface
  • EmailDeleterInterface
  • EmailFactoryInterface
  • EmailInterface
  • EmailReaderInterface
  • EmailRepositoryInterface
  • EmailServiceInterface
  • EmailSubjectInterface
  • EmailWriterInterface
  • GXCoreLoaderInterface
  • GXCoreLoaderSettingsInterface
  • HttpContextInterface
  • HttpContextReaderInterface
  • HttpControllerResponseInterface
  • HttpDispatcherInterface
  • HttpResponseProcessorInterface
  • HttpServiceFactoryInterface
  • HttpServiceInterface
  • HttpViewControllerFactoryInterface
  • HttpViewControllerInterface
  • HttpViewControllerRegistryInterface
  • IdInterface
  • LanguageProviderInterface
  • MailerAdapterInterface
  • OrderFactoryInterface
  • OrderInterface
  • OrderItemAttributeFactoryInterface
  • OrderItemAttributeInterface
  • OrderItemAttributeRepositoryDeleterInterface
  • OrderItemAttributeRepositoryFactoryInterface
  • OrderItemAttributeRepositoryInterface
  • OrderItemAttributeRepositoryReaderInterface
  • OrderItemAttributeRepositoryWriterInterface
  • OrderItemFactoryInterface
  • OrderItemInterface
  • OrderItemPropertyFactoryInterface
  • OrderItemPropertyRepositoryDeleterInterface
  • OrderItemPropertyRepositoryReaderInterface
  • OrderItemPropertyRepositoryWriterInterface
  • OrderItemRepositoryDeleterInterface
  • OrderItemRepositoryInterface
  • OrderItemRepositoryReaderInterface
  • OrderItemRepositoryWriterInterface
  • OrderListGeneratorInterface
  • OrderObjectServiceInterface
  • OrderPaymentTypeInterface
  • OrderReadServiceInterface
  • OrderRepositoryDeleterInterface
  • OrderRepositoryInterface
  • OrderRepositoryReaderInterface
  • OrderRepositoryWriterInterface
  • OrderServiceSettingsInterface
  • OrderShippingTypeInterface
  • OrderStatusHistoryReaderInterface
  • OrderStatusHistoryWriterInterface
  • OrderTotalFactoryInterface
  • OrderTotalInterface
  • OrderTotalRepositoryDeleterInterface
  • OrderTotalRepositoryInterface
  • OrderTotalRepositoryReaderInterface
  • OrderTotalRepositoryWriterInterface
  • OrderWriteServiceInterface
  • ProductAttributeFactoryInterface
  • ProductAttributeInterface
  • ProductAttributeObjectServiceInterface
  • ProductAttributeRepositoryDeleterInterface
  • ProductAttributeRepositoryInterface
  • ProductAttributeRepositoryReaderInterface
  • ProductAttributeRepositoryWriterInterface
  • ProductAttributeServiceInterface
  • ProductCategoryLinkerInterface
  • ProductFactoryInterface
  • ProductImageContainerInterface
  • ProductImageContainerRepositoryInterface
  • ProductImageInterface
  • ProductImagePathsSettingsInterface
  • ProductImageProcessingInterface
  • ProductInterface
  • ProductListProviderFactoryInterface
  • ProductListProviderInterface
  • ProductObjectServiceInterface
  • ProductPermissionSetterInterface
  • ProductReadServiceInterface
  • ProductRepositoryDeleterInterface
  • ProductRepositoryInterface
  • ProductRepositoryReaderInterface
  • ProductRepositoryWriterInterface
  • ProductSettingsInterface
  • ProductSettingsRepositoryInterface
  • ProductSettingsRepositoryReaderInterface
  • ProductSettingsRepositoryWriterInterface
  • ProductWriteServiceInterface
  • StatisticsServiceInterface
  • StoredCategoryInterface
  • StoredOrderItemAttributeInterface
  • StoredOrderItemInterface
  • StoredOrderTotalInterface
  • StoredProductAttributeInterface
  • StoredProductInterface
  • UserConfigurationReaderInterface
  • UserConfigurationServiceInterface
  • UserConfigurationWriterInterface
  • VatNumberValidatorInterface

Exceptions

  • AjaxException
  • AttachmentNotFoundException
  • FileNotFoundException
  • HttpApiV2Exception
  • MissingControllerNameException
  • UnknownEnvironmentException
  1 <?php
  2 /* --------------------------------------------------------------
  3    CustomerInputValidator.inc.php 2015-05-27 gm
  4    Gambio GmbH
  5    http://www.gambio.de
  6    Copyright (c) 2015 Gambio GmbH
  7    Released under the GNU General Public License (Version 2)
  8    [http://www.gnu.org/licenses/gpl-2.0.html]
  9    --------------------------------------------------------------
 10 */
 11 
 12 MainFactory::load_class('CustomerInputValidatorInterface');
 13 
 14 require_once DIR_FS_INC . 'xtc_validate_email.inc.php';
 15 
 16 /**
 17  * Class CustomerInputValidator
 18  *
 19  * Validator class that checks the entered user data.
 20  *
 21  * @category   System
 22  * @package    Customer
 23  * @subpackage Validation
 24  * @implements CustomerInputValidatorInterface
 25  */
 26 class CustomerInputValidator implements CustomerInputValidatorInterface
 27 {
 28     /**
 29      * Customer country repository.
 30      * @var CustomerCountryRepositoryInterface
 31      */
 32     protected $customerCountryRepository;
 33 
 34     /**
 35      * Customer country zone repository.
 36      * @var CustomerCountryZoneRepositoryInterface
 37      */
 38     protected $customerCountryZoneRepository;
 39 
 40     /**
 41      * Customer service.
 42      * @var CustomerServiceInterface
 43      */
 44     protected $customerService;
 45 
 46     /**
 47      * Country service.
 48      * @var CountryServiceInterface
 49      */
 50     protected $countryService;
 51 
 52     /**
 53      * Customer input validator settings.
 54      * @var CustomerInputValidatorSettingsInterface
 55      */
 56     protected $settings;
 57 
 58     /**
 59      * VAT number validator.
 60      * @var VatNumberValidatorInterface
 61      */
 62     protected $vatNumberValidator;
 63 
 64     /**
 65      * Error message collection.
 66      * @var EditableKeyValueCollection
 67      */
 68     protected $errorMessageCollection;
 69 
 70     /**
 71      * Error status.
 72      * @var bool
 73      */
 74     protected $errorStatus = false;
 75 
 76 
 77     /**
 78      * Constructor of the class CustomerInputValidator.
 79      *
 80      * @param CustomerServiceInterface                $customerService                Customer service.
 81      * @param CountryServiceInterface                 $countryService                 Country service.
 82      * @param CustomerInputValidatorSettingsInterface $customerInputValidatorSettings Customer input validator settings.
 83      * @param CustomerCountryRepositoryInterface      $customerCountryRepository      Customer country repository.
 84      * @param CustomerCountryZoneRepositoryInterface  $customerCountryZoneRepository  Customer country zone repository.
 85      * @param VatNumberValidatorInterface             $vatNumberValidator             VAT number validator.
 86      */
 87     public function __construct(CustomerServiceInterface $customerService,
 88                                 CountryServiceInterface $countryService,
 89                                 CustomerInputValidatorSettingsInterface $customerInputValidatorSettings,
 90                                 CustomerCountryRepositoryInterface $customerCountryRepository,
 91                                 CustomerCountryZoneRepositoryInterface $customerCountryZoneRepository,
 92                                 VatNumberValidatorInterface $vatNumberValidator)
 93     {
 94         $this->customerService               = $customerService;
 95         $this->countryService                = $countryService;
 96         $this->settings                      = $customerInputValidatorSettings;
 97         $this->customerCountryRepository     = $customerCountryRepository;
 98         $this->customerCountryZoneRepository = $customerCountryZoneRepository;
 99         $this->vatNumberValidator            = $vatNumberValidator;
100         
101         $this->errorMessageCollection = MainFactory::create('EditableKeyValueCollection', array());
102     }
103     
104 
105     /**
106      * Checks if the entered customer's gender is valid.
107      *
108      * @param string $p_gender Customer's gender.
109      *
110      * @return bool Is valid?
111      */
112     public function validateGender($p_gender)
113     {
114         if(!$this->settings->getDisplayGender())
115         {
116             return true;
117         }
118         if((string)$p_gender != 'm' && (string)$p_gender != 'f')
119         {
120             $this->errorStatus = true;
121             $this->errorMessageCollection->setValue('error_gender', $this->settings->getGenderErrorMessage());
122 
123             return false;
124         }
125 
126         return true;
127     }
128     
129 
130     /**
131      * Checks if the entered customer's first name is valid.
132      *
133      * @param string $p_firstname Customer's first name.
134      *
135      * @return bool Is valid?
136      */
137     public function validateFirstname($p_firstname)
138     {
139         if(strlen_wrapper(trim((string)$p_firstname)) > $this->settings->getFirstnameMaxLength())
140         {
141             $this->errorStatus = true;
142             $this->errorMessageCollection->setValue('error_first_name', $this->settings->getInvalidInputErrorMessage());
143 
144             return false;
145         }
146         
147         if(strlen_wrapper((string)$p_firstname) < $this->settings->getFirstnameMinLength())
148         {
149             $this->errorStatus = true;
150             $this->errorMessageCollection->setValue('error_first_name', $this->settings->getFirstnameErrorMessage());
151 
152             return false;
153         }
154 
155         return true;
156     }
157 
158 
159     /**
160      * Checks if the entered customer's last name is valid.
161      *
162      * @param string $p_lastname Customer's last name.
163      *
164      * @return bool Is valid?
165      */
166     public function validateLastname($p_lastname)
167     {
168         if(strlen_wrapper(trim((string)$p_lastname)) > $this->settings->getLastnameMaxLength())
169         {
170             $this->errorStatus = true;
171             $this->errorMessageCollection->setValue('error_last_name', $this->settings->getInvalidInputErrorMessage());
172 
173             return false;
174         }
175         
176         if(strlen_wrapper((string)$p_lastname) < $this->settings->getLastnameMinLength())
177         {
178             $this->errorStatus = true;
179             $this->errorMessageCollection->setValue('error_last_name', $this->settings->getLastnameErrorMessage());
180 
181             return false;
182         }
183 
184         return true;
185     }
186 
187 
188     /**
189      * Checks if the entered customer's date of birth is valid.
190      * Valid format is: dd.mm.yyyy
191      *
192      * @param string $p_dateOfBirth Customer's date of birth.
193      *
194      * @return bool Is valid?
195      */
196     public function validateDateOfBirth($p_dateOfBirth)
197     {
198         // @todo DisplayDateOfBirth setting is blocking the unit tests of the class.
199         if(!$this->settings->getDisplayDateOfBirth())
200         {
201             return true;
202         }
203         $dateOfBirth = (string)$p_dateOfBirth;
204         $minLength   = $this->settings->getDateOfBirthMinLength();
205         
206         if($minLength > 0 || ($dateOfBirth != '' && $minLength === 0))
207         {
208             if(!preg_match('/^[0-9]{2}[\.\/]{1}[0-9]{2}[\.\/]{1}[0-9]{4}$/', $dateOfBirth)
209                || checkdate(substr(xtc_date_raw($dateOfBirth), 4, 2), substr(xtc_date_raw($dateOfBirth), 6, 2),
210                             substr(xtc_date_raw($dateOfBirth), 0, 4)) == false
211             )
212             {
213                 $this->errorStatus = true;
214                 $this->errorMessageCollection->setValue('error_birth_day',
215                                                         $this->settings->getDateOfBirthErrorMessage());
216 
217                 return false;
218             }
219         }
220 
221         return true;
222     }
223 
224 
225     /**
226      * Checks if the entered customer's company is valid.
227      *
228      * @param string $p_company Customer's company.
229      *
230      * @return bool Is valid?
231      */
232     public function validateCompany($p_company)
233     {
234         if(!$this->settings->getDisplayCompany())
235         {
236             return true;
237         }
238         $company = (string)$p_company;
239 
240         if(strlen_wrapper(trim($company)) > $this->settings->getCompanyMaxLength())
241         {
242             $this->errorStatus = true;
243             $this->errorMessageCollection->setValue('error_company', $this->settings->getInvalidInputErrorMessage());
244 
245             return false;
246         }
247         
248         if(strlen_wrapper($company) > 0 && strlen_wrapper($company) < $this->settings->getCompanyMinLength())
249         {
250             $this->errorStatus = true;
251             $this->errorMessageCollection->setValue('error_company', $this->settings->getCompanyErrorMessage());
252 
253             return false;
254         }
255 
256         return true;
257     }
258 
259 
260     /**
261      * Checks if the entered parameters are in a valid format.
262      *
263      * @param string $p_vatNumber VAT number.
264      * @param int    $p_countryId Country ID.
265      * @param bool   $p_isGuest   Is customer a guest?
266      *
267      * @return bool Is valid?
268      */
269     public function validateVatNumber($p_vatNumber, $p_countryId, $p_isGuest)
270     {
271         if(strlen_wrapper(trim((string)$p_vatNumber)) > $this->settings->getVatNumberMaxLength())
272         {
273             $this->errorStatus = true;
274             $this->errorMessageCollection->setValue('error_vat', $this->settings->getInvalidInputErrorMessage());
275 
276             return false;
277         }
278         
279         if($this->vatNumberValidator->getErrorStatus($p_vatNumber, $p_countryId, $p_isGuest))
280         {
281             $this->errorStatus = true;
282             $this->errorMessageCollection->setValue('error_vat', $this->settings->getVatNumberErrorMessage());
283 
284             return false;
285         }
286 
287         return true;
288     }
289     
290 
291     /**
292      * Checks if the entered email and email confirmation are valid.
293      * It will check the minimum length, address syntax, confirmation matching and existence of e-mail address.
294      *
295      * @param string $p_email             Customer's E-Mail address.
296      * @param string $p_emailConfirmation Confirmation E-Mail address.
297      *
298      * @return bool Is valid?
299      */
300     public function validateEmailAndConfirmation($p_email, $p_emailConfirmation)
301     {
302         if($p_email != $p_emailConfirmation)
303         {
304             $this->errorStatus = true;
305             $this->errorMessageCollection->setValue('error_mail', $this->settings->getEmailConfirmationErrorMessage());
306 
307             return false;
308         }
309 
310         if(!$this->validateEmail($p_email))
311         {
312             return false;
313         }
314 
315         if(!$this->validateEmailExists($p_email))
316         {
317             return false;
318         }
319 
320         return true;
321     }
322 
323 
324     /**
325      * Checks if the entered email is valid.
326      *
327      * @param string $p_email Customer's E-Mail address.
328      *
329      * @return bool Is valid?
330      */
331     public function validateEmail($p_email)
332     {
333         if(strlen_wrapper($p_email) < $this->settings->getEmailMinLength())
334         {
335             $this->errorStatus = true;
336             $this->errorMessageCollection->setValue('error_mail', $this->settings->getEmailErrorMessage());
337 
338             return false;
339         }
340         elseif(xtc_validate_email($p_email) == false)
341         {
342             $this->errorStatus = true;
343             $this->errorMessageCollection->setValue('error_mail', $this->settings->getEmailAddressCheckErrorMessage());
344 
345             return false;
346         }
347         elseif(!filter_var($p_email, FILTER_VALIDATE_EMAIL))
348         {
349             // @codeCoverageIgnoreStart
350             # code coverage ignore this edge case, xtc_validate_email usually recognize invalid email addresses.
351             $this->errorStatus = true;
352             $this->errorMessageCollection->setValue('error_mail', $this->settings->getEmailAddressCheckErrorMessage());
353 
354             return false;
355             // @codeCoverageIgnoreEnd
356         }
357 
358         return true;
359     }
360     
361     
362     /**
363      * Checks if the entered email already exists.
364      *
365      * @param string            $p_email  Customer's E-Mail address-
366      * @param CustomerInterface $customer Customer.
367      *
368      * @return bool Is valid?
369      */
370     public function validateEmailExists($p_email, CustomerInterface $customer = null)
371     {
372         if($this->customerService->registreeEmailExists(MainFactory::create('CustomerEmail', $p_email))
373            && ($customer === null
374                || $customer->getEmail() != $p_email)
375         )
376         {
377             $this->errorStatus = true;
378             $this->errorMessageCollection->setValue('error_mail', $this->settings->getEmailExistsErrorMessage());
379 
380             return false;
381         }
382 
383         return true;
384     }
385 
386 
387     /**
388      * Checks if the entered street is valid.
389      *
390      * @param string $p_street Customer's street.
391      *
392      * @return bool Is valid?
393      */
394     public function validateStreet($p_street)
395     {
396         if(strlen_wrapper(trim((string)$p_street)) > $this->settings->getStreetMaxLength())
397         {
398             $this->errorStatus = true;
399             $this->errorMessageCollection->setValue('error_street', $this->settings->getInvalidInputErrorMessage());
400 
401             return false;
402         }
403         
404         if(strlen_wrapper((string)$p_street) < $this->settings->getStreetMinLength())
405         {
406             $this->errorStatus = true;
407             $this->errorMessageCollection->setValue('error_street', $this->settings->getStreetErrorMessage());
408 
409             return false;
410         }
411 
412         return true;
413     }
414 
415 
416     /**
417      * Checks if the entered postcode is valid.
418      *
419      * @param string $p_postcode Customer's post code.
420      *
421      * @return bool Is valid?
422      */
423     public function validatePostcode($p_postcode)
424     {
425         if(strlen_wrapper(trim((string)$p_postcode)) > $this->settings->getPostcodeMaxLength())
426         {
427             $this->errorStatus = true;
428             $this->errorMessageCollection->setValue('error_post_code', $this->settings->getInvalidInputErrorMessage());
429 
430             return false;
431         }
432         
433         if(strlen_wrapper((string)$p_postcode) < $this->settings->getPostcodeMinLength())
434         {
435             $this->errorStatus = true;
436             $this->errorMessageCollection->setValue('error_post_code', $this->settings->getPostcodeErrorMessage());
437 
438             return false;
439         }
440 
441         return true;
442     }
443 
444 
445     /**
446      * Checks if the entered city is valid.
447      *
448      * @param string $p_city Customer's city.
449      *
450      * @return bool Is valid?
451      */
452     public function validateCity($p_city)
453     {
454         if(strlen_wrapper(trim((string)$p_city)) > $this->settings->getCityMaxLength())
455         {
456             $this->errorStatus = true;
457             $this->errorMessageCollection->setValue('error_city', $this->settings->getInvalidInputErrorMessage());
458 
459             return false;
460         }
461         
462         if(strlen_wrapper((string)$p_city) < $this->settings->getCityMinLength())
463         {
464             $this->errorStatus = true;
465             $this->errorMessageCollection->setValue('error_city', $this->settings->getCityErrorMessage());
466 
467             return false;
468         }
469 
470         return true;
471     }
472 
473 
474     /**
475      * Checks if the entered country exists.
476      *
477      * @param int $p_countryId Customer's country ID.
478      *
479      * @return bool Is valid?
480      */
481     public function validateCountry($p_countryId)
482     {
483         $country = $this->customerCountryRepository->findById(new IdType($p_countryId));
484         
485         if($country === null || $country->getStatus() === false)
486         {
487             $this->errorStatus = true;
488             $this->errorMessageCollection->setValue('error_country', $this->settings->getCountryErrorMessage());
489 
490             return false;
491         }
492 
493         return true;
494     }
495 
496 
497     /**
498      * Checks if the entered country zone is valid.
499      *
500      * Cases:
501      * - If country has zones: It checks if zone belongs to country.
502      * - If country does not contain zones: It checks the minimum length of zone name.
503      *
504      * @param $p_countryZoneName Customer's country zone name.
505      * @param $p_countryId       Customer's country ID.
506      *
507      * @return bool Is valid?
508      */
509     public function validateCountryZone($p_countryZone, $p_countryId)
510     {
511         if(!$this->settings->getDisplayCountryZone())
512         {
513             return true;
514         }
515 
516         $country = $this->customerCountryRepository->findById(new IdType($p_countryId));
517         
518         if($country !== null && $this->countryService->countryHasCountryZones($country))
519         {
520             if(is_numeric($p_countryZone))
521             {
522                 $countryZone = $this->customerCountryZoneRepository->findById(new IdType($p_countryZone));
523             }
524             else
525             {
526                 if(strlen_wrapper(trim((string)$p_countryZone)) > $this->settings->getCountryZoneMaxLength())
527                 {
528                     $this->errorStatus = true;
529                     $this->errorMessageCollection->setValue('error_state',
530                                                             $this->settings->getInvalidInputErrorMessage());
531 
532                     return false;
533                 }
534                 
535                 $countryZone = $this->customerCountryZoneRepository->findByNameAndCountry(MainFactory::create('CustomerCountryZoneName',
536                                                                                                               $p_countryZone),
537                                                                                           $country);
538             }
539             
540             if($countryZone === null
541                || $country->getStatus() === false
542                || !$this->countryService->countryZoneExistsInCountry($countryZone, $country)
543             )
544             {
545                 $this->errorStatus = true;
546                 $this->errorMessageCollection->setValue('error_state',
547                                                         $this->settings->getCountryZoneSelectionErrorMessage());
548 
549                 return false;
550             }
551         }
552         elseif(is_numeric($p_countryZone)
553                || strlen_wrapper((string)$p_countryZone) < $this->settings->getCountryZoneMinLength()
554         )
555         {
556             $this->errorStatus = true;
557             $this->errorMessageCollection->setValue('error_state', $this->settings->getCountryZoneErrorMessage());
558 
559             return false;
560         }
561 
562         return true;
563     }
564 
565 
566     /**
567      * Checks if the entered suburb is valid.
568      *
569      * @param $p_suburb Customer's suburb.
570      *
571      * @return bool Is valid?
572      */
573     public function validateSuburb($p_suburb)
574     {
575         if(!$this->settings->getDisplaySuburb())
576         {
577             return true;
578         }
579 
580         if(strlen_wrapper(trim((string)$p_suburb)) > $this->settings->getSuburbMaxLength())
581         {
582             $this->errorStatus = true;
583             $this->errorMessageCollection->setValue('error_suburb', $this->settings->getInvalidInputErrorMessage());
584 
585             return false;
586         }
587         
588         return true;
589     }
590 
591 
592     /**
593      * Checks if the entered telephone number is valid.
594      *
595      * @param string $p_telephoneNumber Customer's telephone number.
596      *
597      * @return bool Is valid?
598      */
599     public function validateTelephoneNumber($p_telephoneNumber)
600     {
601         if(!$this->settings->getDisplayTelephone())
602         {
603             return true;
604         }
605 
606         if(strlen_wrapper(trim((string)$p_telephoneNumber)) > $this->settings->getCallNumberMaxLength())
607         {
608             $this->errorStatus = true;
609             $this->errorMessageCollection->setValue('error_tel', $this->settings->getInvalidInputErrorMessage());
610 
611             return false;
612         }
613         
614         if(strlen_wrapper((string)$p_telephoneNumber) < $this->settings->getTelephoneNumberMinLength())
615         {
616             $this->errorStatus = true;
617             $this->errorMessageCollection->setValue('error_tel', $this->settings->getTelephoneNumberErrorMessage());
618 
619             return false;
620         }
621 
622         return true;
623     }
624 
625 
626     /**
627      * Checks if the entered fax number is valid.
628      *
629      * @param string $p_faxNumber Customer's fax number.
630      *
631      * @return bool Is valid?
632      */
633     public function validateFaxNumber($p_faxNumber)
634     {
635         if(!$this->settings->getDisplayFax())
636         {
637             return true;
638         }
639 
640         if(strlen_wrapper(trim((string)$p_faxNumber)) > $this->settings->getCallNumberMaxLength())
641         {
642             $this->errorStatus = true;
643             $this->errorMessageCollection->setValue('error_fax', $this->settings->getInvalidInputErrorMessage());
644 
645             return false;
646         }
647 
648         return true;
649     }
650 
651 
652     /**
653      * Checks if the entered password is valid.
654      *
655      * @param string $p_password             Customer's password.
656      * @param string $p_passwordConfirmation Customer's password confirmation.
657      *
658      * @return bool Is valid?
659      */
660     public function validatePassword($p_password, $p_passwordConfirmation)
661     {
662         if(strlen_wrapper($p_password) < $this->settings->getPasswordMinLength())
663         {
664             $this->errorStatus = true;
665             $this->errorMessageCollection->setValue('error_password', $this->settings->getPasswordErrorMessage());
666 
667             return false;
668         }
669         elseif($p_password !== $p_passwordConfirmation)
670         {
671             $this->errorStatus = true;
672             $this->errorMessageCollection->setValue('error_password2',
673                                                     $this->settings->getPasswordMismatchErrorMessage());
674 
675             return false;
676         }
677 
678         return true;
679     }
680     
681 
682     /**
683      * Returns error messages.
684      * @deprecated Use getErrorMessageCollection() instead
685      * @return array Error messages.
686      */
687     public function getErrorMessages()
688     {
689         return $this->errorMessageCollection->getArray();
690     }
691 
692 
693     /**
694      * Returns a collection of error messages.
695      *
696      * @return EditableKeyValueCollection Collection of error messages.
697      */
698     public function getErrorMessageCollection()
699     {
700         return $this->errorMessageCollection;
701     }
702     
703     
704     /**
705      * Returns the error status.
706      *
707      * @return bool Error status.
708      */
709     public function getErrorStatus()
710     {
711         return $this->errorStatus;
712     }
713 } 
API documentation generated by ApiGen