def validate_length(low=None, high=None, equal=None):
    """
    Validate the length of a field with either low, high, or equal.
    Should work with anything that supports len().

    :param low: Smallest length required.
    :param high: Longest length required.
    :param equal: Exact length required.
    :raises: ``ValidationError('length_low')``
    :raises: ``ValidationError('length_high')``
    :raises: ``ValidationError('length_between')``
    :raises: ``ValidationError('length_equal')``
    """
    def length_validator(field, data):
        if field.value is None:
            return
        if equal is not None and len(field.value) != equal:
            raise ValidationError('length_equal', equal=equal)
        if low is not None and len(field.value) < low:
            key = 'length_low' if high is None else 'length_between'
            raise ValidationError(key, low=low, high=high)
        if high is not None and len(field.value) > high:
            key = 'length_high' if low is None else 'length_between'
            raise ValidationError(key, low=low, high=high)
    return length_validator