mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #136: Trigger error on prefix w/host bits set instead of silently converting it
This commit is contained in:
@@ -10,7 +10,13 @@ from .lookups import (
|
||||
)
|
||||
|
||||
|
||||
def prefix_validator(prefix):
|
||||
if prefix.ip != prefix.cidr.ip:
|
||||
raise ValidationError("{} is not a valid prefix. Did you mean {}?".format(prefix, prefix.cidr))
|
||||
|
||||
|
||||
class BaseIPField(models.Field):
|
||||
default_validators = [prefix_validator]
|
||||
|
||||
def python_type(self):
|
||||
return IPNetwork
|
||||
|
Reference in New Issue
Block a user