Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
danielb2 committed Aug 22, 2014
1 parent 9eb9bff commit f03296c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions lib/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ internals.Array.prototype._base = function (value, state, options) {

if (this._inner.inclusions.length &&
!isValid) {

result.errors = Errors.create('array.includes', { pos: v }, { key: state.key, path: localState.path }, options);
return result;
}
Expand Down
34 changes: 17 additions & 17 deletions lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,6 @@ internals.Err.prototype.toString = function () {
};


internals.Err.prototype.getPath = function () {

var recursePath = function (item) {

var reachedItem = Hoek.reach(item, 'context.reason.0');
if (reachedItem && reachedItem.context) {
return recursePath(reachedItem);
}

return item.path;
};

return recursePath(this) || this.context.key;
};


exports.create = function (type, context, state, options) {

return new internals.Err(type, context, state, options);
Expand All @@ -73,7 +57,7 @@ exports.process = function (errors, object) {
var item = errors[i];
details.push({
message: item.toString(),
path: item.getPath(),
path: internals.getPath(item),
type: item.type
});
}
Expand All @@ -95,6 +79,22 @@ exports.process = function (errors, object) {
};


internals.getPath = function (item) {

var recursePath = function (it) {

var reachedItem = Hoek.reach(it, 'context.reason.0');
if (reachedItem && reachedItem.context) {
return recursePath(reachedItem);
}

return it.path;
};

return recursePath(item) || item.context.key;
};


internals.annotate = function () {

var obj = Hoek.clone(this._object || {});
Expand Down

0 comments on commit f03296c

Please sign in to comment.