Powerful objects and string validation in javascript