<commit_before>(function () {

    var jsonValidator
      , __
      , ruleValidator = {};

    if (typeof(module) !== 'undefined' && module.exports) {
        jsonValidator = require('amanda')('json');
        __ = require('underscore');
        module.exports = ruleValidator;
    } else if (typeof(define) !== 'undefined') {
        define(['amanda', 'underscore'], function (amanda, underscore) {
            jsonValidator = amanda('json');
            __ = underscore;
            return ruleValidator;
        });
    } else {
        jsonValidator = amanda('json');
        __ = _;
        this.ruleValidator = ruleValidator;
    }

    var ValidationRules = {};
    ValidationRules.prototype = {

        schema: function() {
            var attributes = {};
            __.each(arguments, function(arg) {
                for(var member in arg) {
                    if (arg.hasOwnProperty(member)) {
                        attributes[member] = arg[member];
                        break;
                    }
                }
            });

            return attributes;
        },

        validate: function(ruleName, data, callback) {
            jsonValidator.validate(data, this[ruleName], { singleError: false }, callback);
        }
        
    };

    ruleValidator.extend = function(rules, extension) {
        var extObj = __.extend(__.clone(ValidationRules.prototype), extension);

        if (extObj.attributes) {
            for (var m in extObj.attributes) {
                var attr = {};
                attr[m] = extObj.attributes[m];
                attr.isRequired = function() {
                    for(var member in this) {
                        if (this.hasOwnProperty(member)) {
                            this[member].required = true;
                            return this;
                        }
                    }
                };
                attr.isNotRequired = function() {
                    for(var member in this) {
                        if (this.hasOwnProperty(member)) {
                            this[member].required = false;
                            return this;
                        }
                    }
                };
                extObj.attributes[m] = attr;
            }
        }

        for (var r in rules) {
            var rule = rules[r];
            if (__.isFunction(rule)) {
                rule = rule.call(extObj);
            }

            extObj[r] = {
                type: 'object',
                properties: rule
            };

            extObj[r].ruleName = r;
            extObj[r].validate = function(data, callback) {
                extObj.validate(this.ruleName, data, callback);
            };
        }

        return extObj;

    };

}());<commit_msg>published new version 0.1.0 pass attributes to rule<commit_after>(function () {

    var jsonValidator
      , __
      , ruleValidator = {};

    if (typeof(module) !== 'undefined' && module.exports) {
        jsonValidator = require('amanda')('json');
        __ = require('underscore');
        module.exports = ruleValidator;
    } else if (typeof(define) !== 'undefined') {
        define(['amanda', 'underscore'], function (amanda, underscore) {
            jsonValidator = amanda('json');
            __ = underscore;
            return ruleValidator;
        });
    } else {
        jsonValidator = amanda('json');
        __ = _;
        this.ruleValidator = ruleValidator;
    }

    var ValidationRules = {};
    ValidationRules.prototype = {

        schema: function() {
            var attributes = {};
            __.each(arguments, function(arg) {
                for(var member in arg) {
                    if (arg.hasOwnProperty(member)) {
                        attributes[member] = arg[member];
                        break;
                    }
                }
            });

            return attributes;
        },

        validate: function(ruleName, data, callback) {
            jsonValidator.validate(data, this[ruleName], { singleError: false }, callback);
        }
        
    };

    ruleValidator.extend = function(rules, extension) {
        var extObj = __.extend(__.clone(ValidationRules.prototype), extension);

        if (extObj.attributes) {
            for (var m in extObj.attributes) {
                var attr = {};
                attr[m] = extObj.attributes[m];
                attr.isRequired = function() {
                    for(var member in this) {
                        if (this.hasOwnProperty(member)) {
                            this[member].required = true;
                            return this;
                        }
                    }
                };
                attr.isNotRequired = function() {
                    for(var member in this) {
                        if (this.hasOwnProperty(member)) {
                            this[member].required = false;
                            return this;
                        }
                    }
                };
                extObj.attributes[m] = attr;
            }
        }

        for (var r in rules) {
            var rule = rules[r];
            if (__.isFunction(rule)) {
                rule = rule.call(extObj, extObj.attributes);
            }

            extObj[r] = {
                type: 'object',
                properties: rule
            };

            extObj[r].ruleName = r;
            extObj[r].validate = function(data, callback) {
                extObj.validate(this.ruleName, data, callback);
            };
        }

        return extObj;

    };

}());
{'fraction_non_alphanumeric': 0.11176365901405944, 'fraction_numerical': 0.0005339028296849973, 'mean_word_length': 1.203921568627451, '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': '5132804', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1326, 'n_words': 272}