Update validate static function
This commit is contained in:
parent
6e4959e918
commit
e8acbd89c7
|
@ -8,12 +8,14 @@
|
||||||
from tubot.static.abc import IValidatable
|
from tubot.static.abc import IValidatable
|
||||||
|
|
||||||
|
|
||||||
async def validate(obj: IValidatable) -> bool:
|
async def validate(obj: IValidatable, msg: str | None = None) -> bool:
|
||||||
"""
|
"""
|
||||||
Checks the validity of the object
|
Throws an exception if the object has not been validated
|
||||||
|
|
||||||
:return: Object validity boolean
|
:return: Object validity boolean
|
||||||
"""
|
"""
|
||||||
if await obj.__validate__():
|
if await obj.__validate__():
|
||||||
return True
|
return True
|
||||||
raise TypeError("Object validation failed")
|
if msg is None:
|
||||||
|
raise TypeError("Object validation failed")
|
||||||
|
raise TypeError(f"Object validation failed: {msg}")
|
||||||
|
|
Reference in New Issue