<commit_before>"use strict";

var _ = require('lodash');
var Rule = require('./base/rule');

module.exports = Rule.extend({
	check: function (value, params, done) {
		return params.test(value);
	},

	prepareParams: function (params) {
		if (_.isString(params) || (_.isNumber(params) && !_.isNaN(params))) {
			params = new RegExp(params);
		}

		if (_.isRegExp(params)) {
			return params;
		}

		throw new Error('#RFORMAT1: invalid value type, must be RegExp');
	}
});<commit_msg>add format params serialize method<commit_after>"use strict";

var _ = require('lodash');
var Rule = require('./base/rule');

module.exports = Rule.extend({
	check: function (value, params, done) {
		return params.test(value);
	},

	serialize: function () {
		return this.params.source;
	},

	prepareParams: function (params) {
		if (_.isString(params) || (_.isNumber(params) && !_.isNaN(params))) {
			params = new RegExp(params);
		}

		if (_.isRegExp(params)) {
			return params;
		}

		throw new Error('#RFORMAT1: invalid value type, must be RegExp');
	}
});
{'fraction_non_alphanumeric': 0.17353787152444872, 'fraction_numerical': 0.0019175455417066154, 'mean_word_length': 4.1940298507462686, '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': '2598572', 'n_tokens_mistral': 375, 'n_tokens_neox': 344, 'n_words': 86}