refactor validator for optimized recursive object traversal