mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Fixes #136: Trigger error on prefix w/host bits set instead of silently converting it
This commit is contained in:
parent
d2bcd71b32
commit
c9bf10421b
@ -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):
|
class BaseIPField(models.Field):
|
||||||
|
default_validators = [prefix_validator]
|
||||||
|
|
||||||
def python_type(self):
|
def python_type(self):
|
||||||
return IPNetwork
|
return IPNetwork
|
||||||
|
Loading…
Reference in New Issue
Block a user