useful validation methods for node.js and the browser