import re
import click


def validate_id(ctx,
                param: str,
                value: str) -> str:
    """
    Allows group code to consist only of letters/numbers/underscore

    :param ctx: Click context
    :param param: Name of parameter (`id`)
    :type param: str
    :param value: Value of `id` parameter
    :type value: str

    :return: true if value passes
    :rtype: str

    :raise click.BadParameter:
    """
    if re.match("^[A-z0-9]+[A-z0-9_]+$", value):
        return value
    else:
        raise click.BadParameter('Only letters, numbers, underscores '
                                 'are allowed. Underscore can\'t go first')