def METHOD_NAME(pattern: str) -> Optional[re.Pattern]:
    """
    Compile and vet a user id pattern.
    :pattern: String format of the regex to parse
    :raise VitalSourceMalformedRegex: For any issues with the regex
    """
    if not pattern:
        return None
    try:
        compiled_pattern = re.compile(pattern)
    except re.error as err:
        raise VitalSourceMalformedRegex(str(err), pattern=pattern) from err
    if compiled_pattern.groups != 1:
        raise VitalSourceMalformedRegex(
            "The user regex must have one capture group (brackets)", pattern=pattern
        )
    return compiled_pattern