Skip to content
Snippets Groups Projects
Commit 0aaf331a authored by Hakan Calim's avatar Hakan Calim Committed by Neda Moeini
Browse files

NAT-328: Moved the site name validation to this file

parent eeef86b3
Branches
Tags
1 merge request!97Feature/nat 328 site names should be validated
......@@ -179,3 +179,18 @@ def validate_country_code(country_code: str) -> str:
return country_code
except LookupError:
raise ValueError("Invalid or non-existent country code, it must be in ISO 3166-1 alpha-2 format.")
def validate_site_name(site_name: str) -> str:
"""Validate the site name.
The site name must consist of three uppercase letters (A-Z) followed by an optional single digit (0-9).
"""
pattern = re.compile(r"^[A-Z]{3}[0-9]?$")
if pattern.match(site_name):
return site_name
else:
raise ValueError(
"Enter a valid site name. It must consist of three uppercase letters (A-Z) followed by an optional single "
"digit (0-9)."
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment