Javascript object validation based on https://github.com/chriso/node-validator