model: optimization pass on custom validator
(This commit is actually doing two things /o\)
- we inline the type-checking in the custom validator to reduce the number of function call.
- we optimize some of the custom validator by skipping the creation of intermediate tuples.