import re import importlib def is_valid_email(email): email_regex = r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$' return re.match(email_regex, email) is not None def build_serializer_class(source): # Remove the 's' character at the end if present if source.endswith('s'): source = source[:-1] # Capitalize words separated by a dash words = source.split('-') capitalized_words = [word[0].upper() + word[1:] for word in words] transformed_string = ''.join(capitalized_words) # Add 'Serializer' at the end transformed_string += 'Serializer' module = importlib.import_module('api.serializers') return getattr(module, transformed_string)