(data, valid_values, field=None, default=None)
Validate and correct string value(s) in a dictionary key or list,
    or a string by itself.

    :param data: The data to be verified and corrected.
    :type data: dict, list of strings, or str
    :param valid_values: Key with simplified string, value with actual string
    :type valid_values: dict
    :param field: The dictionary key containing the data.
    :type field: str
    :param default: A value to use if an invalid item cannot be corrected
    :type default: str
    :returns: the validated/corrected value(str), list of values(list) or ''
Validate and correct string value(s) in a dictionary key or list,
    or a string by itself.
Validate and correct string value ( s ) in a dictionary key or list or a string by itself .
def get_verified_field(data, valid_values, field=None, default=None):
    """
    Validate and correct string value(s) in a dictionary key or list,
    or a string by itself.

    :param data: The data to be verified and corrected.
    :type data: dict, list of strings, or str
    :param valid_values: Key with simplified string, value with actual string
    :type valid_values: dict
    :param field: The dictionary key containing the data.
    :type field: str
    :param default: A value to use if an invalid item cannot be corrected
    :type default: str
    :returns: the validated/corrected value(str), list of values(list) or ''
    """

    if isinstance(data, dict):
        data = data.get(field, '')
    if isinstance(data, list):
        value_list = data
    else:
        value_list = [data]
    for i, item in enumerate(value_list):
        if isinstance(item, basestring):
            item = item.lower().strip().replace(' - ', '-')
            if item in valid_values:
                value_list[i] = valid_values[item]
                continue
        if default is not None:
            item = default
            continue
        return ''
    if isinstance(data, list):
        return value_list
    else:
        return value_list[0]
def get_verified_field ( data , valid_values , field = None , default = None ) : if isinstance ( data , dict ) : data = data . get ( field , '' ) if isinstance ( data , list ) : value_list = data else : value_list = [ data ] for i , item in enumerate ( value_list ) : if isinstance ( item , basestring ) : item = item . lower ( ) . strip ( ) . replace ( ' - ' , '-' ) if item in valid_values : value_list [ i ] = valid_values [ item ] continue if default is not None : item = default continue return '' if isinstance ( data , list ) : return value_list else : return value_list [ 0 ]