from .exceptions import UndefinedOperatorError


def operator_is_defined(op):
    def checker(operator_function):
        def do_check(self, other):
            if op not in self._operators:
                raise UndefinedOperatorError(op, self, other, self._operators)
            else:
                return operator_function(self, other)
        return do_check
    return checker

@@ -1,8 +1,45 @@
+from collections import defaultdict%0A%0A
 from .ex
@@ -79,16 +79,188 @@
 Error%0A%0A%0A
+def arg(arg_id, *constraints):%0A    return ArgCheckAdder(arg_id, *constraints)%0A%0A%0Adef args(arg_id, constraint, or_=None):%0A    return ArgCheckAdder(arg_id, constraint, or_)%0A%0A%0A
 def oper
@@ -568,16 +568,16 @@
 o_check%0A
-
     retu
@@ -587,8 +587,914 @@
 checker%0A
+%0A%0Adef is_a(type_):%0A    pass%0A%0A%0Adef length(min=0, max=None):%0A    pass%0A%0A%0Adef value(min=0, max=None):%0A    pass%0A%0A%0Adef equal(get_attr):%0A    pass%0A%0A%0Adef match(get_attr):%0A    pass%0A%0A%0Aclass ArgCheckAdder(object):%0A    def __init__(self, arg_id, *constraints):%0A        self.arg_id = arg_id%0A        self.constraints = constraints%0A%0A    def __call__(self, func):%0A        if hasattr(func, 'checks'):%0A            func.checks%5Barg_id%5D.extend(self.constraints)%0A            return func%0A        else:%0A            return CheckedFunction(func, %7Bself.arg_id: self.constraints%7D)%0A%0A%0Aclass CheckedFunction(object):%0A    def __init__(self, func, checks):%0A        self.checks = defaultdict(list)%0A        self.checks.update(checks)%0A        self.func = func%0A%0A    def __call__(self, *args, **kwargs):%0A        for arg_id, check in self.checks.items():%0A            check(self.get_args(arg_id, args, kwargs))%0A        self.func(*args, **kwargs)%0A%0A

Work on check.py