4
1
Fork 1
This repository has been archived on 2024-08-07. You can view files and clone it, but cannot push or open issues or pull requests.
qBitDownload-Bot/tubot/static/functions.py

22 lines
510 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
####################
# Static functions #
####################
# Imports
from tubot.static.abc import IValidatable
2024-08-03 10:49:08 +00:00
async def validate(obj: IValidatable, msg: str | None = None) -> bool:
"""
2024-08-03 10:49:08 +00:00
Throws an exception if the object has not been validated
:return: Object validity boolean
"""
if await obj.__validate__():
return True
2024-08-03 10:49:08 +00:00
if msg is None:
raise TypeError("Object validation failed")
raise TypeError(f"Object validation failed: {msg}")