From 1497a81cd506d8f936d4f4c2f7bec5c6f16de714 Mon Sep 17 00:00:00 2001 From: counterweight Date: Sun, 21 Dec 2025 17:56:38 +0100 Subject: [PATCH] Add backend validation for note length using constant - Updated BookingRequest validator to use NOTE_MAX_LENGTH constant - Replaced hardcoded 144 with constant for consistency - Error message now includes the actual max length value --- backend/schemas.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/schemas.py b/backend/schemas.py index b79691b..1993ebe 100644 --- a/backend/schemas.py +++ b/backend/schemas.py @@ -4,6 +4,8 @@ from typing import Generic, TypeVar from pydantic import BaseModel, EmailStr, field_validator +from shared_constants import NOTE_MAX_LENGTH + class UserCredentials(BaseModel): """Base model for user email/password.""" @@ -207,8 +209,8 @@ class BookingRequest(BaseModel): @field_validator("note") @classmethod def validate_note_length(cls, v: str | None) -> str | None: - if v is not None and len(v) > 144: - raise ValueError("Note must be at most 144 characters") + if v is not None and len(v) > NOTE_MAX_LENGTH: + raise ValueError(f"Note must be at most {NOTE_MAX_LENGTH} characters") return v