private function validateUserPostData($post_data) { $isNewUserCreation = !array_key_exists('id', $post_data) || empty($post_data['id']); if ($isNewUserCreation && (!array_key_exists('emailAddress', $post_data) || empty($post_data['emailAddress']))) { $error_message = 'emailAddress is required for new User creation'; throw new NSH_ValidationException(110, $error_message); } if ($isNewUserCreation && (!array_key_exists('username', $post_data) || empty($post_data['username']))) { $error_message = 'username is required for new User creation'; throw new NSH_ValidationException(110, $error_message); } if (array_key_exists('credentialType', $post_data)) { if (!$this->equalIgnorecase($post_data['credentialType'], STANDARD_CREDENTIALTYPE) && !$this->equalIgnorecase($post_data['credentialType'], FACEBOOK_CREDENTIALTYPE) && !$this->equalIgnorecase($post_data['credentialType'], GOOGLE_CREDENTIALTYPE)) { $error_message = 'credentialType should be either STANDARD, FACEBOOK or GOOGLE'; throw new NSH_ValidationException(110, $error_message); } if ($this->equalIgnorecase($post_data['credentialType'], STANDARD_CREDENTIALTYPE) && (!array_key_exists('password', $post_data) || empty($post_data['password']))) { $error_message = 'password is required for STANDARD crendentialType'; throw new NSH_ValidationException(110, $error_message); } if (!$this->equalIgnorecase($post_data['credentialType'], STANDARD_CREDENTIALTYPE) && (!array_key_exists('socialId', $post_data) || empty($post_data['socialId']))) { $error_message = 'SocialId is required for FACEBOOK or GOOGLE crendentialType'; throw new NSH_ValidationException(110, $error_message); } if (array_key_exists('password', $post_data) && !empty($post_data['password'])) { //check password meets criteria Password_validation::validate($post_data['password']); } } if (array_key_exists('attributes', $post_data)) { $this->UserAttributeValues_model->validateAttributes($post_data['attributes']); } }
private function validatePostData($post_data) { if (!array_key_exists('credentialType', $post_data) || empty($post_data['credentialType'])) { $error_message = 'credentialType is required'; throw new NSH_ValidationException(110, $error_message); } if (!$this->equalIgnorecase($post_data['credentialType'], STANDARD_CREDENTIALTYPE) && !$this->equalIgnorecase($post_data['credentialType'], FACEBOOK_CREDENTIALTYPE) && !$this->equalIgnorecase($post_data['credentialType'], GOOGLE_CREDENTIALTYPE)) { $error_message = 'CredentialType should be either STANDARD, FACEBOOK or GOOGLE'; throw new NSH_ValidationException(110, $error_message); } if ($this->equalIgnorecase($post_data['credentialType'], STANDARD_CREDENTIALTYPE) && (!array_key_exists('password', $post_data) || empty($post_data['password']))) { $error_message = 'password is required for STANDARD crendentialType'; throw new NSH_ValidationException(110, $error_message); } if (!$this->equalIgnorecase($post_data['credentialType'], STANDARD_CREDENTIALTYPE) && (!array_key_exists('socialId', $post_data) || empty($post_data['socialId']))) { $error_message = 'SocialId is required for FACEBOOK or GOOGLE crendentialType'; throw new NSH_ValidationException(110, $error_message); } if (array_key_exists('password', $post_data) && !empty($post_data['password'])) { //check password meets criteria Password_validation::validate($post_data['password']); } }