Fix import statement for regex module in MAC address validation
This commit is contained in:
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from api.models import User
|
from api.models import User
|
||||||
import regex
|
import re
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
def validate_mac_address(value):
|
def validate_mac_address(value):
|
||||||
if not regex.match(r"^([0-9A-Fa-f]{2}-){5}[0-9A-Fa-f]{2}$", value):
|
if not re.match(r"^([0-9A-Fa-f]{2}-){5}[0-9A-Fa-f]{2}$", value):
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
"This field accepts a valid MAC address in the format XX-XX-XX-XX-XX-XX using '-' as the separator."
|
"This field accepts a valid MAC address in the format XX-XX-XX-XX-XX-XX using '-' as the separator."
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user