1 <?php
2 /* --------------------------------------------------------------
3 CustomerRegistrationInputValidatorService.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('CustomerInputValidator');
13 MainFactory::load_class('CustomerRegistrationInputValidatorServiceInterface');
14
15 /**
16 * Class CustomerRegistrationInputValidatorService
17 *
18 * This class is used for validating customer input while registration
19 *
20 * @category System
21 * @package Customer
22 * @subpackage Validation
23 * @extends CustomerInputValidator
24 * @implements CustomerRegistrationInputValidatorServiceInterface
25 */
26 class CustomerRegistrationInputValidatorService extends CustomerInputValidator
27 implements CustomerRegistrationInputValidatorServiceInterface
28 {
29 /**
30 * Validates the entered customer data with an array of parameters.
31 *
32 * Expects array with following keys:
33 * - gender
34 * - firstname
35 * - lastname
36 * - dob (date of birth)
37 * - company
38 * - email_address
39 * - email_address_confirm
40 * - postcode
41 * - city
42 * - country
43 * - state (ID or name)
44 * - telephone
45 * - vat
46 * - password
47 * - confirmation
48 *
49 * @param array $inputArray Customer data input.
50 *
51 * @return bool Is customer data valid?
52 */
53 public function validateCustomerDataByArray(array $inputArray)
54 {
55 $this->_validateDataByArray($inputArray);
56 $this->validateVatNumber($inputArray['vat'], $inputArray['country'], false);
57 $this->validatePassword($inputArray['password'], $inputArray['confirmation']);
58
59 return !$this->getErrorStatus();
60 }
61
62
63 /**
64 * Validate the entered guest data with an array of parameters.
65 *
66 * expects array with following keys:
67 * - gender
68 * - firstname
69 * - lastname
70 * - dob (date of birth)
71 * - company
72 * - email_address
73 * - email_address_confirm
74 * - postcode
75 * - city
76 * - country
77 * - state (ID or name)
78 * - telephone
79 * - vat
80 *
81 * @param array $inputArray Guest customer data input.
82 *
83 * @return bool Is guest customer data valid?
84 */
85 public function validateGuestDataByArray(array $inputArray)
86 {
87 $this->_validateDataByArray($inputArray);
88 $this->validateVatNumber($inputArray['vat'], $inputArray['country'], true);
89
90 return !$this->getErrorStatus();
91 }
92
93
94 /**
95 * Checks if the entered data is valid.
96 *
97 * Expects an array with the following keys:
98 * - gender
99 * - firstname
100 * - lastname
101 * - dob (date of birth)
102 * - company
103 * - email_address
104 * - suburb
105 * - email_address_confirm
106 * - postcode
107 * - city
108 * - country
109 * - state (ID or name)
110 * - telephone
111 * - fax
112 * - vat
113 *
114 * @param array $inputArray Customer Input array.
115 *
116 * @return bool Is customer data valid?
117 */
118 protected function _validateDataByArray(array $inputArray)
119 {
120 $this->validateGender($inputArray['gender']);
121 $this->validateFirstname($inputArray['firstname']);
122 $this->validateLastname($inputArray['lastname']);
123 $this->validateDateOfBirth($inputArray['dob']);
124 $this->validateCompany($inputArray['company']);
125 $this->validateEmailAndConfirmation($inputArray['email_address'], $inputArray['email_address_confirm']);
126 $this->validateStreet($inputArray['street_address']);
127 $this->validateSuburb($inputArray['suburb']);
128 $this->validatePostcode($inputArray['postcode']);
129 $this->validateCity($inputArray['city']);
130 $this->validateCountry($inputArray['country']);
131 $this->validateCountryZone($inputArray['state'], $inputArray['country']);
132 $this->validateTelephoneNumber($inputArray['telephone']);
133 $this->validateFaxNumber($inputArray['fax']);
134
135 return !$this->getErrorStatus();
136 }
137 }
138