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
1 file
+ 15
0
Compare changes
  • Side-by-side
  • Inline
  • 0aaf331a
    NAT-328: Moved the site name validation to this file · 0aaf331a
    Hakan Calim authored
+ 15
0
@@ -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)."
)
Loading