
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;


var enforce = require('enforce');

function validEmail(email){
	//use node-enfore library
	var checks = new enforce.Enforce();
	checks.add("testEmail", enforce.patterns.email("bad email"));
	checks.check({
		testEmail : email
	}, function (err) {
		if(err){
			console.log(JSON.stringify(err.msg));
			return true;
		}
		else{
			console.log("good email");
			return false;
		}
	});
}

function validPassword(password){
	var checks = new enforce.Enforce();
	checks.add("testPass", enforce.ranges.length(8, 16, "bad password"));
	checks.check({
		testPass : password
	}, function (err) {
		if(err){
			console.log(JSON.stringify(err.msg));
			return true;
		}
		else{
			console.log("good password");
			return false;
		}
	});
}

//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;

Update controllerUtils.js