
var enforce = require('enforce');

function validEmail(email){
	//use node-enfore library
	var checks = new enforce.Enforce();
	checks.add("testEmail", enforce.patterns.email({      
	      'error': {
	        'type': 'Registration',
	        'description': 'Could not register user',
	        'data': {
	          'code': 1103,
	          'message': 'Invalid Email'
	        }
	      }
	    }));
	checks.check({
		testEmail : email
	}, function (err) {
		if(err){
			console.log(JSON.stringify(err.msg));
		}
		else{
			console.log("good email");
		}
	});
}

function validPassword(password){
	var checks = new enforce.Enforce();
	checks.add("testPass", enforce.ranges.length(8, 16, {
	      'error': {
	        'type': 'Registration',
	        'description': 'Could not register user',
	        'data': {
	          'code': 1104,
	          'message': 'Password is not 8-16 chars'
	        }
	      }
	    }));
	checks.check({
		testPass : password
	}, function (err) {
		if(err){
			console.log(JSON.stringify(err.msg));
		}
		else{
			console.log("good password");
		}
	});
}

//function validToken(token){
//	checks.add("testToken", enforce.ranges.length(36, 36, "bad token"))
//	checks.check({
//		testToken : token
//	}, function (err) {
//		console.log(err);
//	});
//}

exports.validPassword = validPassword;
exports.validEmail = validEmail;
//exports.validToken = validToken;

@@ -173,226 +173,19 @@
 ail(
-%7B      %0A%09      'error': %7B%0A%09        'type': 'Registration',%0A%09        'description': 'Could not register user',%0A%09        'data': %7B%0A%09          'code': 1103,%0A%09          'message': 'Invalid Email'%0A%09        %7D%0A%09      %7D%0A%09    %7D
+%22bad email%22
 ));%0A
@@ -285,32 +285,48 @@
 gify(err.msg));%0A
+%09%09%09return true;%0A
 %09%09%7D%0A%09%09else%7B%0A%09%09%09c
@@ -347,24 +347,41 @@
 od email%22);%0A
+%09%09%09return false;%0A
 %09%09%7D%0A%09%7D);%0A%7D%0A%0A
@@ -508,233 +508,22 @@
 16, 
-%7B%0A%09      'error': %7B%0A%09        'type': 'Registration',%0A%09        'description': 'Could not register user',%0A%09        'data': %7B%0A%09          'code': 1104,%0A%09          'message': 'Password is not 8-16 chars'%0A%09        %7D%0A%09      %7D%0A%09    %7D
+%22bad password%22
 ));%0A
@@ -633,16 +633,32 @@
 .msg));%0A
+%09%09%09return true;%0A
 %09%09%7D%0A%09%09el
@@ -694,16 +694,33 @@
 word%22);%0A
+%09%09%09return false;%0A
 %09%09%7D%0A%09%7D);

Update controllerUtils.js