~sirodoht/mataroa

ref: e6f4cf9f3f47eb8c331c566d0e36ed2f71db2399 mataroa/main/validators.py -rw-r--r-- 422 bytes
e6f4cf9fTheodore Keloglou add redirect domain on user a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
from django.core import validators as dj_validators
from django.core.exceptions import ValidationError


class AlphanumericHyphenValidator(dj_validators.RegexValidator):
    regex = r"^[a-z\d-]+\Z"
    message = "Enter a valid username, it should include only lowercase letters, numbers, and -"
    flags = 0


def validate_domain_name(value):
    if "." not in value:
        raise ValidationError("Invalid domain name")