import string
import random


def generate_random_string(field, **kwargs):
    """
    Generate a random string. If there is a default value, use it.
    If field is not required, return an empty result.

    Args:
        field: The field object.
    Keyword Arguments:
        only_required: The argument to generate only required fields.
        fulldate: A boolen to decide if must be a timestamp or time.
        index: The index that indicate the record line on CSV.

    Returns:
        A random string value using a min and max length.
    """
    if not field['required'] and kwargs.get("only_required"):
        return ''
    if 'format' in field:
        return str(field['format']).format(index=kwargs.get("index"))
    random_values = string.ascii_lowercase
    string_size = random.randint(field['min_length'], field['max_length'])
    random_str = ''.join(random.choices(random_values, k=string_size))
    return str(random_str.title())