import re


def _validate_curie(c, prefixes):
    """Verify that a string is a valid compact URI, like EFO:000001. If prefixes is not empty, make sure the
    prefix of the curies is in prefixes.
    """

    if not c:
        return True

    match = re.match(r"([A-Z]\w+):\d+$", c)

    if prefixes:
        return match and match.group(1) in prefixes
    else:
        return match