<commit_before>/**
 * @class schematic-js/LuhnValidationPlugin
 * Plugin to validate a number using the Luhn algorithm.
 */
define([
    "../util"
], function (
    util
    ) {
    var module = function (config) {
        util.mixin(this, config);

        this.validate = function (property, instance, newValue, schema) {
            var ret = [], value = newValue || instance[property],
                sum = 0,
                numdigits = value.length,
                parity = numdigits % 2,
                i,
                digit;

            if (value && isNumeric(value)) {
                for(i = 0; i < numdigits; i += 1) {
                    digit = parseInt(value.charAt(i));
                    if(i % 2 == parity) digit *= 2;
                    if(digit > 9) {
                        digit -= 9;
                    }
                    sum += digit;
                }
                if ((sum % 10) !== 0) {
                    ret.push(this.message);
                }
            } else {
                ret.push("Property " + property + " is invalid");
            }
            return ret.length ? ret : undefined;
        }

        function isNumeric (n) {
            return !isNaN(parseFloat(n)) && isFinite(n);
        };
    };
    return module;
});
<commit_msg>Defined "this.message" at top of validator.  Fixed some lint errors.<commit_after>/**
 * @class schematic-js/LuhnValidationPlugin
 * Plugin to validate a number using the Luhn algorithm.
 */
define([
    "../util"
], function (
    util
    ) {
    var module = function (config) {
        this.message = {code: 0, message: "Invalid number"};
        util.mixin(this, config);

        function isNumeric(n) {
            return !isNaN(parseFloat(n)) && isFinite(n);
        }

        this.validate = function (property, instance, newValue, schema) {
            var ret = [], value = newValue || instance[property],
                sum = 0,
                numdigits = value.length,
                parity = numdigits % 2,
                i,
                digit;

            if (value && isNumeric(value)) {
                for (i = 0; i < numdigits; i += 1) {
                    digit = parseInt(value.charAt(i), 10);
                    if (i % 2 === parity) {
                        digit *= 2;
                    }
                    if (digit > 9) {
                        digit -= 9;
                    }
                    sum += digit;
                }
                if ((sum % 10) !== 0) {
                    ret.push(this.message);
                }
            } else {
                ret.push(this.message);
            }
            return ret.length ? ret : undefined;
        };
    };
    return module;
});

{'fraction_non_alphanumeric': 0.12203142126415784, 'fraction_numerical': 0.009134088417975887, 'mean_word_length': 1.1407349491790462, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '355864', 'n_tokens_mistral': 788, 'n_tokens_neox': 716, 'n_words': 187}