mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
12278 remove validator
This commit is contained in:
parent
7bdefbb264
commit
762d9bdbf6
@ -2,7 +2,6 @@ from django.utils.translation import gettext_lazy as _
|
||||
from rest_framework import serializers
|
||||
|
||||
from ipam import models
|
||||
from ipam.validators import validate_ipaddress_with_mask
|
||||
from netaddr import AddrFormatError, IPNetwork
|
||||
|
||||
__all__ = [
|
||||
@ -21,11 +20,6 @@ class IPAddressField(serializers.CharField):
|
||||
'invalid': _('Enter a valid IPv4 or IPv6 address with optional mask.'),
|
||||
}
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
validator = validate_ipaddress_with_mask
|
||||
self.validators.append(validator)
|
||||
|
||||
def to_internal_value(self, data):
|
||||
try:
|
||||
return IPNetwork(data)
|
||||
|
@ -1,6 +1,5 @@
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import BaseValidator, RegexValidator
|
||||
from netaddr import AddrFormatError, IPNetwork
|
||||
|
||||
|
||||
def prefix_validator(prefix):
|
||||
@ -29,13 +28,3 @@ DNSValidator = RegexValidator(
|
||||
message='Only alphanumeric characters, asterisks, hyphens, periods, and underscores are allowed in DNS names',
|
||||
code='invalid'
|
||||
)
|
||||
|
||||
|
||||
def validate_ipaddress_with_mask(address):
|
||||
if address:
|
||||
try:
|
||||
IPNetwork(address)
|
||||
except AddrFormatError:
|
||||
raise ValidationError("Invalid IP address format: {}".format(address))
|
||||
except (TypeError, ValueError) as e:
|
||||
raise ValidationError(e)
|
||||
|
Loading…
Reference in New Issue
Block a user