fastapi-svelte-template/backend/todo/schemas/common.py

13 lines
356 B
Python
Raw Normal View History

"""This module contains common functions for schema validation."""
def is_valid_id(id: int) -> bool:
"""Checks whether the specified id is a valid ID.
Performs a shallow check on whether the ID is a valid primary key.
"""
if not isinstance(id, int):
raise TypeError(f"Expected an integer but got: {type(id)}")
return id > 0