feat: add generic Value[T] base class for value objects

- Create Value[T] (frozen dataclass + ABC + Generic) in domain/framework/
- Migrate ClassifiedAdTitle and ClassifiedAdText to inherit Value[str]
- Standardize all value access via .value instead of type-specific fields
This commit is contained in:
2026-07-29 11:13:17 -04:00
parent 05229910cd
commit d345e522bd
9 changed files with 150 additions and 102 deletions

View File

@@ -1,10 +1,12 @@
from dataclasses import dataclass
from domain.framework.value import Value
@dataclass(frozen=True)
class ClassifiedAdTitle:
title: str
class ClassifiedAdTitle(Value[str]):
def __post_init__(self):
if len(self.title) > 100:
raise ValueError(f"Title cannot be longer than 100 characters: {self.title}")
if len(self.value) > 100:
raise ValueError(
f"Title cannot be longer than 100 characters: {self.value}"
)