def read_value (fields, name, validate_fn):
    """Retrieve a value from an epgdb record and validate it.

fields: The record dict
name: The field name
validate_fn:
    Function used to validate the value (like the function returned by
    `validate`)

Returns the value to use or throws `ValueError`.

"""
    value = fields.get(name)
    try:
        return validate_fn(value)
    except ValueError as e:
        raise ValueError('found item with unexpected value',
                         {'field': name, 'fields': fields},
                         *e.args)