src/validator.js
function (obj, path) {
    if (Object.prototype.hasOwnProperty.call(obj, path)) {
      return obj[path];
    }

    var keys = path.replace(/\[(\w+)\]/g, ".$1").replace(/^\./, "").split(".");
    var copy = {};
    for (var attr in obj) {
      if (Object.prototype.hasOwnProperty.call(obj, attr)) {
        copy[attr] = obj[attr];
      }
    }

    for (var i = 0, l = keys.length; i < l; i++) {
      if (Object.hasOwnProperty.call(copy, keys[i])) {
        copy = copy[keys[i]];
      } else {
        return;
      }
    }
    return copy;
  }
function (obj, path) {
    if (Object.prototype.hasOwnProperty.call(obj, path)) {
      return obj[path];
    }

    var keys = path.replace(/\[(\w+)\]/g, ".$1").replace(/^\./, "").split(".");
    var copy = {};
    for (var attr in obj) {
      if (Object.prototype.hasOwnProperty.call(obj, attr)) {
        copy[attr] = obj[attr];
      }
    }

    for (var i = 0, l = keys.length; i < l; i++) {
      if (Object.hasOwnProperty.call(copy, keys[i])) {
        copy = copy[keys[i]];
      } else {
        return;
      }
    }
    return copy;
  }
function ( obj , path ) { if ( Object . prototype . hasOwnProperty . call ( obj , path ) ) { return obj [ path ] ; } var keys = path . replace ( / \[(\w+)\] / g , ".$1" ) . replace ( / ^\. / , "" ) . split ( "." ) ; var copy = { } ; for ( var attr in obj ) { if ( Object . prototype . hasOwnProperty . call ( obj , attr ) ) { copy [ attr ] = obj [ attr ] ; } } for ( var i = 0 , l = keys . length ; i < l ; i ++ ) { if ( Object . hasOwnProperty . call ( copy , keys [ i ] ) ) { copy = copy [ keys [ i ] ] ; } else { return ; } } return copy ; }
Extract value from nested object using string path with dot notation

@param  {object} object to search in
@param  {string} path inside object
@return {any|void} value under the path
Extract value from nested object using string path with dot notation