Skip to content
Snippets Groups Projects

Feature/nat 410 add validator for tty number

Merged Hakan Calim requested to merge feature/NAT-410_add_validator_for_tty_number into develop
All threads resolved!
Files
7
+ 20
0
@@ -270,3 +270,23 @@ 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 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
Loading