Skip to content

Commit 9bc7e82

Browse files
authored
Merge pull request #432 from iCasture/master
fix: reject MAC addresses with mixed separators
2 parents 5440442 + 402b351 commit 9bc7e82

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/validators/mac_address.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,8 @@ def mac_address(value: str, /):
2929
(Literal[True]): If `value` is a valid MAC address.
3030
(ValidationError): If `value` is an invalid MAC address.
3131
"""
32+
# Check for mixed separators: MAC addresses cannot use both ':' and '-' simultaneously
33+
if ":" in value and "-" in value:
34+
return False
35+
3236
return re.match(r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$", value) if value else False

0 commit comments

Comments
 (0)