1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #3047: Fix exception string for invalid MAC Address format

This commit is contained in:
dansheps
2019-04-05 09:36:56 -05:00
parent 1b389d662b
commit e556c78599

View File

@ -2,6 +2,7 @@ from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator, MaxValueValidator
from django.db import models
from netaddr import AddrFormatError, EUI, mac_unix_expanded
import pprint
class ASNField(models.BigIntegerField):
@ -31,7 +32,7 @@ class MACAddressField(models.Field):
try:
return EUI(value, version=48, dialect=mac_unix_expanded_uppercase)
except AddrFormatError as e:
raise ValidationError(e)
raise ValidationError("Invalid MAC address format: {}".format(value))
def db_type(self, connection):
return 'macaddr'