Skip to content
Snippets Groups Projects
Commit 7cd6e1e0 authored by Hakan Calim's avatar Hakan Calim
Browse files

NAT-328: updated validation site name by an utils method

parent 70780c81
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !97. Comments created here will be created in the context of that merge request.
import ipaddress
import re
from typing import NoReturn
import pycountry
......@@ -15,6 +14,7 @@ from gso.products.product_blocks import site as site_pb
from gso.products.product_blocks.site import LatitudeCoordinate, LongitudeCoordinate
from gso.products.product_types import site
from gso.services.crm import customer_selector
from gso.util.helpers import validate_site_name
def initial_input_form_generator(product_name: str) -> FormGenerator: # noqa: C901
......@@ -52,12 +52,7 @@ def initial_input_form_generator(product_name: str) -> FormGenerator: # noqa: C
@validator("site_name", allow_reuse=True)
def site_name_must_be_valid(cls, site_name: str) -> str | NoReturn:
# Accept 3 chapital letters and only one ditigt after capital letters.
pattern = re.compile(r"^[A-Z]{3}[0-9]?$")
if not bool(pattern.match(site_name)):
raise ValueError(f"Enter a valid site name similar looks like AMS, AMS1or LON9. Get: {site_name}")
return site_name
return validate_site_name(site_name)
user_input = yield CreateSiteForm
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment