def get_int(value, default, test_fn=None):
    """Convert value to integer.

    :param value: Integer value.
    :param default: Default value on failed conversion.
    :param test_fn: Constraint function. Use default if returns ``False``.
    :return: Integer value.
    :rtype:  ``int``
    """
    try:
        converted = int(value)
    except ValueError:
        return default

    test_fn = test_fn if test_fn else lambda x: True
    return converted if test_fn(converted) else default
Convert value to integer.

    :param value: Integer value.
    :param default: Default value on failed conversion.
    :param test_fn: Constraint function. Use default if returns ``False``.
    :return: Integer value.
    :rtype:  ``int``