<commit_before>"use strict";

var Validator = require('validator').Validator;

Validator.prototype.clearErrors = function(msg) {

	if (this._objectKey)
		this._objectErrors = {};

	this.errors = [];
};

Validator.prototype.error = function(msg) {

	if (this._objectKey) {
		this._objectErrors[this._objectKey] = msg;
	} else {
		this._errors.push(msg);
	}
};

Validator.prototype.getErrors = function () {
	return this._errors;
}

Validator.prototype.getObjectErrors = function () {

	if (Object.keys(this._objectErrors).length == 0)
		return null;

	return this._objectErrors;
}

Validator.prototype.checkObject = function(obj, key, msg) {
	this._objectKey = key;

	if (!this._objectErrors)
		this._objectErrors = {};

	return this.check(obj[key], msg);
};

module.exports = Validator;<commit_msg>check object when validate it<commit_after>"use strict";

var Validator = require('validator').Validator;

Validator.prototype.clearErrors = function(msg) {

	if (this._objectKey)
		this._objectErrors = {};

	this.errors = [];
};

Validator.prototype.error = function(msg) {

	if (this._objectKey) {
		this._objectErrors[this._objectKey] = msg;
	} else {
		this._errors.push(msg);
	}
};

Validator.prototype.getErrors = function () {
	return this._errors;
}

Validator.prototype.getObjectErrors = function () {

	if (Object.keys(this._objectErrors).length == 0)
		return null;

	return this._objectErrors;
}

Validator.prototype.checkObject = function(obj, key, msg) {
	this._objectKey = key;

	if (!this._objectErrors)
		this._objectErrors = {};


	if (obj instanceof Object)
		return this.check(obj[key], msg);

	return this.check(null, msg);
};

module.exports = Validator;
{'fraction_non_alphanumeric': 0.14755077658303464, 'fraction_numerical': 0.0011947431302270011, 'mean_word_length': 4.583333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5475908', 'n_tokens_mistral': 563, 'n_tokens_neox': 534, 'n_words': 102}