33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
from sqlalchemy import Column, String, Text, DateTime
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.sql import func
|
|
from core.database import Base
|
|
import uuid
|
|
import email_validator
|
|
|
|
class ContactForm(Base):
|
|
__tablename__ = "contact_forms"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
name = Column(String, nullable=False)
|
|
email = Column(String, nullable=False)
|
|
message = Column(Text, nullable=False)
|
|
created_at = Column(DateTime, default=func.now())
|
|
updated_at = Column(DateTime, default=func.now(), onupdate=func.now())
|
|
|
|
@staticmethod
|
|
def validate_email(email: str) -> bool:
|
|
"""
|
|
Validates the provided email address using the email_validator package.
|
|
|
|
Args:
|
|
email (str): The email address to validate.
|
|
|
|
Returns:
|
|
bool: True if the email is valid, False otherwise.
|
|
"""
|
|
try:
|
|
email_validator.validate_email(email)
|
|
return True
|
|
except email_validator.EmailNotValidError:
|
|
return False |