Skip to content

Commit

Permalink
Return the string value after validation
Browse files Browse the repository at this point in the history
"any".title() returns "Any" etc, which is not necessary
  • Loading branch information
sajith committed Sep 10, 2024
1 parent 16e17a9 commit 2909897
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sdx_datamodel/models/connection_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def validate_vlan(cls, value: str) -> str:
if int(value) not in range(1, 4095):
raise ValueError(f"vlan {value} is not in [1,4095] range")
else:
return value.title()
return value

# a range like "1:100" is valid.
if ":" in value:
Expand All @@ -41,15 +41,15 @@ def validate_vlan(cls, value: str) -> str:
if x > y:
raise ValueError(f"vlan {value} is invalid: {x} > {y}")
# this range is probably okay.
return value.title()
return value
else:
raise ValueError(f"vlan {value} is an invalid range")

# "any", "all", and "untagged" also are valid.
if value not in ("any", "all", "untagged"):
raise ValueError(f"VLAN {value} is not valid")
else:
return value.title()
return value

raise ValueError(f"vlan {value} is invalid")

Expand Down

0 comments on commit 2909897

Please sign in to comment.