-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidators.py
More file actions
34 lines (28 loc) · 1.18 KB
/
validators.py
File metadata and controls
34 lines (28 loc) · 1.18 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
"""Common validators."""
# =============================================================================
# IMPORTS
# =============================================================================
# Django
from django.core.validators import RegexValidator
# App
from project_manager.constants import RELEASE_VERSION_REGEX
# =============================================================================
# ALL DECLARATION
# =============================================================================
__all__ = (
"basename_validator",
"version_validator",
)
# =============================================================================
# GLOBAL VARIABLES
# =============================================================================
# basename values should:
# Start with a lower-case character.
# Contain only lower-case characters, numbers, and underscores.
# End in a lower-case character or number.
basename_validator = RegexValidator(r"^[a-z][0-9a-z_]*[0-9a-z]")
# version values should:
# Start with a number.
# Contain only numbers, lower-case characters, and decimals.
# End in a number or lower-case character.
version_validator = RegexValidator(r"^" + RELEASE_VERSION_REGEX)