forked from OrudoCA/qBitDownload-Bot
22 lines
510 B
Python
22 lines
510 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
####################
|
|
# Static functions #
|
|
####################
|
|
|
|
# Imports
|
|
from tubot.static.abc import IValidatable
|
|
|
|
|
|
async def validate(obj: IValidatable, msg: str | None = None) -> bool:
|
|
"""
|
|
Throws an exception if the object has not been validated
|
|
|
|
:return: Object validity boolean
|
|
"""
|
|
if await obj.__validate__():
|
|
return True
|
|
if msg is None:
|
|
raise TypeError("Object validation failed")
|
|
raise TypeError(f"Object validation failed: {msg}")
|