@@ -80,7 +80,7 @@ def _check_string_not_empty(value, name, operation):
8080 return True
8181
8282
83- def _check_string_matches (value , operation , pattern ):
83+ def _check_string_matches (value , operation , pattern , name ):
8484 """
8585 Check if value is adhere to a regular expression passed.
8686
@@ -93,14 +93,14 @@ def _check_string_matches(value, operation, pattern):
9393 :return: The result of validation
9494 :rtype: True|False
9595 """
96- if not re .match (pattern , value ):
96+ if re . search ( pattern , value ) is None or re .search (pattern , value ). group () != value :
9797 _LOGGER .error (
9898 '%s: you passed %s, event_type must ' +
9999 'adhere to the regular expression %s. ' +
100- 'This means an event name must be alphanumeric, cannot be more ' +
100+ 'This means %s must be alphanumeric, cannot be more ' +
101101 'than 80 characters long, and can only include a dash, underscore, ' +
102102 'period, or colon as separators of alphanumeric characters.' ,
103- operation , value , pattern
103+ operation , value , pattern , name
104104 )
105105 return False
106106 return True
@@ -323,7 +323,7 @@ def validate_event_type(event_type):
323323 if (not _check_not_null (event_type , 'event_type' , 'track' )) or \
324324 (not _check_is_string (event_type , 'event_type' , 'track' )) or \
325325 (not _check_string_not_empty (event_type , 'event_type' , 'track' )) or \
326- (not _check_string_matches (event_type , 'track' , EVENT_TYPE_PATTERN )):
326+ (not _check_string_matches (event_type , 'track' , EVENT_TYPE_PATTERN , 'an event name' )):
327327 return None
328328 return event_type
329329
@@ -591,10 +591,9 @@ def validate_flag_sets(flag_sets, method_name):
591591 flag_set = _remove_empty_spaces (flag_set , 'flag set' , method_name )
592592 flag_set = _convert_str_to_lower (flag_set , 'flag set' , method_name )
593593
594- if re .search (_FLAG_SETS_REGEX , flag_set ) is None or re .search (_FLAG_SETS_REGEX , flag_set ).group () != flag_set :
595- _LOGGER .warning ("%s: you passed %s, flag set must adhere to the regular expressions %s. This means a flag set must start with a letter, be in lowercase, alphanumeric and have a max length of 50 characteres. %s was discarded." , flag_set , _FLAG_SETS_REGEX , flag_set )
594+ if not _check_string_matches (flag_set , method_name , _FLAG_SETS_REGEX , 'a flag set' ):
596595 continue
597596
598- sanitized_flag_sets .add (flag_set . strip () )
597+ sanitized_flag_sets .add (flag_set )
599598
600599 return sorted (list (sanitized_flag_sets ))
0 commit comments