@exceptions.rewrap(ValueError, FloatRequired)
def require_float(value, min=None, max=None):
    """Jinja2 filter used to enforce an float type in a template.

    Accepts optional min/max constraints.

    Usage:
        {{ my_float_value|require_float }}
        {{ my_float_value|require_float(min=0) }}
        {{ my_float_value|require_float(min=0, max=20) }}
        {{ my_float_value|require_float(max=20) }}
    """
    value = float(value)

    # check the float falls within the allowed range if set
    if min is not None and value < min:
        raise FloatTooSmall("%f is smaller than the minimum allowed value of %f" % (value, min))
    if max is not None and value > max:
        raise FloatTooLarge("%f is larger than the maximum allowed value of %f" % (value, max))

    return value
dataset/ETHPy150Open shopkeep/shpkpr/shpkpr/template_filters.py/require_float/original