Spaces:
Sleeping
Sleeping
File size: 840 Bytes
7952f32 | 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 | """Input validation functions for the task manager."""
from __future__ import annotations
VALID_PRIORITIES = {"low", "medium", "high"}
def validate_title(title: str) -> bool:
"""Return True if title is a non-empty string <= 200 chars."""
return isinstance(title, str) and 0 < len(title) <= 200
def validate_tags(tags: object) -> bool:
"""Return True if tags is a list of strings."""
return isinstance(tags, list) and all(isinstance(t, str) for t in tags)
def validate_email(email: str) -> bool:
"""Return True if email looks like a valid address (contains @ and .)."""
return isinstance(email, str) and "@" in email and "." in email.split("@")[-1]
def validate_priority(priority: str) -> bool:
"""Return True if priority is one of 'low', 'medium', or 'high'."""
return priority in VALID_PRIORITIES
|