Comparing version 17.10.2 to 17.11.0
@@ -40,4 +40,17 @@ 'use strict'; | ||
this._template = null; | ||
this._settings = Clone(options); | ||
if (options) { | ||
const { functions, ...opts } = options; | ||
this._settings = Object.keys(opts).length ? Clone(opts) : undefined; | ||
this._functions = functions; | ||
if (this._functions) { | ||
Assert(Object.keys(this._functions).every((key) => typeof key === 'string'), 'Functions keys must be strings'); | ||
Assert(Object.values(this._functions).every((key) => typeof key === 'function'), 'Functions values must be functions'); | ||
} | ||
} | ||
else { | ||
this._settings = undefined; | ||
this._functions = undefined; | ||
} | ||
this._parse(); | ||
@@ -126,2 +139,6 @@ } | ||
if (this._functions) { | ||
desc.functions = this._functions; | ||
} | ||
return desc; | ||
@@ -132,3 +149,3 @@ } | ||
return new internals.Template(desc.template, desc.options); | ||
return new internals.Template(desc.template, desc.options || desc.functions ? { ...desc.options, functions: desc.functions } : undefined); | ||
} | ||
@@ -221,3 +238,4 @@ | ||
try { | ||
var formula = new Formula.Parser(content, { reference, functions: internals.functions, constants: internals.constants }); | ||
const functions = this._functions ? { ...internals.functions, ...this._functions } : internals.functions; | ||
var formula = new Formula.Parser(content, { reference, functions, constants: internals.constants }); | ||
} | ||
@@ -224,0 +242,0 @@ catch (err) { |
{ | ||
"name": "joi", | ||
"description": "Object schema validation", | ||
"version": "17.10.2", | ||
"version": "17.11.0", | ||
"repository": "git://github.com/hapijs/joi", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
533785
9851