mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-11-21 10:24:05 +01:00
@@ -1,5 +1,6 @@
|
||||
"""Admin API v2 serializers."""
|
||||
|
||||
import ipaddress
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
@@ -230,6 +231,21 @@ class AdminGlobalParametersSerializer(serializers.Serializer):
|
||||
)
|
||||
return value
|
||||
|
||||
def validate_valid_mxs(self, value):
|
||||
"""Make sure it only contains IP addresses."""
|
||||
if not value:
|
||||
return value
|
||||
try:
|
||||
ip_addresses = [
|
||||
ipaddress.ip_network(v.strip())
|
||||
for v in value.split() if v.strip()
|
||||
]
|
||||
except ValueError:
|
||||
raise serializers.ValidationError(
|
||||
_("This field only allows valid IP addresses (or networks)")
|
||||
)
|
||||
return value
|
||||
|
||||
def validate(self, data):
|
||||
"""Check MX options."""
|
||||
condition = (
|
||||
|
||||
Reference in New Issue
Block a user