<commit_before>var addError = require("./add-error")
var min = require("./min")
var max = require("./max")
var length = require("./length")

var LENGTH_MESSAGE = "Expected %s to contain exactly %d items"
var MIN_MESSAGE = "Expected %s to contain at least %d items"
var MAX_MESSAGE = "Expected %s to contain at most %d items"

module.exports = list

function list(options, message) {

    var minValidator, maxValidator, lengthValidator
    var contentValidator = options.content

    if (typeof options.min === "number") {
        minValidator = min(options.min, message || MIN_MESSAGE)
    }
    if (typeof options.max === "number") {
        maxValidator = max(options.max, message || MAX_MESSAGE)
    }
    if (typeof options.length === "number") {
        lengthValidator = length(options.length, message || LENGTH_MESSAGE)
    }

    if (contentValidator && !Array.isArray(contentValidator)) {
        contentValidator = [contentValidator]
    }

    return function validate(value, key, values) {
        var errors = []
        if (minValidator) {
            addError(errors, key, minValidator(value, key, values))
        }
        if (maxValidator) {
            addError(errors, key, maxValidator(value, key, values))
        }
        if (lengthValidator) {
            addError(errors, key, lengthValidator(value, key, values))
        }

        if (contentValidator) {
            value.forEach(function (childValue, index) {
                var childKey = key + "[" + index + "]"

                contentValidator.forEach(function runValidator(validator) {
                    addError(errors, childKey,
                        validator(childValue, childKey, value))
                })
            })
        }

        return errors.length ? errors : null
    }
}
<commit_msg>make key optional<commit_after>var addError = require("./add-error")
var min = require("./min")
var max = require("./max")
var length = require("./length")

var LENGTH_MESSAGE = "Expected %s to contain exactly %d items"
var MIN_MESSAGE = "Expected %s to contain at least %d items"
var MAX_MESSAGE = "Expected %s to contain at most %d items"

module.exports = list

function list(options, message) {
    var minValidator, maxValidator, lengthValidator
    var contentValidator = options.content

    if (typeof options.min === "number") {
        minValidator = min(options.min, message || MIN_MESSAGE)
    }
    if (typeof options.max === "number") {
        maxValidator = max(options.max, message || MAX_MESSAGE)
    }
    if (typeof options.length === "number") {
        lengthValidator = length(options.length, message || LENGTH_MESSAGE)
    }

    if (contentValidator && !Array.isArray(contentValidator)) {
        contentValidator = [contentValidator]
    }

    return function validate(value, key, values) {
        var errors = []
        if (minValidator) {
            addError(errors, key, minValidator(value, key, values))
        }
        if (maxValidator) {
            addError(errors, key, maxValidator(value, key, values))
        }
        if (lengthValidator) {
            addError(errors, key, lengthValidator(value, key, values))
        }

        if (contentValidator) {
            value.forEach(function (childValue, index) {
                var childKey = "[" + index + "]"
                if (key) {
                    childKey = key + childKey
                }

                contentValidator.forEach(function runValidator(validator) {
                    addError(errors, childKey,
                        validator(childValue, childKey, value))
                })
            })
        }

        return errors.length ? errors : null
    }
}

{'fraction_non_alphanumeric': 0.11398258977149076, 'fraction_numerical': 0.0, 'mean_word_length': 2.2977578475336324, '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': '5148147', 'n_tokens_mistral': 994, 'n_tokens_neox': 969, 'n_words': 266}