Rather than using a validate method in a validator, it might be better to use __call__ - you can make objects callable, but you can't make functions and closures into objects with methods other than the function that they are.
Then you can write a validator as lamba x: assert(x > 0 && x < 100) or something like that
Rather than using a
validate
method in a validator, it might be better to use__call__
- you can make objects callable, but you can't make functions and closures into objects with methods other than the function that they are.Then you can write a validator as
lamba x: assert(x > 0 && x < 100)
or something like that