<commit_before>var validateValue = require('./validateValue');

/**
 * @param {*}        value
 * @param {Object}   config
 * @param {String[]} path
 * @param {Object}   originalObject
 *
 * @returns {Promise}
 */
module.exports = function validateProperty(value, config, path, originalObject) {
    var promise;
    var validators = config.validators;

    if (config.properties instanceof Object) {
        validators = Object.assign({ type: 'object' }, validators);
    } else if (config.items instanceof Object) {
        validators = Object.assign({ type: 'array' }, validators);
    }

    if (validators instanceof Object) {
        promise = validateValue(value, validators, path, originalObject);
    } else {
        promise = Promise.resolve();
    }

    return promise.then(function() {
        var validateObject = require('./validateObject');

        if (config.properties instanceof Object) {
            return validateObject(value, config.properties, path, originalObject);
        } else if (value instanceof Array && config.items instanceof Object) {
            var arrayConfig = {};
            value.forEach(function(item, index) {
                arrayConfig[index] = config.items;<commit_msg>check value properties only if value is object<commit_after>var validateValue = require('./validateValue');

/**
 * @param {*}        value
 * @param {Object}   config
 * @param {String[]} path
 * @param {Object}   originalObject
 *
 * @returns {Promise}
 */
module.exports = function validateProperty(value, config, path, originalObject) {
    var promise;
    var validators = config.validators;

    if (config.properties instanceof Object) {
        validators = Object.assign({ type: 'object' }, validators);
    } else if (config.items instanceof Object) {
        validators = Object.assign({ type: 'array' }, validators);
    }

    if (validators instanceof Object) {
        promise = validateValue(value, validators, path, originalObject);
    } else {
        promise = Promise.resolve();
    }

    return promise.then(function() {
        var validateObject = require('./validateObject');

        if (config.properties instanceof Object && value instanceof Object) {
            return validateObject(value, config.properties, path, originalObject);
        } else if (config.items instanceof Object && value instanceof Array) {
            var arrayConfig = {};
            value.forEach(function(item, index) {
                arrayConfig[index] = config.items;
{'fraction_non_alphanumeric': 0.11939102564102565, 'fraction_numerical': 0.0, 'mean_word_length': 2.9761146496815285, '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': '7378399', 'n_tokens_mistral': 634, 'n_tokens_neox': 626, 'n_words': 181}