Added validation to couchdb main.js file

Added the same validation logic to the main.js file for the couchDB
copy of the app.