Skip to content

Tt number

A Trouble Ticket number.

validate_tt_number(tt_number)

Validate a string to match a specific pattern.

This method checks if the input string starts with 'TT#' and is followed by exactly 16 digits.

Parameters:

Name Type Description Default
tt_number str

The TT number as string to validate

required

Returns:

Type Description
str

The TT number string if TT number match was successful, otherwise it will raise a ValueError.

Source code in gso/utils/types/tt_number.py
def validate_tt_number(tt_number: str) -> str:
    """Validate a string to match a specific pattern.

    This method checks if the input string starts with 'TT#' and is followed by exactly 16 digits.

    Args:
        tt_number: The TT number as string to validate

    Returns:
        The TT number string if TT number match was successful, otherwise it will raise a ValueError.
    """
    pattern = r"^TT#\d{16}$"
    if not bool(re.match(pattern, tt_number)):
        err_msg = (
            f"The given TT number: {tt_number} is not valid. "
            f" A valid TT number starts with 'TT#' followed by 16 digits."
        )
        raise ValueError(err_msg)

    return tt_number