mirror of
https://github.com/wizarrrr/wizarr.git
synced 2026-04-19 05:28:33 -04:00
22 lines
568 B
Python
22 lines
568 B
Python
"""
|
|
Shared form validation constants and filters.
|
|
"""
|
|
|
|
from typing import Any
|
|
|
|
USERNAME_PATTERN = r"^[\w'.-]+$"
|
|
USERNAME_MIN_LENGTH = 3
|
|
USERNAME_MAX_LENGTH = 15
|
|
USERNAME_LENGTH_MESSAGE = "Username must be 3 to 15 characters."
|
|
USERNAME_ALLOWED_CHARS_MESSAGE = (
|
|
"Username can contain letters, numbers, dashes (-), underscores (_), "
|
|
"apostrophes ('), and periods (.)."
|
|
)
|
|
|
|
|
|
def strip_filter(value: Any):
|
|
"""Trim leading/trailing whitespace from string inputs before validation."""
|
|
if isinstance(value, str):
|
|
return value.strip()
|
|
return value
|