Model/domain/postcode.py
2026-05-20 13:21:11 +00:00

15 lines
376 B
Python

from __future__ import annotations
from dataclasses import dataclass
@dataclass(frozen=True)
class Postcode:
value: str
def __post_init__(self) -> None:
# Frozen dataclass: bypass the descriptor with object.__setattr__.
object.__setattr__(self, "value", "".join(self.value.split()).upper())
def __str__(self) -> str:
return self.value