Skip to content

Commit

Permalink
Move link.describe() to manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Jul 12, 2019
1 parent fb01468 commit 031dbf6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ exports.describe = function (schema) {
normalized = mapped;
}

description[inner] = normalized;
description[inner] = inner === 'link' ? normalized[0] : normalized;
}

return description;
Expand Down
17 changes: 4 additions & 13 deletions lib/types/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ internals.Link = class extends Any {
Hoek.assert(ref.ancestor > 0, 'Link cannot reference itself');

const obj = this.clone();
obj._inners._link = [{ ref }];
obj._inners.link = [{ ref }];
return obj;
}

_base(value, state, prefs) {

const ref = this._inners._link[0].ref;
const ref = this._inners.link[0].ref;
const perspective = state.schemas[ref.ancestor];
if (!perspective) {
return { value, errors: this.createError('link.depth', value, { ref }, state, prefs) };
Expand All @@ -51,15 +51,6 @@ internals.Link = class extends Any {
return schema._validate(value, state, prefs);
}

// About

describe() {

const description = super.describe();
description.link = { ref: this._inners._link[0].ref.describe() };
return description;
}

// Helpers

concat(source) {
Expand All @@ -72,12 +63,12 @@ internals.Link = class extends Any {

when(...args) {

const ref = this._inners._link[0].ref.clone();
const ref = this._inners.link[0].ref.clone();
++ref.ancestor;
ref.updateDisplay();

const obj = this.clone();
obj._inners._link = [{ ref }];
obj._inners.link = [{ ref }];
return super.when.call(obj, ...args);
}
};
Expand Down

0 comments on commit 031dbf6

Please sign in to comment.