Includes the Validate
superclass, the validate
decorator, and the ValidationError
exception.
Inheriting from Validate
or using the validate
decorator will result in instantiation type-checking based on annotations, as well as in-method attribute static-typing by raising ValidationError
.
from tsclasses import Validate
class Example(Validate):
number: int
def __init__(self, *args, **kwargs):
self.string = "five"
def valid_method(self):
self.number = 5
def invalid_method(self):
self.string = 5