1 <?php
2 /* --------------------------------------------------------------
3 CustomerAccountInputValidator.inc.php 2015-02-18 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('CustomerInputValidator');
13 MainFactory::load_class('CustomerAccountInputValidatorInterface');
14
15 /**
16 * Class CustomerAccountInputValidator
17 *
18 * This class is used for validating input data from the customer account
19 *
20 * @category System
21 * @package Customer
22 * @subpackage Validation
23 * @extends CustomerInputValidator
24 * @implements CustomerAccountInputValidatorInterface
25 */
26 class CustomerAccountInputValidator extends CustomerInputValidator implements CustomerAccountInputValidatorInterface
27 {
28 /**
29 * Checks if the entered customer data is valid based on an array.
30 *
31 * Expects an array with following keys:
32 * - gender
33 * - firstname
34 * - lastname
35 * - dob (date of birth)
36 * - email_address
37 * - telephone
38 * - vat
39 * - country
40 *
41 * @param array $inputArray Input data.
42 * @param CustomerInterface $customer Customer data.
43 *
44 * @return bool Returns the validation result (true indicates no validation error).
45 */
46 public function validateByArray(array $inputArray, CustomerInterface $customer)
47 {
48 $this->validateGender($inputArray['gender']);
49 $this->validateFirstname($inputArray['firstname']);
50 $this->validateLastname($inputArray['lastname']);
51 $this->validateDateOfBirth($inputArray['dob']);
52 $this->validateEmail($inputArray['email_address']);
53 $this->validateEmailExists($inputArray['email_address'], $customer);
54 $this->validateTelephoneNumber($inputArray['telephone']);
55 $this->validateVatNumber($inputArray['vat'], $inputArray['country'], $customer->isGuest());
56
57 return !$this->getErrorStatus();
58 }
59 }
60