chore(release): harden nick contract for v0.1.2

This commit is contained in:
2026-08-15 23:46:57 +09:00
parent e6a90800ec
commit c292df0a4b
8 changed files with 97 additions and 22 deletions
+21 -1
View File
@@ -6,7 +6,7 @@ from datetime import date, datetime
from decimal import Decimal
from typing import Any, Literal
from pydantic import BaseModel, ConfigDict, Field, model_validator
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
# ---------------------------------------------------------------------------
@@ -322,6 +322,16 @@ class StrategyCreateRequest(BaseModel):
config: dict[str, Any] = Field(default_factory=dict)
status: StrategyStatus = "active"
@field_validator("nick")
@classmethod
def normalize_nick(cls, value: str | None) -> str | None:
if value is None:
return None
normalized = value.strip()
if not normalized:
raise ValueError("nick must not be blank")
return normalized
class StrategyUpdateRequest(BaseModel):
model_config = ConfigDict(extra="forbid")
@@ -331,6 +341,16 @@ class StrategyUpdateRequest(BaseModel):
config: dict[str, Any] | None = None
status: StrategyStatus | None = None
@field_validator("nick")
@classmethod
def normalize_nick(cls, value: str | None) -> str | None:
if value is None:
return None
normalized = value.strip()
if not normalized:
raise ValueError("nick must not be blank")
return normalized
@model_validator(mode="after")
def require_change(self) -> "StrategyUpdateRequest":
if not self.model_fields_set: