Skip to content
Snippets Groups Projects

Feature/nat 328 site names should be validated

Merged Hakan Calim requested to merge feature/NAT-328-Site-names-should-be-validated into develop
Files
6
+ 14
0
@@ -179,3 +179,17 @@ 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 not pattern.match(site_name):
raise ValueError(
"Enter a valid site name. It must consist of three uppercase letters (A-Z) followed by an optional single "
"digit (0-9)."
)
return site_name
Loading