Added unit tests for validation logic with custom error object