Reject non-integer weekday values in presence pattern requests
The create and edit pattern models typed weekday values as lax int, so JSON true, "1" and 1.0 were coerced to weekday 1. Type them StrictInt so each is a 422 naming the pattern field, and add create and edit regression cases for bool, string, float and out-of-range weekdays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+5
-4
@@ -623,15 +623,16 @@ class AdminPresencePatternCreateRequest(BaseModel):
|
||||
covers that week (Monday=0); every week of the cycle must be
|
||||
covered, which the PRESENCE MODEL enforces at construction, not
|
||||
this shape — as it does the non-blank ``name`` and the
|
||||
``home``/``away`` ``kind``. ``cycle_length_weeks`` is a strict
|
||||
JSON integer: ``2.0`` or ``"2"`` is a 422, not a silent coercion.
|
||||
``home``/``away`` ``kind``. ``cycle_length_weeks`` and the weekday
|
||||
values are strict JSON integers: ``2.0``, ``"2"`` or ``true`` is a
|
||||
422, not a silent coercion.
|
||||
"""
|
||||
|
||||
name: str
|
||||
kind: str
|
||||
cycle_length_weeks: StrictInt
|
||||
anchor_date: str
|
||||
pattern: dict[int, list[int]]
|
||||
pattern: dict[int, list[StrictInt]]
|
||||
|
||||
|
||||
class AdminPresencePatternEditRequest(BaseModel):
|
||||
@@ -646,7 +647,7 @@ class AdminPresencePatternEditRequest(BaseModel):
|
||||
kind: str | None = None
|
||||
cycle_length_weeks: StrictInt | None = None
|
||||
anchor_date: str | None = None
|
||||
pattern: dict[int, list[int]] | None = None
|
||||
pattern: dict[int, list[StrictInt]] | None = None
|
||||
|
||||
|
||||
class AdminPresencePatternResponse(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user