Refactor validator.isOfType, add support for primitives