JavaScript data structure validator