from typing import Annotated
from annotated_types import (
MaxLen,
MinLen,
)
from pydantic import field_validator
from app.lib.schema import (
CamelizedBaseSchema,
CamelizedBaseStruct,
)
__all__ = (
"EquipmentCreate",
"EquipmentRead",
"EquipmentUpdate",
"ExerciseTagCreate",
"ExerciseTagRead",
"ExerciseTagUpdate",
"FieldsReadBase",
"MuscleGroupCreate",
"MuscleGroupRead",
"MuscleGroupUpdate",
)
[docs]
class FieldsReadBase(CamelizedBaseStruct):
"""Base schema for reading catalog items."""
id: int
name: str
[docs]
class FieldsCreateBase(CamelizedBaseSchema):
"""Base schema for creating new catalog items."""
name: Annotated[str, MinLen(3), MaxLen(100)]
@field_validator("name", mode="after")
def normalize_name(cls, v: str) -> str: # noqa: N805
return " ".join(v.split()).lower()
[docs]
class FieldsUpdateBase(FieldsCreateBase):
"""Base schema for updating catalog items."""
[docs]
class MuscleGroupCreate(FieldsCreateBase):
"""Schema for creating a new muscle group.
Example: 'chest', 'biceps'.
"""
[docs]
class EquipmentCreate(FieldsCreateBase):
"""Schema for creating a new piece of equipment.
Example: 'barbell', 'kettlebells'.
"""
[docs]
class ExerciseTagCreate(FieldsCreateBase):
"""Schema for creating a new exercise tag.
Example: 'mobility', 'isometric'.
"""
[docs]
class MuscleGroupRead(FieldsReadBase):
"""Public representation of a muscle group."""
[docs]
class EquipmentRead(FieldsReadBase):
"""Public representation of a piece of equipment."""
[docs]
class ExerciseTagRead(FieldsReadBase):
"""Public representation of an exercise tag."""
[docs]
class MuscleGroupUpdate(FieldsUpdateBase):
"""Schema for updating a muscle group."""
[docs]
class EquipmentUpdate(FieldsUpdateBase):
"""Schema for updating a piece of equipment."""
[docs]
class ExerciseTagUpdate(FieldsUpdateBase):
"""Schema for updating an exercise tag."""