1. George Notaras
  2. django-powerdns-manager

Commits

George Notaras  committed 5c5206f

Implemented NS record validation.

  • Participants
  • Parent commits fdbbbf0
  • Branches default

Comments (0)

Files changed (1)

File src/powerdns_manager/forms.py

View file
  • Ignore whitespace
 from django.core.exceptions import ValidationError
 
 from powerdns_manager import settings
+from powerdns_manager.utils import validate_hostname
 
 
 
 class NsRecordModelForm(BaseRecordModelForm):
     """ModelForm for NS resource records."""
 
+    def clean_name(self):
+        name = self.cleaned_data.get('name')
+        validate_hostname(name)
+        return name
+    
+    def clean_content(self):
+        content = self.cleaned_data.get('content')
+        validate_hostname(content)
+        return content
+
     def save(self, *args, **kwargs):
         self.instance.type = 'NS'
         return super(NsRecordModelForm, self).save(*args, **kwargs)