Simple javascript object validator