News for hackers. Stuff that matters.
Re:Javascript - Beautiful Validation, No Extras. by rollypolly on Friday May 04, 2012 @07:26AM (#3927922)
Lines of code aren't at a premium. Why not favor readability over cleverness when possible?

I pity the person who'll be maintain this.

Re:Javascript - Beautiful Validation, No Extras. by Flow on Friday May 04, 2012 @10:57AM (#3928660)
Why not simply do a straight exit-early if+return?

  if(!username || username.trim() = '')
     return { error: "No Username Given.", field: 'name' };

  if(!password || password.trim() = '')
     return { error: "No Password Given.", field: 'password' };
and so on.

Is that not clever enough??? Even a monkey would understand this.

Re:Javascript - Beautiful Validation, No Extras. by hackermom on Friday May 04, 2012 @08:55AM (#3928143)
Why? The snippet of code is simple and functional enough to escape the need of being fiddled with ad infinitum ad absurdum. I can't see a cloud of maintenance need hovering over it.