def enum(all_vars, default):
    """Check input against accepted set or return a default."""

    def get_value(test_value):
        if test_value in all_vars:
            return test_value
        else:
            return default

    return get_value