forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidators.py
More file actions
34 lines (25 loc) · 1.15 KB
/
validators.py
File metadata and controls
34 lines (25 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright The IETF Trust 2024, All Rights Reserved
import re
from django import forms
from django.conf import settings
from django.core.exceptions import ValidationError
def prevent_at_symbol(name):
if "@" in name:
raise forms.ValidationError(
"Please fill in name - this looks like an email address (@ is not allowed in names)."
)
def prevent_system_name(name):
name_without_spaces = name.replace(" ", "").replace("\t", "")
if "(system)" in name_without_spaces.lower():
raise forms.ValidationError("Please pick another name - this name is reserved.")
def prevent_anonymous_name(name):
name_without_spaces = name.replace(" ", "").replace("\t", "")
if "anonymous" in name_without_spaces.lower():
raise forms.ValidationError("Please pick another name - this name is reserved.")
def is_allowed_address(value):
"""Validate that an address complies with datatracker requirements"""
for pat in settings.EXCLUDED_PERSONAL_EMAIL_REGEX_PATTERNS:
if re.search(pat, value):
raise ValidationError(
"This email address is not valid in a datatracker account"
)