from dataclasses import dataclass from uuid import UUID, uuid4 from api.domain.user import UserValidationError @dataclass class User: id: UUID name: str email: str password: str @staticmethod def create(name: str, email: str, password: str) -> "User": if not name: raise UserValidationError("User name cannot be empty") if not email: raise UserValidationError("User email cannot be empty") if len(name) > 50: raise UserValidationError("User name cannot be longer than 50 characters") if len(email) > 30: raise UserValidationError("User email cannot be longer than 30 characters") return User( id=uuid4(), name=name, email=email, password=password, )