import click


def _prompt(msg, default=None, type=None, validation_fn=None):
    """Wraps a `click.prompt` call with retries and validation."""
    res = None
    while True:
        res = click.prompt(msg, default=default, type=type)
        if validation_fn is not None:
            is_valid, errors = validation_fn(res)
            if not is_valid:
                click.echo(f"invalid input: {errors}")
                continue
        break
    return res