TorbatYar/backend/services/delivery/app/validators/availability.py
Mortezakoohjani 72077908f1 feat(delivery): deploy backend phases 10.2-10.8 through settlement
Ship fleet, availability, pricing, dispatch, routing, tracking, and settlement on delivery-service 0.10.8.0 with migrations and phase tests green.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 21:01:23 +03:30

37 lines
1.1 KiB
Python

"""Availability validators — Phase 10.3."""
from __future__ import annotations
from datetime import datetime
from shared.exceptions import AppError
from app.validators.foundation import validate_non_empty
def validate_shift_window(*, starts_at: datetime, ends_at: datetime) -> None:
if ends_at <= starts_at:
raise AppError(
"زمان پایان شیفت باید بعد از زمان شروع باشد",
status_code=422,
error_code="invalid_shift_window",
)
def validate_availability_window(
*, effective_from: datetime | None, effective_until: datetime | None
) -> None:
if effective_from and effective_until and effective_until <= effective_from:
raise AppError(
"بازه دسترسی نامعتبر است",
status_code=422,
error_code="invalid_availability_window",
)
def validate_shift_name(name: str) -> str:
return validate_non_empty(name, "name")
def validate_zone_name(name: str) -> str:
return validate_non_empty(name, "name")