diff --git a/lib/types/any/index.js b/lib/types/any/index.js index 2afe9f20a..de6293c5d 100755 --- a/lib/types/any/index.js +++ b/lib/types/any/index.js @@ -1,20 +1,24 @@ 'use strict'; const Hoek = require('@hapi/hoek'); +const Marker = require('@hapi/marker'); +const Cast = require('../../cast'); const Settings = require('./settings'); const Ref = require('../../ref'); const Errors = require('../../errors'); const State = require('../state'); const Symbols = require('../symbols'); +const Pkg = require('../../../package.json'); + let Alternatives = null; // Delay-loaded to prevent circular dependencies -let Cast = null; let Schemas = null; const internals = { - Set: require('../../set') + Set: require('../../set'), + symbol: Marker('joi-any-base') }; @@ -37,8 +41,6 @@ module.exports = internals.Any = class { constructor() { - Cast = Cast || require('../../cast'); - this.isJoi = true; this._type = 'any'; this._settings = null; @@ -957,6 +959,13 @@ internals.Any.prototype.disallow = internals.Any.prototype.not = internals.Any.p internals.Any.prototype.exist = internals.Any.prototype.required; +internals.Any.prototype[internals.symbol] = { + version: Pkg.version, + compile: Cast.schema, + root: '_currentJoi' +}; + + internals._try = function (fn, args = []) { let err; diff --git a/package.json b/package.json index 5ac4bfa7f..fa5e8bdb8 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,9 @@ "validation" ], "dependencies": { - "@hapi/hoek": "6.x.x", "@hapi/address": "2.x.x", + "@hapi/hoek": "6.x.x", + "@hapi/marker": "1.x.x", "@hapi/topo": "3.x.x" }, "devDependencies": {