답변 2개 / 댓글 2개
/api/v1/models/point.py
Copy
from typing import List
from pydantic import BaseModel, Field, validator, ValidationError
class PointBase(BaseModel):
po_content: str
po_point: int = Field(..., description="포인트 점수는 정수여야 합니다.")
po_rel_table: str
po_rel_id: str
po_rel_action: str
@validator("po_point", pre=True, always=True)
def validate_po_point(cls, value):
# Check if value is an integer or can be converted to an integer
if isinstance(value, str) and not value.isdigit():
raise ValueError("po_point는 정수여야 하며 빈 문자열일 수 없습니다.")
return int(value)
class PointListResponse(BaseModel):
total_points: int
page_sum_points: dict = {"positive": 0, "negative": 0}
points: List[PointBase]
답변을 작성하려면 로그인이 필요합니다.
수정 했는데 여전히 안되네요
{"detail":[{"type":"int_parsing","loc":["body","po_point"],"msg":"Input should be a valid integer, unable to parse string as an integer","input":""},{"type":"int_parsing","loc":["body","po_id"],"msg":"Input should be a valid integer, unable to parse string as an integer","input":""}]}