def validate_request(self): EventRequest.validate_request(self) if self.dstIp is not None: # first, validation IPv4 format if SvcUtils.regex_validate(SvcConfig.ipv4_validation_regex) is False: # second, if not IPv4 compliant, validate for IPv6 format if SvcUtils.regex_validate(SvcConfig.ipv6_validation_regex) is False: error_msg = SvcUtils.error_message('Invalid event request, destination IP is invalid', {'destination IP': self.dstIp}) raise ValueError(error_msg) if SvcUtils.regex_validate(SvcConfig.uri_validation_regex, self.externalUrl) is False: error_msg = SvcUtils.error_message('Invalid event request, external URL is invalid', {'external URL': self.externalUrl}) raise ValueError(error_msg)
def validate_request(self): if self.customerKey is None: raise Exception('Invalid event request, customer key is missing') if self.deviceId is None: raise Exception('Invalid event request, device ID is missing') if self.deviceVersion is None: raise Exception('Invalid event request, device version is missing') if self.dstUrl is None: raise Exception('Invalid event request, destination URL is missing') if self.eventTime is None: raise Exception('Invalid event request, event time (UTC) is missing') if SvcUtils.regex_validate(SvcConfig.uuid_validation_regex, self.customerKey) is False: error_msg = SvcUtils.error_message('Invalid event request, customer key is invalid', {'customer key': self.customerKey}) raise ValueError(error_msg) if SvcUtils.regex_validate(SvcConfig.uri_validation_regex, self.dstUrl) is False: error_msg = SvcUtils.error_message('Invalid event request, destination URL is invalid', {'destination URL': self.dstUrl}) raise ValueError(error_msg) if SvcUtils.validate_timestamp(self.eventTime)is False: error_msg = SvcUtils.error_message('Invalid event request, event time is invalid', {'event time': self.eventTime}) raise ValueError(error_msg)