<commit_before>var reduce = require('lodash.reduce');


function validate (source, schema, fieldPrefix) {
    var _fieldPrefix = fieldPrefix ? (fieldPrefix + '.') : '';


    if (typeof schema === 'function') {
        return processScalar(source, schema);
    }

    if (Array.isArray(source)) {
        return processNested(source, schema);
    }

    return processTop(source, schema, _fieldPrefix)
}

function processScalar (source, schema) {
    return reduce(source, function (errors, item, index) {

        var result = schema(item, source);
<commit_msg>fieldPrefix should check for undefined instead of falsy:<commit_after>var reduce = require('lodash.reduce');


function validate (source, schema, fieldPrefix) {
    var _fieldPrefix = fieldPrefix === undefined ? (fieldPrefix + '.') : '';


    if (typeof schema === 'function') {
        return processScalar(source, schema);
    }

    if (Array.isArray(source)) {
        return processNested(source, schema);
    }

    return processTop(source, schema, _fieldPrefix)
}

function processScalar (source, schema) {
    return reduce(source, function (errors, item, index) {

        var result = schema(item, source);

{'fraction_non_alphanumeric': 0.12531752751905165, 'fraction_numerical': 0.0, 'mean_word_length': 3.6535433070866143, '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': '4069717', 'n_tokens_mistral': 333, 'n_tokens_neox': 322, 'n_words': 92}