Skip to content

Commit 5d4c0c9

Browse files
committed
Legacy api. Closes #1926
1 parent 3108872 commit 5d4c0c9

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/types/any/index.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
'use strict';
22

33
const Hoek = require('@hapi/hoek');
4+
const Marker = require('@hapi/marker');
45

6+
const Cast = require('../../cast');
57
const Settings = require('./settings');
68
const Ref = require('../../ref');
79
const Errors = require('../../errors');
810
const State = require('../state');
911
const Symbols = require('../symbols');
1012

13+
const Pkg = require('../../../package.json');
14+
1115
let Alternatives = null; // Delay-loaded to prevent circular dependencies
12-
let Cast = null;
1316
let Schemas = null;
1417

1518

1619
const internals = {
17-
Set: require('../../set')
20+
Set: require('../../set'),
21+
symbol: Marker('joi-any-base')
1822
};
1923

2024

@@ -37,8 +41,6 @@ module.exports = internals.Any = class {
3741

3842
constructor() {
3943

40-
Cast = Cast || require('../../cast');
41-
4244
this.isJoi = true;
4345
this._type = 'any';
4446
this._settings = null;
@@ -957,6 +959,13 @@ internals.Any.prototype.disallow = internals.Any.prototype.not = internals.Any.p
957959
internals.Any.prototype.exist = internals.Any.prototype.required;
958960

959961

962+
internals.Any.prototype[internals.symbol] = {
963+
version: Pkg.version,
964+
compile: Cast.schema,
965+
root: '_currentJoi'
966+
};
967+
968+
960969
internals._try = function (fn, args = []) {
961970

962971
let err;

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
"validation"
1111
],
1212
"dependencies": {
13-
"@hapi/hoek": "6.x.x",
1413
"@hapi/address": "2.x.x",
14+
"@hapi/hoek": "6.x.x",
15+
"@hapi/marker": "1.x.x",
1516
"@hapi/topo": "3.x.x"
1617
},
1718
"devDependencies": {

0 commit comments

Comments
 (0)