import click


def validate_fragment_type(ctx, param, value):
    """
    Validate that a given fragment type exists.
    """
    config = ctx.obj.config
    if value and not config.has_fragment_type(value):
        raise click.BadParameter(
            'Missing or unknown fragment type: {}'.format(value))
    return value