Skip to content
Snippets Groups Projects
Commit a6c90397 authored by Hakan Calim's avatar Hakan Calim Committed by Karel van Klink
Browse files

NAT-410: added method to validate tt number

parent 4bf38511
No related branches found
No related tags found
1 merge request!159Feature/nat 410 add validator for tty number
......@@ -270,3 +270,24 @@ def validate_interface_name_list(interface_name_list: list, vendor: str) -> list
)
raise ValueError(error_msg)
return interface_name_list
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.
:param str tt_number: The TT number as string to validate
:return str: The tt number string, if tt number match was successful, otherwise it will throw a ValueError
exception.
"""
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment