<commit_before>'use strict';
var BL = {
	model: null,
	"test": function (config, req, res) {
		
		var msg ="";
		/** woring version **/
		var data = "xx";
		var schema = {"type": "number"};
		var x =  new req.soajs.validator.Validator();
		var status = x.validate(data, schema);
		if (!status.valid) {
			status.errors.forEach(function (err) {
				msg = msg + err.stack + ". ";
			});
			console.log(JSON.stringify(msg, null, 2));// 2del
		}
		console.log(JSON.stringify(status, null, 2));// 2del
		
		console.log(JSON.stringify("*************************", null, 2));// 2del
		console.log(JSON.stringify("*************************", null, 2));// 2del
		console.log(JSON.stringify("*************************", null, 2));// 2del
		
		var data = {
			"deleted": "xxx"
		};
		var schema = {
			"imfv": {
				"custom": {
					"deleted": {
						"required": false,
						"validation": {
							"type": "boolean"
						}
					}
				}
			}
		};
		
		
		var miniSchema =	{
			"required": false,
			"validation": {
				"type": "boolean"
			}
			};
		var x =  new req.soajs.validator.Validator();
		
	
		
		
		var status = x.validate(data, schema);
		if (!status.valid) {
			status.errors.forEach(function (err) {
				msg = msg + err.stack + ". ";
			});
			console.log(JSON.stringify(msg, null, 2));// 2del
		}
		console.log(JSON.stringify(status, null, 2));// 2del
		
		
		
		console.log(JSON.stringify("*************************", null, 2));// 2del
		console.log(JSON.stringify("*************************", null, 2));// 2del
		console.log(JSON.stringify("*************************", null, 2));// 2del
		
		
		var data = req.soajs.inputmaskData.data;
		console.log(JSON.stringify("--------", null, 2));// 2del
		console.log(JSON.stringify(data.input, null, 2) , "<br>", JSON.stringify(data.imfv) );// 2del
		console.log(JSON.stringify("--------", null, 2));// 2del
		var myValidator = new req.soajs.validator.Validator();
		var status = myValidator.validate(data.input, data.imfv);
		if (!status.valid) {
			status.errors.forEach(function (err) {
				msg = msg + err.stack + ". ";
			});
			console.log(JSON.stringify(msg, null, 2));// 2del
			return res.jsonp(req.soajs.buildResponse({code: 0, error: msg}, null));
		}
		console.log(JSON.stringify(status, null, 2));// 2del
		return res.jsonp(req.soajs.buildResponse(null, {"test" :true}));
	}
};
/**
 * no need for a model or db connection for this api to work
 * @type {{init: module.exports.init}}
 */
module.exports = {
	"init": function (modelName , cb) {
		return cb(null, BL);
	}
};<commit_msg>looping over imfbv elements for validation<commit_after>'use strict';
var BL = {
	model: null,
	"test": function (config, req, res) {
		
		
		/**
		 var msg = "";
		 var data = {
			"deleted": true,
			"test": 123
		};
		 
		 var miniSchema = {
			"required": false,
			"type": "number"
		};
		 var x = new req.soajs.validator.Validator();
		 
		 
		 x.addSchema(miniSchema, "test");
		 var status = x.validate(data, miniSchema);
		 if (!status.valid) {
			x
			status.errors.forEach(function (err) {
				msg = msg + err.stack + ". ";
			});
			console.log(JSON.stringify(msg, null, 2));// 2del
		}
		 console.log(JSON.stringify(status, null, 2));// 2del
		 
		 */
		console.log(JSON.stringify("*************************", null, 2));// 2del
		console.log(JSON.stringify("*************************", null, 2));// 2del
		console.log(JSON.stringify("*************************", null, 2));// 2del
		
		
		var data = req.soajs.inputmaskData.data;
		console.log(JSON.stringify("--------", null, 2));// 2del
		console.log(JSON.stringify(data.input, null, 2), "\n\r", JSON.stringify(data.imfv));// 2del
		console.log(JSON.stringify("--------", null, 2));// 2del
		
		console.log(JSON.stringify("Elements", null, 2));// 2del
		
		var myValidator = new req.soajs.validator.Validator();
		var imfv = data.imfv;
		console.log(JSON.stringify(imfv, null, 2));// 2del
		Object.keys(imfv).forEach(function (key) {
			var val = imfv[key];
			
			console.log(JSON.stringify("Now validating ", null, 2), key, " with ");// 2del
			console.log(JSON.stringify(val, null, 2));// 2del
			
			if (data.input[key]) {
				console.log(key, "exists and equal to ", data.input[key]);// 2del
				var status = myValidator.validate(data.input[key], val.validation);
				if (!status.valid) {
					status.errors.forEach(function (err) {
						msg = msg + err.stack + ". ";
					});
					console.log(JSON.stringify(msg, null, 2));// 2del
				}
			}
			
			
		});
		
		
		// return res.jsonp(req.soajs.buildResponse({code: 0, error: msg}, null));
		/*
		 console.log(JSON.stringify("-------- now validate ----------", null, 2));// 2del
		 
		 var status = myValidator.validate(data.input, data.imfv);
		 if (!status.valid) {
		 status.errors.forEach(function (err) {
		 msg = msg + err.stack + ". ";
		 });
		 console.log(JSON.stringify(msg, null, 2));// 2del
		 return res.jsonp(req.soajs.buildResponse({code: 0, error: msg}, null));
		 }
		 console.log(JSON.stringify(status, null, 2));// 2del
		 
		 */
		
		
		return res.jsonp(req.soajs.buildResponse(null, {"test": true}));
	}
};
/**
 * no need for a model or db connection for this api to work
 * @type {{init: module.exports.init}}
 */
module.exports = {
	"init": function (modelName, cb) {
		return cb(null, BL);
	}
};
{'fraction_non_alphanumeric': 0.2354722695438198, 'fraction_numerical': 0.01306076093128904, 'mean_word_length': 3.012148823082764, 'pattern_counts': {'":': 20, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7343689', 'n_tokens_mistral': 2173, 'n_tokens_neox': 1763, 'n_words': 392}