Change DNSValidator-Regex

This Change the Regex for DNSValidator to be valid as per RFC 1123. Originally, RFC 952 specified that hostname segments could not start with a digit. 

From: http://en.wikipedia.org/wiki/Hostname
``
The original specification of hostnames in RFC 952, mandated that labels could not start with a digit or with a hyphen, and must not end with a hyphen. However, a subsequent specification (RFC 1123) permitted hostname labels to start with digits.
``
This commit is contained in:
Oli 2019-05-21 09:16:29 +02:00 committed by GitHub
parent c24fb8df84
commit eb9d3183b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@ from django.core.validators import RegexValidator
DNSValidator = RegexValidator(
regex='^[0-9A-Za-z.-]+$',
regex='^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$',
message='Only alphanumeric characters, hyphens, and periods are allowed in DNS names',
code='invalid'
)