JavaScript object validator