Add helper functions for None
This commit is contained in:
parent
85cc4624e9
commit
90ff6d0e3b
69
helpers/none_helpers.py
Normal file
69
helpers/none_helpers.py
Normal file
@ -0,0 +1,69 @@
|
||||
from typing import Dict, Optional
|
||||
from pydantic import BaseModel, validator
|
||||
|
||||
def validate_yoloo_message(message: str) -> bool:
|
||||
"""
|
||||
Validates if the yoloo message meets requirements.
|
||||
|
||||
Args:
|
||||
message: The message to validate
|
||||
|
||||
Returns:
|
||||
bool: True if message is valid, False otherwise
|
||||
"""
|
||||
if not message:
|
||||
return False
|
||||
if len(message) > 100:
|
||||
return False
|
||||
return True
|
||||
|
||||
def format_yoloo_response(message: str = "yoloo!!") -> Dict[str, str]:
|
||||
"""
|
||||
Formats the yoloo message into a standard response format.
|
||||
|
||||
Args:
|
||||
message: The message to format
|
||||
|
||||
Returns:
|
||||
Dict containing formatted message
|
||||
"""
|
||||
return {
|
||||
"message": message,
|
||||
"status": "success"
|
||||
}
|
||||
|
||||
def get_default_yoloo() -> str:
|
||||
"""
|
||||
Returns the default yoloo message.
|
||||
|
||||
Returns:
|
||||
str: Default yoloo message
|
||||
"""
|
||||
return "yoloo!!"
|
||||
|
||||
def sanitize_yoloo_message(message: str) -> str:
|
||||
"""
|
||||
Sanitizes the yoloo message by removing unwanted characters.
|
||||
|
||||
Args:
|
||||
message: Message to sanitize
|
||||
|
||||
Returns:
|
||||
str: Sanitized message
|
||||
"""
|
||||
# Remove special characters except ! and basic punctuation
|
||||
sanitized = ''.join(c for c in message if c.isalnum() or c in "!.,? ")
|
||||
return sanitized.strip()
|
||||
|
||||
def transform_yoloo_case(message: str, to_upper: bool = False) -> str:
|
||||
"""
|
||||
Transforms the yoloo message case.
|
||||
|
||||
Args:
|
||||
message: Message to transform
|
||||
to_upper: If True converts to uppercase, otherwise lowercase
|
||||
|
||||
Returns:
|
||||
str: Transformed message
|
||||
"""
|
||||
return message.upper() if to_upper else message.lower()
|
Loading…
x
Reference in New Issue
Block a user