From be3c863b8a513f3e714476512d67743d560ff74f Mon Sep 17 00:00:00 2001 From: Eran Hammer Date: Thu, 8 Aug 2019 07:21:01 +0000 Subject: [PATCH] object.assert() fixes. Closes #2026. Closes #2027 --- API.md | 12 +- README.md | 2 +- browser/stats.json | 3434 ++++++++++++++++++++---------------------- lib/types/object.js | 29 +- test/errors.js | 5 +- test/ref.js | 3 +- test/types/object.js | 51 +- 7 files changed, 1694 insertions(+), 1842 deletions(-) diff --git a/API.md b/API.md index ed74d1b45..43790ad21 100755 --- a/API.md +++ b/API.md @@ -118,7 +118,7 @@ - [`object` - inherits from `Any`](#object---inherits-from-any) - [`object.and(...peers, [options])`](#objectandpeers-options) - [`object.append([schema])`](#objectappendschema) - - [`object.assert(ref, schema, [message])`](#objectassertref-schema-message) + - [`object.assert(subject, schema, [message])`](#objectassertsubject-schema-message) - [`object.instance(constructor, [name])`](#objectinstanceconstructor-name) - [`object.keys([schema])`](#objectkeysschema) - [`object.length(limit)`](#objectlengthlimit) @@ -2293,12 +2293,12 @@ const extended = base.append({ }); ``` -#### `object.assert(ref, schema, [message])` +#### `object.assert(subject, schema, [message])` Verifies an assertion where: -- `ref` - the key name or [reference](#refkey-options). +- `subject` - the key name, [reference](#refkey-options), or template expression to validate. - `schema` - the validation rules required to satisfy the assertion. If the `schema` includes references, they are resolved against - the object value, not the value of the `ref` target. + the object value, not the value of the `subject` target. - `message` - optional human-readable message used when the assertion fails. Defaults to 'failed to pass the assertion test'. ```js @@ -3804,8 +3804,8 @@ The schema on an [`object.assert()`](#objectassertref-schema-message) failed to Additional local context properties: ```ts { - ref: string, // Dotted path to the property that was checked - message: string // Custom message or default one + subject: object, // The assertion subject. When it is a reference, use subject.key for the display path. + message: string // Custom message when provided } ``` diff --git a/README.md b/README.md index bdaeffbd7..cd042b224 100755 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ that stores information) to ensure *validation* of key information. ## API -See the detailed [API Reference](https://github.com/hapijs/joi/blob/v16.0.0-rc2/API.md). +See the detailed [API Reference](https://github.com/hapijs/joi/blob/v16.0.0/API.md). ## Example diff --git a/browser/stats.json b/browser/stats.json index ca107d8fa..ffa0f5366 100644 --- a/browser/stats.json +++ b/browser/stats.json @@ -2,9 +2,9 @@ "errors": [], "warnings": [], "version": "4.39.1", - "hash": "d101b5988853c97a731f", - "time": 2669, - "builtAt": 1565219301771, + "hash": "05304bbf842c28b3fd0a", + "time": 1680, + "builtAt": 1565220289566, "publicPath": "", "outputPath": "/home/eran/code/hapijs/joi/browser/dist", "assetsByChunkName": { @@ -13,7 +13,7 @@ "assets": [ { "name": "./joi-browser.min.js", - "size": 212296, + "size": 164358, "chunks": [ 0 ], @@ -54,14 +54,14 @@ "rendered": true, "initial": true, "entry": true, - "size": 455340, + "size": 323097, "names": [ "main" ], "files": [ "./joi-browser.min.js" ], - "hash": "47ca8c5e5a027f47ad0d", + "hash": "20a831a2602647d58a92", "siblings": [], "parents": [], "children": [], @@ -73,7 +73,7 @@ "name": "../node_modules/@hapi/hoek/lib/assert.js", "index": 1, "index2": 2, - "size": 418, + "size": 422, "cacheable": true, "built": true, "optional": false, @@ -90,15 +90,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -112,7 +112,7 @@ "moduleName": "../lib/common.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "19:13-45" + "loc": "3:15-47" }, { "moduleId": 3, @@ -121,7 +121,7 @@ "moduleName": "../lib/types/any.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "3:13-45" + "loc": "3:15-47" }, { "moduleId": 4, @@ -130,7 +130,7 @@ "moduleName": "../lib/template.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "27:13-45" + "loc": "3:15-47" }, { "moduleId": 5, @@ -139,7 +139,7 @@ "moduleName": "../lib/ref.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "27:13-45" + "loc": "3:15-47" }, { "moduleId": 6, @@ -148,7 +148,7 @@ "moduleName": "../lib/compile.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "5:13-45" + "loc": "3:15-47" }, { "moduleId": 9, @@ -157,7 +157,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/reach.js", "type": "cjs require", "userRequest": "./assert", - "loc": "13:13-32" + "loc": "3:15-34" }, { "moduleId": 10, @@ -166,7 +166,7 @@ "moduleName": "../lib/messages.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "5:13-45" + "loc": "3:15-47" }, { "moduleId": 14, @@ -175,7 +175,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "17:13-45" + "loc": "3:15-47" }, { "moduleId": 16, @@ -184,7 +184,7 @@ "moduleName": "../lib/cache.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "11:13-45" + "loc": "3:15-47" }, { "moduleId": 19, @@ -193,7 +193,7 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "21:13-45" + "loc": "3:15-47" }, { "moduleId": 20, @@ -202,7 +202,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/merge.js", "type": "cjs require", "userRequest": "./assert", - "loc": "5:13-32" + "loc": "3:15-34" }, { "moduleId": 23, @@ -211,160 +211,160 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "41:13-45" + "loc": "5:15-47" }, { - "moduleId": 25, + "moduleId": 24, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/uri.js", "module": "../lib/types/string/uri.js", "moduleName": "../lib/types/string/uri.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "3:13-45" + "loc": "3:15-47" }, { - "moduleId": 30, + "moduleId": 29, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "module": "../lib/types/alternatives.js", "moduleName": "../lib/types/alternatives.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "21:13-45" + "loc": "3:15-47" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "21:13-45" + "loc": "3:15-47" }, { - "moduleId": 32, + "moduleId": 31, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/extend.js", "module": "../lib/extend.js", "moduleName": "../lib/extend.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "13:13-45" + "loc": "3:15-47" }, { - "moduleId": 33, + "moduleId": 32, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/modify.js", "module": "../lib/modify.js", "moduleName": "../lib/modify.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "17:13-45" + "loc": "3:15-47" }, { - "moduleId": 34, + "moduleId": 33, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/validator.js", "module": "../lib/validator.js", "moduleName": "../lib/validator.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "23:13-45" + "loc": "3:15-47" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "13:13-45" + "loc": "3:15-47" }, { - "moduleId": 36, + "moduleId": 35, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", "module": "../lib/types/boolean.js", "moduleName": "../lib/types/boolean.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "11:13-45" + "loc": "3:15-47" }, { - "moduleId": 37, + "moduleId": 36, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/date.js", "module": "../lib/types/date.js", "moduleName": "../lib/types/date.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "3:13-45" + "loc": "3:15-47" }, { - "moduleId": 38, + "moduleId": 37, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/function.js", "module": "../lib/types/function.js", "moduleName": "../lib/types/function.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "3:13-45" + "loc": "3:15-47" }, { - "moduleId": 39, + "moduleId": 38, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/applyToDefaults.js", "module": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "moduleName": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "type": "cjs require", "userRequest": "./assert", - "loc": "5:13-32" + "loc": "3:15-34" }, { - "moduleId": 40, + "moduleId": 39, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/topo/lib/index.js", "module": "../node_modules/@hapi/topo/lib/index.js", "moduleName": "../node_modules/@hapi/topo/lib/index.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "9:13-45" + "loc": "3:15-47" }, { - "moduleId": 41, + "moduleId": 40, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/link.js", "module": "../lib/types/link.js", "moduleName": "../lib/types/link.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "3:13-45" + "loc": "3:15-47" }, { - "moduleId": 42, + "moduleId": 41, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/number.js", "module": "../lib/types/number.js", "moduleName": "../lib/types/number.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "3:13-45" + "loc": "3:15-47" }, { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "13:13-45" + "loc": "11:15-47" }, { - "moduleId": 50, + "moduleId": 49, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/contain.js", "module": "../node_modules/@hapi/hoek/lib/contain.js", "moduleName": "../node_modules/@hapi/hoek/lib/contain.js", "type": "cjs require", "userRequest": "./assert", - "loc": "13:13-32" + "loc": "3:15-34" }, { - "moduleId": 52, + "moduleId": 51, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/symbol.js", "module": "../lib/types/symbol.js", "moduleName": "../lib/types/symbol.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "37:13-45" + "loc": "3:15-47" } ], "usedExports": true, @@ -373,7 +373,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar AssertError = require('./error');\n\nvar internals = {};\n\nmodule.exports = function (condition) {\n if (condition) {\n return;\n }\n\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n if (args.length === 1 && args[0] instanceof Error) {\n throw args[0];\n }\n\n throw new AssertError(args);\n};" + "source": "'use strict';\n\nconst AssertError = require('./error');\n\nconst internals = {};\n\nmodule.exports = function (condition) {\n if (condition) {\n return;\n }\n\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n if (args.length === 1 && args[0] instanceof Error) {\n throw args[0];\n }\n\n throw new AssertError(args);\n};" }, { "id": 1, @@ -381,7 +381,7 @@ "name": "../lib/common.js", "index": 9, "index2": 15, - "size": 8158, + "size": 5615, "cacheable": true, "built": true, "optional": false, @@ -398,15 +398,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -420,7 +420,7 @@ "moduleName": "../lib/template.js", "type": "cjs require", "userRequest": "./common", - "loc": "35:13-32" + "loc": "11:15-34" }, { "moduleId": 5, @@ -429,7 +429,7 @@ "moduleName": "../lib/ref.js", "type": "cjs require", "userRequest": "./common", - "loc": "33:13-32" + "loc": "9:15-34" }, { "moduleId": 6, @@ -438,7 +438,7 @@ "moduleName": "../lib/compile.js", "type": "cjs require", "userRequest": "./common", - "loc": "7:13-32" + "loc": "5:15-34" }, { "moduleId": 7, @@ -447,7 +447,7 @@ "moduleName": "../lib/errors.js", "type": "cjs require", "userRequest": "./common", - "loc": "39:13-32" + "loc": "5:15-34" }, { "moduleId": 14, @@ -456,7 +456,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./common", - "loc": "21:13-32" + "loc": "7:15-34" }, { "moduleId": 16, @@ -465,7 +465,7 @@ "moduleName": "../lib/cache.js", "type": "cjs require", "userRequest": "./common", - "loc": "15:13-32" + "loc": "7:15-34" }, { "moduleId": 19, @@ -474,7 +474,7 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "./common", - "loc": "25:13-32" + "loc": "7:15-34" }, { "moduleId": 21, @@ -483,7 +483,7 @@ "moduleName": "../lib/values.js", "type": "cjs require", "userRequest": "./common", - "loc": "19:13-32" + "loc": "3:15-34" }, { "moduleId": 23, @@ -492,97 +492,97 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "../common", - "loc": "51:13-33" + "loc": "15:15-35" }, { - "moduleId": 30, + "moduleId": 29, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "module": "../lib/types/alternatives.js", "moduleName": "../lib/types/alternatives.js", "type": "cjs require", "userRequest": "../common", - "loc": "25:13-33" + "loc": "7:15-35" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./common", - "loc": "31:13-32" + "loc": "13:15-34" }, { - "moduleId": 33, + "moduleId": 32, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/modify.js", "module": "../lib/modify.js", "moduleName": "../lib/modify.js", "type": "cjs require", "userRequest": "./common", - "loc": "19:13-32" + "loc": "5:15-34" }, { - "moduleId": 34, + "moduleId": 33, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/validator.js", "module": "../lib/validator.js", "moduleName": "../lib/validator.js", "type": "cjs require", "userRequest": "./common", - "loc": "29:13-32" + "loc": "9:15-34" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "../common", - "loc": "23:13-33" + "loc": "13:15-35" }, { - "moduleId": 36, + "moduleId": 35, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", "module": "../lib/types/boolean.js", "moduleName": "../lib/types/boolean.js", "type": "cjs require", "userRequest": "../common", - "loc": "15:13-33" + "loc": "7:15-35" }, { - "moduleId": 37, + "moduleId": 36, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/date.js", "module": "../lib/types/date.js", "moduleName": "../lib/types/date.js", "type": "cjs require", "userRequest": "../common", - "loc": "7:13-33" + "loc": "7:15-35" }, { - "moduleId": 41, + "moduleId": 40, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/link.js", "module": "../lib/types/link.js", "moduleName": "../lib/types/link.js", "type": "cjs require", "userRequest": "../common", - "loc": "7:13-33" + "loc": "7:15-35" }, { - "moduleId": 42, + "moduleId": 41, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/number.js", "module": "../lib/types/number.js", "moduleName": "../lib/types/number.js", "type": "cjs require", "userRequest": "../common", - "loc": "7:13-33" + "loc": "7:15-35" }, { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "../../common", - "loc": "21:13-36" + "loc": "19:15-38" } ], "usedExports": true, @@ -591,7 +591,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar AssertError = require('@hapi/hoek/lib/error');\n\nvar Marker = require('@hapi/marker');\n\nvar Pkg = require('../package.json');\n\nvar Messages;\nvar Schemas;\nvar internals = {\n isoDate: /^(?:[-+]\\d{2})?(?:\\d{4}(?!\\d{2}\\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\\1(?:[12]\\d|0[1-9]|3[01]))?|W(?:[0-4]\\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\\d|[12]\\d{2}|3(?:[0-5]\\d|6[1-6])))(?![T]$|[T][\\d]+Z$)(?:[T\\s](?:(?:(?:[01]\\d|2[0-3])(?:(:?)[0-5]\\d)?|24\\:?00)(?:[.,]\\d+(?!:))?)(?:\\2[0-5]\\d(?:[.,]\\d+)?)?(?:[Z]|(?:[+-])(?:[01]\\d|2[0-3])(?::?[0-5]\\d)?)?)?)?$/\n};\nexports.version = Pkg.version;\nexports.defaults = {\n abortEarly: true,\n allowUnknown: false,\n cache: true,\n context: null,\n convert: true,\n dateFormat: 'iso',\n errors: {\n escapeHtml: false,\n language: null,\n stack: false,\n wrapArrays: true\n },\n externals: true,\n messages: {},\n nonEnumerables: false,\n noDefaults: false,\n presence: 'optional',\n skipFunctions: false,\n stripUnknown: false,\n warnings: false\n};\nexports.symbols = {\n any: Marker('joi-any-base'),\n // Used to internally identify any-based types (shared with other joi versions)\n arraySingle: Symbol('arraySingle'),\n deepDefault: Symbol('deepDefault'),\n literal: Symbol('literal'),\n prefs: Symbol('prefs'),\n ref: Symbol('ref'),\n values: Symbol('values'),\n template: Symbol('template')\n};\n\nexports.assertOptions = function (options, keys) {\n var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Options';\n Assert(options && _typeof(options) === 'object' && !Array.isArray(options), 'Options must be of type object');\n var unknownKeys = Object.keys(options).filter(function (k) {\n return !keys.includes(k);\n });\n Assert(unknownKeys.length === 0, \"\".concat(name, \" contain unknown keys: \").concat(unknownKeys));\n};\n\nexports.checkPreferences = function (prefs) {\n Schemas = Schemas || require('./schemas');\n var result = Schemas.preferences.validate(prefs);\n\n if (result.error) {\n throw new AssertError([result.error.details[0].message]);\n }\n};\n\nexports.compare = function (a, b, operator) {\n switch (operator) {\n case '=':\n return a === b;\n\n case '>':\n return a > b;\n\n case '<':\n return a < b;\n\n case '>=':\n return a >= b;\n\n case '<=':\n return a <= b;\n }\n};\n\nexports.default = function (value, defaultValue) {\n return value === undefined ? defaultValue : value;\n};\n\nexports.isIsoDate = function (date) {\n return internals.isoDate.test(date);\n};\n\nexports.isNumber = function (value) {\n return typeof value === 'number' && !isNaN(value);\n};\n\nexports.isResolvable = function (obj) {\n if (!obj) {\n return false;\n }\n\n return obj[exports.symbols.ref] || obj[exports.symbols.template];\n};\n\nexports.isSchema = function (schema) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var any = schema && schema[exports.symbols.any];\n\n if (!any) {\n return false;\n }\n\n Assert(options.legacy || any.version === exports.version, 'Cannot mix different versions of joi schemas');\n return true;\n};\n\nexports.isValues = function (obj) {\n return obj[exports.symbols.values];\n};\n\nexports.limit = function (value) {\n return Number.isSafeInteger(value) && value >= 0;\n};\n\nexports.preferences = function (target, source) {\n Messages = Messages || require('./messages');\n target = target || {};\n var merged = Object.assign({}, target, source);\n\n if (source.errors && target.errors) {\n merged.errors = Object.assign({}, target.errors, source.errors);\n }\n\n if (source.messages) {\n merged.messages = Messages.compile(source.messages, target.messages);\n }\n\n delete merged[exports.symbols.prefs];\n return merged;\n};\n\nexports.State =\n/*#__PURE__*/\nfunction () {\n function _class(path, ancestors, state) {\n _classCallCheck(this, _class);\n\n this.path = path;\n this.ancestors = ancestors;\n this.mainstay = state.mainstay;\n this.schemas = state.schemas;\n }\n\n _createClass(_class, [{\n key: \"entry\",\n value: function entry(schema, reference) {\n var ancestors = reference !== undefined ? [reference] : [];\n var state = new exports.State([], ancestors, this);\n state.schemas = state.schemas && [].concat(_toConsumableArray(state.schemas), [schema]);\n return state;\n }\n }, {\n key: \"localize\",\n value: function localize(path) {\n var ancestors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var schema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n var state = new exports.State(path, ancestors, this);\n\n if (schema) {\n state.schemas = state.schemas && [].concat(_toConsumableArray(state.schemas), [schema]);\n }\n\n return state;\n }\n }, {\n key: \"nest\",\n value: function nest(schema) {\n var state = new exports.State(this.path, this.ancestors, this);\n state.schemas = state.schemas && [].concat(_toConsumableArray(state.schemas), [schema]);\n return state;\n }\n }]);\n\n return _class;\n}();\n\nexports.tryWithPath = function (fn, key) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n\n try {\n return fn();\n } catch (err) {\n if (err.path !== undefined) {\n err.path = key + '.' + err.path;\n } else {\n err.path = key;\n }\n\n if (options.append) {\n err.message = \"\".concat(err.message, \"(\").concat(err.path, \")\");\n }\n\n throw err;\n }\n};\n\nexports.validateArg = function (value, _ref) {\n var assert = _ref.assert,\n message = _ref.message;\n\n if (exports.isSchema(assert)) {\n var result = assert.validate(value);\n\n if (!result.error) {\n return;\n }\n\n return result.error.message;\n } else if (!assert(value)) {\n return message;\n }\n};\n\nexports.verifyFlat = function (args, method) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = args[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var arg = _step.value;\n Assert(!Array.isArray(arg), 'Method no longer accepts array arguments:', method);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst AssertError = require('@hapi/hoek/lib/error');\n\nconst Marker = require('@hapi/marker');\n\nconst Pkg = require('../package.json');\n\nlet Messages;\nlet Schemas;\nconst internals = {\n isoDate: /^(?:[-+]\\d{2})?(?:\\d{4}(?!\\d{2}\\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\\1(?:[12]\\d|0[1-9]|3[01]))?|W(?:[0-4]\\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\\d|[12]\\d{2}|3(?:[0-5]\\d|6[1-6])))(?![T]$|[T][\\d]+Z$)(?:[T\\s](?:(?:(?:[01]\\d|2[0-3])(?:(:?)[0-5]\\d)?|24\\:?00)(?:[.,]\\d+(?!:))?)(?:\\2[0-5]\\d(?:[.,]\\d+)?)?(?:[Z]|(?:[+-])(?:[01]\\d|2[0-3])(?::?[0-5]\\d)?)?)?)?$/\n};\nexports.version = Pkg.version;\nexports.defaults = {\n abortEarly: true,\n allowUnknown: false,\n cache: true,\n context: null,\n convert: true,\n dateFormat: 'iso',\n errors: {\n escapeHtml: false,\n language: null,\n stack: false,\n wrapArrays: true\n },\n externals: true,\n messages: {},\n nonEnumerables: false,\n noDefaults: false,\n presence: 'optional',\n skipFunctions: false,\n stripUnknown: false,\n warnings: false\n};\nexports.symbols = {\n any: Marker('joi-any-base'),\n // Used to internally identify any-based types (shared with other joi versions)\n arraySingle: Symbol('arraySingle'),\n deepDefault: Symbol('deepDefault'),\n literal: Symbol('literal'),\n prefs: Symbol('prefs'),\n ref: Symbol('ref'),\n values: Symbol('values'),\n template: Symbol('template')\n};\n\nexports.assertOptions = function (options, keys) {\n let name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Options';\n Assert(options && typeof options === 'object' && !Array.isArray(options), 'Options must be of type object');\n const unknownKeys = Object.keys(options).filter(k => !keys.includes(k));\n Assert(unknownKeys.length === 0, \"\".concat(name, \" contain unknown keys: \").concat(unknownKeys));\n};\n\nexports.checkPreferences = function (prefs) {\n Schemas = Schemas || require('./schemas');\n const result = Schemas.preferences.validate(prefs);\n\n if (result.error) {\n throw new AssertError([result.error.details[0].message]);\n }\n};\n\nexports.compare = function (a, b, operator) {\n switch (operator) {\n case '=':\n return a === b;\n\n case '>':\n return a > b;\n\n case '<':\n return a < b;\n\n case '>=':\n return a >= b;\n\n case '<=':\n return a <= b;\n }\n};\n\nexports.default = function (value, defaultValue) {\n return value === undefined ? defaultValue : value;\n};\n\nexports.isIsoDate = function (date) {\n return internals.isoDate.test(date);\n};\n\nexports.isNumber = function (value) {\n return typeof value === 'number' && !isNaN(value);\n};\n\nexports.isResolvable = function (obj) {\n if (!obj) {\n return false;\n }\n\n return obj[exports.symbols.ref] || obj[exports.symbols.template];\n};\n\nexports.isSchema = function (schema) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const any = schema && schema[exports.symbols.any];\n\n if (!any) {\n return false;\n }\n\n Assert(options.legacy || any.version === exports.version, 'Cannot mix different versions of joi schemas');\n return true;\n};\n\nexports.isValues = function (obj) {\n return obj[exports.symbols.values];\n};\n\nexports.limit = function (value) {\n return Number.isSafeInteger(value) && value >= 0;\n};\n\nexports.preferences = function (target, source) {\n Messages = Messages || require('./messages');\n target = target || {};\n const merged = Object.assign({}, target, source);\n\n if (source.errors && target.errors) {\n merged.errors = Object.assign({}, target.errors, source.errors);\n }\n\n if (source.messages) {\n merged.messages = Messages.compile(source.messages, target.messages);\n }\n\n delete merged[exports.symbols.prefs];\n return merged;\n};\n\nexports.State = class {\n constructor(path, ancestors, state) {\n this.path = path;\n this.ancestors = ancestors;\n this.mainstay = state.mainstay;\n this.schemas = state.schemas;\n }\n\n entry(schema, reference) {\n const ancestors = reference !== undefined ? [reference] : [];\n const state = new exports.State([], ancestors, this);\n state.schemas = state.schemas && [...state.schemas, schema];\n return state;\n }\n\n localize(path) {\n let ancestors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n let schema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n const state = new exports.State(path, ancestors, this);\n\n if (schema) {\n state.schemas = state.schemas && [...state.schemas, schema];\n }\n\n return state;\n }\n\n nest(schema) {\n const state = new exports.State(this.path, this.ancestors, this);\n state.schemas = state.schemas && [...state.schemas, schema];\n return state;\n }\n\n};\n\nexports.tryWithPath = function (fn, key) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n\n try {\n return fn();\n } catch (err) {\n if (err.path !== undefined) {\n err.path = key + '.' + err.path;\n } else {\n err.path = key;\n }\n\n if (options.append) {\n err.message = \"\".concat(err.message, \"(\").concat(err.path, \")\");\n }\n\n throw err;\n }\n};\n\nexports.validateArg = function (value, _ref) {\n let {\n assert,\n message\n } = _ref;\n\n if (exports.isSchema(assert)) {\n const result = assert.validate(value);\n\n if (!result.error) {\n return;\n }\n\n return result.error.message;\n } else if (!assert(value)) {\n return message;\n }\n};\n\nexports.verifyFlat = function (args, method) {\n for (const arg of args) {\n Assert(!Array.isArray(arg), 'Method no longer accepts array arguments:', method);\n }\n};" }, { "id": 2, @@ -599,7 +599,7 @@ "name": "../node_modules/@hapi/hoek/lib/clone.js", "index": 5, "index2": 6, - "size": 5673, + "size": 3257, "cacheable": true, "built": true, "optional": false, @@ -616,8 +616,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -625,15 +625,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/cache.js", "name": "../lib/cache.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1052, - "building": 123 + "factory": 614, + "building": 142 }, "failed": false, "errors": 0, @@ -647,7 +647,7 @@ "moduleName": "../lib/template.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "29:12-43" + "loc": "5:14-45" }, { "moduleId": 5, @@ -656,7 +656,7 @@ "moduleName": "../lib/ref.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "29:12-43" + "loc": "5:14-45" }, { "moduleId": 7, @@ -665,7 +665,7 @@ "moduleName": "../lib/errors.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "37:12-43" + "loc": "3:14-45" }, { "moduleId": 10, @@ -674,7 +674,7 @@ "moduleName": "../lib/messages.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "7:12-43" + "loc": "5:14-45" }, { "moduleId": 16, @@ -683,7 +683,7 @@ "moduleName": "../lib/cache.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "13:12-43" + "loc": "5:14-45" }, { "moduleId": 19, @@ -692,7 +692,7 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "23:12-43" + "loc": "5:14-45" }, { "moduleId": 20, @@ -701,7 +701,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/merge.js", "type": "cjs require", "userRequest": "./clone", - "loc": "7:12-30" + "loc": "5:14-32" }, { "moduleId": 23, @@ -710,43 +710,43 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "45:12-43" + "loc": "9:14-45" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "23:12-43" + "loc": "5:14-45" }, { - "moduleId": 32, + "moduleId": 31, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/extend.js", "module": "../lib/extend.js", "moduleName": "../lib/extend.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "15:12-43" + "loc": "5:14-45" }, { - "moduleId": 34, + "moduleId": 33, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/validator.js", "module": "../lib/validator.js", "moduleName": "../lib/validator.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "25:12-43" + "loc": "5:14-45" }, { - "moduleId": 39, + "moduleId": 38, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/applyToDefaults.js", "module": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "moduleName": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "type": "cjs require", "userRequest": "./clone", - "loc": "7:12-30" + "loc": "5:14-32" } ], "usedExports": true, @@ -755,7 +755,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Types = require('./types');\n\nvar Utils = require('./utils');\n\nvar internals = {\n needsProtoHack: new Set([Types.set, Types.map, Types.weakSet, Types.weakMap])\n};\n\nmodule.exports = internals.clone = function (obj) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n var _seen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n\n if (_typeof(obj) !== 'object' || obj === null) {\n return obj;\n }\n\n var clone = internals.clone;\n var seen = _seen;\n\n if (options.shallow) {\n if (options.shallow !== true) {\n return internals.cloneWithShallow(obj, options);\n }\n\n clone = function clone(value) {\n return value;\n };\n } else {\n seen = seen || new Map();\n var lookup = seen.get(obj);\n\n if (lookup) {\n return lookup;\n }\n }\n\n var baseProto = Types.getInternalProto(obj);\n var newObj;\n\n switch (baseProto) {\n case Types.buffer:\n return Buffer && Buffer.from(obj);\n // $lab:coverage:ignore$\n\n case Types.date:\n return new Date(obj.getTime());\n\n case Types.regex:\n return new RegExp(obj);\n\n case Types.array:\n newObj = [];\n break;\n\n default:\n if (options.prototype !== false) {\n // Defaults to true\n var proto = Object.getPrototypeOf(obj);\n\n if (proto && proto.isImmutable) {\n return obj;\n }\n\n if (internals.needsProtoHack.has(baseProto)) {\n newObj = new proto.constructor();\n\n if (proto !== baseProto) {\n Object.setPrototypeOf(newObj, proto);\n }\n } else {\n newObj = Object.create(proto);\n }\n } else if (internals.needsProtoHack.has(baseProto)) {\n newObj = new baseProto.constructor();\n } else {\n newObj = {};\n }\n\n }\n\n if (seen) {\n seen.set(obj, newObj); // Set seen, since obj could recurse\n }\n\n if (baseProto === Types.set) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = obj[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var value = _step.value;\n newObj.add(clone(value, options, seen));\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n } else if (baseProto === Types.map) {\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = obj[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var _step2$value = _slicedToArray(_step2.value, 2),\n key = _step2$value[0],\n _value = _step2$value[1];\n\n newObj.set(key, clone(_value, options, seen));\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n\n var keys = Utils.keys(obj, options);\n\n for (var i = 0; i < keys.length; ++i) {\n var key = keys[i];\n\n if (baseProto === Types.array && key === 'length') {\n continue;\n }\n\n var descriptor = Object.getOwnPropertyDescriptor(obj, key);\n\n if (descriptor && (descriptor.get || descriptor.set)) {\n Object.defineProperty(newObj, key, descriptor);\n } else {\n Object.defineProperty(newObj, key, {\n enumerable: descriptor ? descriptor.enumerable : true,\n writable: true,\n configurable: true,\n value: clone(obj[key], options, seen)\n });\n }\n }\n\n if (baseProto === Types.array) {\n newObj.length = obj.length;\n }\n\n return newObj;\n};\n\ninternals.cloneWithShallow = function (source, options) {\n var keys = options.shallow;\n options = Object.assign({}, options);\n options.shallow = false;\n var storage = Utils.store(source, keys); // Move shallow copy items to storage\n\n var copy = internals.clone(source, options); // Deep copy the rest\n\n Utils.restore(copy, source, storage); // Shallow copy the stored items and restore\n\n return copy;\n};" + "source": "'use strict';\n\nconst Types = require('./types');\n\nconst Utils = require('./utils');\n\nconst internals = {\n needsProtoHack: new Set([Types.set, Types.map, Types.weakSet, Types.weakMap])\n};\n\nmodule.exports = internals.clone = function (obj) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n let _seen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n\n if (typeof obj !== 'object' || obj === null) {\n return obj;\n }\n\n let clone = internals.clone;\n let seen = _seen;\n\n if (options.shallow) {\n if (options.shallow !== true) {\n return internals.cloneWithShallow(obj, options);\n }\n\n clone = value => value;\n } else {\n seen = seen || new Map();\n const lookup = seen.get(obj);\n\n if (lookup) {\n return lookup;\n }\n }\n\n const baseProto = Types.getInternalProto(obj);\n let newObj;\n\n switch (baseProto) {\n case Types.buffer:\n return Buffer && Buffer.from(obj);\n // $lab:coverage:ignore$\n\n case Types.date:\n return new Date(obj.getTime());\n\n case Types.regex:\n return new RegExp(obj);\n\n case Types.array:\n newObj = [];\n break;\n\n default:\n if (options.prototype !== false) {\n // Defaults to true\n const proto = Object.getPrototypeOf(obj);\n\n if (proto && proto.isImmutable) {\n return obj;\n }\n\n if (internals.needsProtoHack.has(baseProto)) {\n newObj = new proto.constructor();\n\n if (proto !== baseProto) {\n Object.setPrototypeOf(newObj, proto);\n }\n } else {\n newObj = Object.create(proto);\n }\n } else if (internals.needsProtoHack.has(baseProto)) {\n newObj = new baseProto.constructor();\n } else {\n newObj = {};\n }\n\n }\n\n if (seen) {\n seen.set(obj, newObj); // Set seen, since obj could recurse\n }\n\n if (baseProto === Types.set) {\n for (const value of obj) {\n newObj.add(clone(value, options, seen));\n }\n } else if (baseProto === Types.map) {\n for (const [key, value] of obj) {\n newObj.set(key, clone(value, options, seen));\n }\n }\n\n const keys = Utils.keys(obj, options);\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n\n if (baseProto === Types.array && key === 'length') {\n continue;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n\n if (descriptor && (descriptor.get || descriptor.set)) {\n Object.defineProperty(newObj, key, descriptor);\n } else {\n Object.defineProperty(newObj, key, {\n enumerable: descriptor ? descriptor.enumerable : true,\n writable: true,\n configurable: true,\n value: clone(obj[key], options, seen)\n });\n }\n }\n\n if (baseProto === Types.array) {\n newObj.length = obj.length;\n }\n\n return newObj;\n};\n\ninternals.cloneWithShallow = function (source, options) {\n const keys = options.shallow;\n options = Object.assign({}, options);\n options.shallow = false;\n const storage = Utils.store(source, keys); // Move shallow copy items to storage\n\n const copy = internals.clone(source, options); // Deep copy the rest\n\n Utils.restore(copy, source, storage); // Shallow copy the stored items and restore\n\n return copy;\n};" }, { "id": 3, @@ -763,7 +763,7 @@ "name": "../lib/types/any.js", "index": 22, "index2": 27, - "size": 1218, + "size": 1213, "cacheable": true, "built": true, "optional": false, @@ -780,15 +780,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -802,7 +802,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/any", - "loc": "39:9-31" + "loc": "25:9-31" }, { "moduleId": 23, @@ -811,79 +811,79 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "./any", - "loc": "49:10-26" + "loc": "13:12-28" }, { - "moduleId": 30, + "moduleId": 29, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "module": "../lib/types/alternatives.js", "moduleName": "../lib/types/alternatives.js", "type": "cjs require", "userRequest": "./any", - "loc": "23:10-26" + "loc": "5:12-28" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "./any", - "loc": "21:10-26" + "loc": "11:12-28" }, { - "moduleId": 36, + "moduleId": 35, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", "module": "../lib/types/boolean.js", "moduleName": "../lib/types/boolean.js", "type": "cjs require", "userRequest": "./any", - "loc": "13:10-26" + "loc": "5:12-28" }, { - "moduleId": 37, + "moduleId": 36, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/date.js", "module": "../lib/types/date.js", "moduleName": "../lib/types/date.js", "type": "cjs require", "userRequest": "./any", - "loc": "5:10-26" + "loc": "5:12-28" }, { - "moduleId": 41, + "moduleId": 40, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/link.js", "module": "../lib/types/link.js", "moduleName": "../lib/types/link.js", "type": "cjs require", "userRequest": "./any", - "loc": "5:10-26" + "loc": "5:12-28" }, { - "moduleId": 42, + "moduleId": 41, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/number.js", "module": "../lib/types/number.js", "moduleName": "../lib/types/number.js", "type": "cjs require", "userRequest": "./any", - "loc": "5:10-26" + "loc": "5:12-28" }, { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "../any", - "loc": "19:10-27" + "loc": "17:12-29" }, { - "moduleId": 52, + "moduleId": 51, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/symbol.js", "module": "../lib/types/symbol.js", "moduleName": "../lib/types/symbol.js", "type": "cjs require", "userRequest": "./any", - "loc": "39:10-26" + "loc": "5:12-28" } ], "usedExports": true, @@ -892,7 +892,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Base = require('../base');\n\nvar internals = {};\nmodule.exports = Base.extend({\n type: 'any',\n // Rules\n rules: {\n warning: {\n method: function method(code, local) {\n Assert(code && typeof code === 'string', 'Invalid warning code');\n return this.$_addRule({\n name: 'warning',\n args: {\n code: code,\n local: local\n },\n warn: true\n });\n },\n validate: function validate(value, helpers, _ref) {\n var code = _ref.code,\n local = _ref.local;\n return helpers.error(code, local);\n },\n args: ['code', 'local'],\n multi: true\n }\n },\n // Errors\n messages: {\n 'any.default': '\"{{#label}}\" threw an error when running default method',\n 'any.failover': '\"{{#label}}\" threw an error when running failover method',\n 'any.invalid': '\"{{#label}}\" contains an invalid value',\n 'any.only': '\"{{#label}}\" must be one of {{#valids}}',\n 'any.ref': '\"{{#label}}\" {{#arg}} references \"{{#ref}}\" which {{#reason}}',\n 'any.required': '\"{{#label}}\" is required',\n 'any.unknown': '\"{{#label}}\" is not allowed'\n }\n});" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Base = require('../base');\n\nconst internals = {};\nmodule.exports = Base.extend({\n type: 'any',\n // Rules\n rules: {\n warning: {\n method: function method(code, local) {\n Assert(code && typeof code === 'string', 'Invalid warning code');\n return this.$_addRule({\n name: 'warning',\n args: {\n code,\n local\n },\n warn: true\n });\n },\n validate: function validate(value, helpers, _ref) {\n let {\n code,\n local\n } = _ref;\n return helpers.error(code, local);\n },\n args: ['code', 'local'],\n multi: true\n }\n },\n // Errors\n messages: {\n 'any.default': '\"{{#label}}\" threw an error when running default method',\n 'any.failover': '\"{{#label}}\" threw an error when running failover method',\n 'any.invalid': '\"{{#label}}\" contains an invalid value',\n 'any.only': '\"{{#label}}\" must be one of {{#valids}}',\n 'any.ref': '\"{{#label}}\" {{#arg}} references \"{{#ref}}\" which {{#reason}}',\n 'any.required': '\"{{#label}}\" is required',\n 'any.unknown': '\"{{#label}}\" is not allowed'\n }\n});" }, { "id": 4, @@ -900,7 +900,7 @@ "name": "../lib/template.js", "index": 14, "index2": 13, - "size": 14522, + "size": 7795, "cacheable": true, "built": true, "optional": false, @@ -917,15 +917,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -939,7 +939,7 @@ "moduleName": "../lib/ref.js", "type": "cjs require", "userRequest": "./template", - "loc": "431:29-50" + "loc": "340:27-48" }, { "moduleId": 7, @@ -948,7 +948,7 @@ "moduleName": "../lib/errors.js", "type": "cjs require", "userRequest": "./template", - "loc": "41:15-36" + "loc": "7:17-38" }, { "moduleId": 10, @@ -957,7 +957,7 @@ "moduleName": "../lib/messages.js", "type": "cjs require", "userRequest": "./template", - "loc": "9:15-36" + "loc": "7:17-38" }, { "moduleId": 14, @@ -966,7 +966,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./template", - "loc": "31:15-36" + "loc": "17:17-38" }, { "moduleId": 19, @@ -975,7 +975,7 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "./template", - "loc": "31:15-36" + "loc": "13:17-38" }, { "moduleId": 23, @@ -984,16 +984,16 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "../template", - "loc": "59:15-37" + "loc": "23:17-39" }, { - "moduleId": 37, + "moduleId": 36, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/date.js", "module": "../lib/types/date.js", "moduleName": "../lib/types/date.js", "type": "cjs require", "userRequest": "../template", - "loc": "9:15-37" + "loc": "9:17-39" } ], "usedExports": true, @@ -1002,7 +1002,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar EscapeHtml = require('@hapi/hoek/lib/escapeHtml');\n\nvar Formula = require('@hapi/formula');\n\nvar Common = require('./common');\n\nvar Ref = require('./ref');\n\nvar internals = {\n symbol: Symbol('template'),\n opens: new Array(1000).join(\"\\0\"),\n closes: new Array(1000).join(\"\\x01\"),\n dateFormat: {\n date: Date.prototype.toDateString,\n iso: Date.prototype.toISOString,\n string: Date.prototype.toString,\n time: Date.prototype.toTimeString,\n utc: Date.prototype.toUTCString\n }\n};\n\nmodule.exports = exports = internals.Template =\n/*#__PURE__*/\nfunction () {\n function _class(source, options) {\n _classCallCheck(this, _class);\n\n Assert(typeof source === 'string', 'Template source must be a string');\n Assert(!source.includes(\"\\0\") && !source.includes(\"\\x01\"), 'Template source cannot contain reserved control characters');\n this.source = source;\n this.rendered = source;\n this._template = null;\n this._settings = Clone(options);\n\n this._parse();\n }\n\n _createClass(_class, [{\n key: \"_parse\",\n value: function _parse() {\n // 'text {raw} {{ref}} \\\\{{ignore}} {{ignore\\\\}} {{ignore {{ignore}'\n if (!this.source.includes('{')) {\n return;\n } // Encode escaped \\\\{{{{{\n\n\n var encoded = internals.encode(this.source); // Split on first { in each set\n\n var parts = internals.split(encoded); // Process parts\n\n var refs = false;\n var processed = [];\n var head = parts.shift();\n\n if (head) {\n processed.push(head);\n }\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var part = _step.value;\n var raw = part[0] !== '{';\n var ender = raw ? '}' : '}}';\n var end = part.indexOf(ender);\n\n if (end === -1 || // Ignore non-matching closing\n part[1] === '{') {\n // Ignore more than two {\n processed.push(\"{\".concat(internals.decode(part)));\n continue;\n }\n\n var variable = part.slice(raw ? 0 : 1, end);\n\n var dynamic = this._ref(internals.decode(variable), raw);\n\n processed.push(dynamic);\n\n if (typeof dynamic !== 'string') {\n refs = true;\n }\n\n var rest = part.slice(end + ender.length);\n\n if (rest) {\n processed.push(internals.decode(rest));\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n if (!refs) {\n this.rendered = processed.join('');\n return;\n }\n\n this._template = processed;\n }\n }, {\n key: \"describe\",\n value: function describe() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n if (!this._settings && options.compact) {\n return this.source;\n }\n\n var desc = {\n template: this.source\n };\n\n if (this._settings) {\n desc.options = this._settings;\n }\n\n return desc;\n }\n }, {\n key: \"isDynamic\",\n value: function isDynamic() {\n return !!this._template;\n }\n }, {\n key: \"refs\",\n value: function refs() {\n if (!this._template) {\n return;\n }\n\n var refs = [];\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = this._template[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var part = _step2.value;\n\n if (typeof part !== 'string') {\n refs.push.apply(refs, _toConsumableArray(part.refs));\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return refs;\n }\n }, {\n key: \"resolve\",\n value: function resolve(value, state, prefs, local) {\n if (this._template && this._template.length === 1) {\n return this._part(this._template[0], value, state, prefs, local);\n }\n\n return this.render(value, state, prefs, local);\n }\n }, {\n key: \"_part\",\n value: function _part(part) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n if (part.ref) {\n var _part$ref;\n\n return (_part$ref = part.ref).resolve.apply(_part$ref, args);\n }\n\n return part.formula.evaluate(args);\n }\n }, {\n key: \"render\",\n value: function render(value, state, prefs, local) {\n var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};\n\n if (!this.isDynamic()) {\n return this.rendered;\n }\n\n var parts = [];\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = this._template[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var part = _step3.value;\n\n if (typeof part === 'string') {\n parts.push(part);\n } else {\n var string = internals.stringify(this._part(part, value, state, prefs, local), prefs, options);\n\n if (string !== undefined) {\n var result = part.raw || options.escapeHtml === false ? string : EscapeHtml(string);\n parts.push(result);\n }\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n return parts.join('');\n }\n }, {\n key: \"_ref\",\n value: function _ref(content, raw) {\n var _this = this;\n\n var refs = [];\n\n var reference = function reference(variable) {\n var ref = Ref.create(variable, _this._settings);\n refs.push(ref);\n return function (context) {\n return ref.resolve.apply(ref, _toConsumableArray(context));\n };\n };\n\n try {\n var formula = new Formula(content, {\n reference: reference,\n functions: internals.functions,\n constants: internals.constants\n });\n } catch (err) {\n err.message = \"Invalid template variable \\\"\".concat(content, \"\\\" fails due to: \").concat(err.message);\n throw err;\n }\n\n if (formula.single) {\n if (formula.single.type === 'reference') {\n return {\n ref: refs[0],\n raw: raw,\n refs: refs\n };\n }\n\n return internals.stringify(formula.single.value);\n }\n\n return {\n formula: formula,\n raw: raw,\n refs: refs\n };\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return this.source;\n }\n }], [{\n key: \"date\",\n value: function date(_date, prefs) {\n return internals.dateFormat[prefs.dateFormat].call(_date);\n }\n }, {\n key: \"build\",\n value: function build(desc) {\n return new internals.Template(desc.template, desc.options);\n }\n }, {\n key: \"isTemplate\",\n value: function isTemplate(template) {\n return template ? !!template[Common.symbols.template] : false;\n }\n }]);\n\n return _class;\n}();\n\ninternals.Template.prototype[Common.symbols.template] = true;\ninternals.Template.prototype.isImmutable = true; // Prevents Hoek from deep cloning schema objects\n\ninternals.encode = function (string) {\n return string.replace(/\\\\(\\{+)/g, function ($0, $1) {\n return internals.opens.slice(0, $1.length);\n }).replace(/\\\\(\\}+)/g, function ($0, $1) {\n return internals.closes.slice(0, $1.length);\n });\n};\n\ninternals.decode = function (string) {\n return string.replace(/\\u0000/g, '{').replace(/\\u0001/g, '}');\n};\n\ninternals.split = function (string) {\n var parts = [];\n var current = '';\n\n for (var i = 0; i < string.length; ++i) {\n var char = string[i];\n\n if (char === '{') {\n var next = '';\n\n while (i + 1 < string.length && string[i + 1] === '{') {\n next += '{';\n ++i;\n }\n\n parts.push(current);\n current = next;\n } else {\n current += char;\n }\n }\n\n parts.push(current);\n return parts;\n};\n\ninternals.stringify = function (value, prefs, options) {\n var type = _typeof(value);\n\n if (value === null) {\n return 'null';\n }\n\n if (type === 'string') {\n return value;\n }\n\n if (type === 'number' || type === 'function' || type === 'symbol') {\n return value.toString();\n }\n\n if (type !== 'object') {\n return JSON.stringify(value);\n }\n\n if (value instanceof Date) {\n return internals.Template.date(value, prefs);\n }\n\n if (value instanceof Map) {\n var pairs = [];\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = value.entries()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var _step4$value = _slicedToArray(_step4.value, 2),\n key = _step4$value[0],\n sym = _step4$value[1];\n\n pairs.push(\"\".concat(key.toString(), \" -> \").concat(sym.toString()));\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n\n value = pairs;\n }\n\n if (!Array.isArray(value)) {\n return value.toString();\n }\n\n var partial = '';\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = value[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var item = _step5.value;\n partial = partial + (partial.length ? ', ' : '') + internals.stringify(item, prefs, options);\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n\n return options.wrapArrays ? '[' + partial + ']' : partial;\n};\n\ninternals.constants = {\n true: true,\n false: false,\n null: null,\n second: 1000,\n minute: 60 * 1000,\n hour: 60 * 60 * 1000,\n day: 24 * 60 * 60 * 1000\n};\ninternals.functions = {\n if: function _if(condition, then, otherwise) {\n return condition ? then : otherwise;\n },\n number: function number(value) {\n if (typeof value === 'number') {\n return value;\n }\n\n if (typeof value === 'string') {\n return parseFloat(value);\n }\n\n if (typeof value === 'boolean') {\n return value ? 1 : 0;\n }\n\n if (value instanceof Date) {\n return value.getTime();\n }\n\n return null;\n }\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst EscapeHtml = require('@hapi/hoek/lib/escapeHtml');\n\nconst Formula = require('@hapi/formula');\n\nconst Common = require('./common');\n\nconst Ref = require('./ref');\n\nconst internals = {\n symbol: Symbol('template'),\n opens: new Array(1000).join('\\u0000'),\n closes: new Array(1000).join('\\u0001'),\n dateFormat: {\n date: Date.prototype.toDateString,\n iso: Date.prototype.toISOString,\n string: Date.prototype.toString,\n time: Date.prototype.toTimeString,\n utc: Date.prototype.toUTCString\n }\n};\nmodule.exports = exports = internals.Template = class {\n constructor(source, options) {\n Assert(typeof source === 'string', 'Template source must be a string');\n Assert(!source.includes('\\u0000') && !source.includes('\\u0001'), 'Template source cannot contain reserved control characters');\n this.source = source;\n this.rendered = source;\n this._template = null;\n this._settings = Clone(options);\n\n this._parse();\n }\n\n _parse() {\n // 'text {raw} {{ref}} \\\\{{ignore}} {{ignore\\\\}} {{ignore {{ignore}'\n if (!this.source.includes('{')) {\n return;\n } // Encode escaped \\\\{{{{{\n\n\n const encoded = internals.encode(this.source); // Split on first { in each set\n\n const parts = internals.split(encoded); // Process parts\n\n let refs = false;\n const processed = [];\n const head = parts.shift();\n\n if (head) {\n processed.push(head);\n }\n\n for (const part of parts) {\n const raw = part[0] !== '{';\n const ender = raw ? '}' : '}}';\n const end = part.indexOf(ender);\n\n if (end === -1 || // Ignore non-matching closing\n part[1] === '{') {\n // Ignore more than two {\n processed.push(\"{\".concat(internals.decode(part)));\n continue;\n }\n\n const variable = part.slice(raw ? 0 : 1, end);\n\n const dynamic = this._ref(internals.decode(variable), raw);\n\n processed.push(dynamic);\n\n if (typeof dynamic !== 'string') {\n refs = true;\n }\n\n const rest = part.slice(end + ender.length);\n\n if (rest) {\n processed.push(internals.decode(rest));\n }\n }\n\n if (!refs) {\n this.rendered = processed.join('');\n return;\n }\n\n this._template = processed;\n }\n\n static date(date, prefs) {\n return internals.dateFormat[prefs.dateFormat].call(date);\n }\n\n describe() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n if (!this._settings && options.compact) {\n return this.source;\n }\n\n const desc = {\n template: this.source\n };\n\n if (this._settings) {\n desc.options = this._settings;\n }\n\n return desc;\n }\n\n static build(desc) {\n return new internals.Template(desc.template, desc.options);\n }\n\n isDynamic() {\n return !!this._template;\n }\n\n static isTemplate(template) {\n return template ? !!template[Common.symbols.template] : false;\n }\n\n refs() {\n if (!this._template) {\n return;\n }\n\n const refs = [];\n\n for (const part of this._template) {\n if (typeof part !== 'string') {\n refs.push(...part.refs);\n }\n }\n\n return refs;\n }\n\n resolve(value, state, prefs, local) {\n if (this._template && this._template.length === 1) {\n return this._part(this._template[0], value, state, prefs, local);\n }\n\n return this.render(value, state, prefs, local);\n }\n\n _part(part) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n if (part.ref) {\n return part.ref.resolve(...args);\n }\n\n return part.formula.evaluate(args);\n }\n\n render(value, state, prefs, local) {\n let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};\n\n if (!this.isDynamic()) {\n return this.rendered;\n }\n\n const parts = [];\n\n for (const part of this._template) {\n if (typeof part === 'string') {\n parts.push(part);\n } else {\n const string = internals.stringify(this._part(part, value, state, prefs, local), prefs, options);\n\n if (string !== undefined) {\n const result = part.raw || options.escapeHtml === false ? string : EscapeHtml(string);\n parts.push(result);\n }\n }\n }\n\n return parts.join('');\n }\n\n _ref(content, raw) {\n const refs = [];\n\n const reference = variable => {\n const ref = Ref.create(variable, this._settings);\n refs.push(ref);\n return context => ref.resolve(...context);\n };\n\n try {\n var formula = new Formula(content, {\n reference,\n functions: internals.functions,\n constants: internals.constants\n });\n } catch (err) {\n err.message = \"Invalid template variable \\\"\".concat(content, \"\\\" fails due to: \").concat(err.message);\n throw err;\n }\n\n if (formula.single) {\n if (formula.single.type === 'reference') {\n return {\n ref: refs[0],\n raw,\n refs\n };\n }\n\n return internals.stringify(formula.single.value);\n }\n\n return {\n formula,\n raw,\n refs\n };\n }\n\n toString() {\n return this.source;\n }\n\n};\ninternals.Template.prototype[Common.symbols.template] = true;\ninternals.Template.prototype.isImmutable = true; // Prevents Hoek from deep cloning schema objects\n\ninternals.encode = function (string) {\n return string.replace(/\\\\(\\{+)/g, ($0, $1) => {\n return internals.opens.slice(0, $1.length);\n }).replace(/\\\\(\\}+)/g, ($0, $1) => {\n return internals.closes.slice(0, $1.length);\n });\n};\n\ninternals.decode = function (string) {\n return string.replace(/\\u0000/g, '{').replace(/\\u0001/g, '}');\n};\n\ninternals.split = function (string) {\n const parts = [];\n let current = '';\n\n for (let i = 0; i < string.length; ++i) {\n const char = string[i];\n\n if (char === '{') {\n let next = '';\n\n while (i + 1 < string.length && string[i + 1] === '{') {\n next += '{';\n ++i;\n }\n\n parts.push(current);\n current = next;\n } else {\n current += char;\n }\n }\n\n parts.push(current);\n return parts;\n};\n\ninternals.stringify = function (value, prefs, options) {\n const type = typeof value;\n\n if (value === null) {\n return 'null';\n }\n\n if (type === 'string') {\n return value;\n }\n\n if (type === 'number' || type === 'function' || type === 'symbol') {\n return value.toString();\n }\n\n if (type !== 'object') {\n return JSON.stringify(value);\n }\n\n if (value instanceof Date) {\n return internals.Template.date(value, prefs);\n }\n\n if (value instanceof Map) {\n const pairs = [];\n\n for (const [key, sym] of value.entries()) {\n pairs.push(\"\".concat(key.toString(), \" -> \").concat(sym.toString()));\n }\n\n value = pairs;\n }\n\n if (!Array.isArray(value)) {\n return value.toString();\n }\n\n let partial = '';\n\n for (const item of value) {\n partial = partial + (partial.length ? ', ' : '') + internals.stringify(item, prefs, options);\n }\n\n return options.wrapArrays ? '[' + partial + ']' : partial;\n};\n\ninternals.constants = {\n true: true,\n false: false,\n null: null,\n second: 1000,\n minute: 60 * 1000,\n hour: 60 * 60 * 1000,\n day: 24 * 60 * 60 * 1000\n};\ninternals.functions = {\n if: function _if(condition, then, otherwise) {\n return condition ? then : otherwise;\n },\n number: function number(value) {\n if (typeof value === 'number') {\n return value;\n }\n\n if (typeof value === 'string') {\n return parseFloat(value);\n }\n\n if (typeof value === 'boolean') {\n return value ? 1 : 0;\n }\n\n if (value instanceof Date) {\n return value.getTime();\n }\n\n return null;\n }\n};" }, { "id": 5, @@ -1010,7 +1010,7 @@ "name": "../lib/ref.js", "index": 17, "index2": 12, - "size": 13556, + "size": 8580, "cacheable": true, "built": true, "optional": false, @@ -1027,15 +1027,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -1049,7 +1049,7 @@ "moduleName": "../lib/template.js", "type": "cjs require", "userRequest": "./ref", - "loc": "37:10-26" + "loc": "13:12-28" }, { "moduleId": 6, @@ -1058,7 +1058,7 @@ "moduleName": "../lib/compile.js", "type": "cjs require", "userRequest": "./ref", - "loc": "9:10-26" + "loc": "7:12-28" }, { "moduleId": 14, @@ -1067,7 +1067,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./ref", - "loc": "29:10-26" + "loc": "15:12-28" }, { "moduleId": 19, @@ -1076,7 +1076,7 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "./ref", - "loc": "29:10-26" + "loc": "11:12-28" }, { "moduleId": 23, @@ -1085,25 +1085,25 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "../ref", - "loc": "57:10-27" + "loc": "21:12-29" }, { - "moduleId": 30, + "moduleId": 29, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "module": "../lib/types/alternatives.js", "moduleName": "../lib/types/alternatives.js", "type": "cjs require", "userRequest": "../ref", - "loc": "31:10-27" + "loc": "13:12-29" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./ref", - "loc": "45:10-26" + "loc": "27:12-28" } ], "usedExports": true, @@ -1112,7 +1112,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Reach = require('@hapi/hoek/lib/reach');\n\nvar Common = require('./common');\n\nvar Template;\nvar internals = {\n symbol: Symbol('ref'),\n // Used to internally identify references (shared with other joi versions)\n defaults: {\n adjust: null,\n iterables: null,\n map: null,\n separator: '.',\n type: 'value'\n }\n};\n\nexports.create = function (key) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(typeof key === 'string', 'Invalid reference key:', key);\n Common.assertOptions(options, ['adjust', 'ancestor', 'iterables', 'map', 'prefix', 'separator']);\n Assert(!options.prefix || _typeof(options.prefix) === 'object', 'options.prefix must be of type object');\n var ref = Object.assign({}, internals.defaults, options);\n delete ref.prefix;\n var separator = ref.separator;\n var context = internals.context(key, options.prefix);\n ref.type = context.type;\n key = context.key;\n\n if (ref.type === 'value') {\n if (context.root) {\n Assert(!separator || key[0] !== separator, 'Cannot specify relative path with root prefix');\n ref.ancestor = 'root';\n\n if (!key) {\n key = null;\n }\n }\n\n if (separator && separator === key) {\n key = null;\n ref.ancestor = 0;\n } else {\n if (ref.ancestor !== undefined) {\n Assert(!separator || !key || key[0] !== separator, 'Cannot combine prefix with ancestor option');\n } else {\n var _internals$ancestor = internals.ancestor(key, separator),\n _internals$ancestor2 = _slicedToArray(_internals$ancestor, 2),\n ancestor = _internals$ancestor2[0],\n slice = _internals$ancestor2[1];\n\n if (slice) {\n key = key.slice(slice);\n\n if (key === '') {\n key = null;\n }\n }\n\n ref.ancestor = ancestor;\n }\n }\n }\n\n ref.path = separator ? key === null ? [] : key.split(separator) : [key];\n return new internals.Ref(ref);\n};\n\nexports.isRef = function (ref) {\n return ref ? !!ref[Common.symbols.ref] : false;\n};\n\ninternals.Ref =\n/*#__PURE__*/\nfunction () {\n function _class(options) {\n _classCallCheck(this, _class);\n\n Assert(_typeof(options) === 'object', 'Invalid reference construction');\n Common.assertOptions(options, ['adjust', 'ancestor', 'iterables', 'map', 'path', 'separator', 'type', // Copied\n 'depth', 'key', 'root', 'display' // Overridden\n ]);\n Assert([false, undefined].includes(options.separator) || typeof options.separator === 'string' && options.separator.length === 1, 'Invalid separator');\n Assert(!options.adjust || typeof options.adjust === 'function', 'options.adjust must be a function');\n Assert(!options.map || Array.isArray(options.map), 'options.map must be an array');\n Assert(!options.map || !options.adjust, 'Cannot set both map and adjust options');\n Object.assign(this, internals.defaults, options);\n Assert(this.type === 'value' || this.ancestor === undefined, 'Non-value references cannot reference ancestors');\n\n if (Array.isArray(this.map)) {\n this.map = new Map(this.map);\n }\n\n this.depth = this.path.length;\n this.key = this.path.length ? this.path.join(this.separator) : null;\n this.root = this.path[0];\n this.updateDisplay();\n }\n\n _createClass(_class, [{\n key: \"resolve\",\n value: function resolve(value, state, prefs, local) {\n var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};\n\n if (this.type === 'global') {\n return this._resolve(prefs.context, state, options);\n }\n\n if (this.type === 'local') {\n return this._resolve(local, state, options);\n }\n\n if (!this.ancestor) {\n return this._resolve(value, state, options);\n }\n\n if (this.ancestor === 'root') {\n return this._resolve(state.ancestors[state.ancestors.length - 1], state, options);\n }\n\n Assert(this.ancestor <= state.ancestors.length, 'Invalid reference exceeds the schema root:', this.display);\n return this._resolve(state.ancestors[this.ancestor - 1], state, options);\n }\n }, {\n key: \"_resolve\",\n value: function _resolve(target, state, options) {\n var resolved;\n\n if (this.type === 'value' && state.mainstay && state.mainstay.shadow && options.shadow !== false) {\n resolved = state.mainstay.shadow.get(this.path);\n }\n\n if (resolved === undefined) {\n resolved = Reach(target, this.path, {\n iterables: this.iterables,\n functions: true\n });\n }\n\n if (this.adjust) {\n resolved = this.adjust(resolved);\n }\n\n if (this.map) {\n var mapped = this.map.get(resolved);\n\n if (mapped !== undefined) {\n return mapped;\n }\n }\n\n return resolved;\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return this.display;\n }\n }, {\n key: \"clone\",\n value: function clone() {\n return new internals.Ref(this);\n }\n }, {\n key: \"describe\",\n value: function describe() {\n var ref = {\n path: this.path\n };\n\n if (this.type !== 'value') {\n ref.type = this.type;\n }\n\n if (this.separator !== '.') {\n ref.separator = this.separator;\n }\n\n if (this.type === 'value' && this.ancestor !== 1) {\n ref.ancestor = this.ancestor;\n }\n\n if (this.map) {\n ref.map = _toConsumableArray(this.map);\n }\n\n for (var _i2 = 0, _arr2 = ['adjust', 'iterables']; _i2 < _arr2.length; _i2++) {\n var key = _arr2[_i2];\n\n if (this[key] !== null) {\n ref[key] = this[key];\n }\n }\n\n return {\n ref: ref\n };\n }\n }, {\n key: \"updateDisplay\",\n value: function updateDisplay() {\n if (this.type !== 'value') {\n this.display = \"ref:\".concat(this.type, \":\").concat(this.key);\n return;\n }\n\n if (!this.separator) {\n this.display = \"ref:\".concat(this.key);\n return;\n }\n\n if (!this.ancestor) {\n this.display = \"ref:\".concat(this.separator).concat(this.key);\n return;\n }\n\n if (this.ancestor === 'root') {\n this.display = \"ref:root:\".concat(this.key);\n return;\n }\n\n if (this.ancestor === 1) {\n this.display = \"ref:\".concat(this.key);\n return;\n }\n\n var lead = new Array(this.ancestor + 1).fill(this.separator).join('');\n this.display = \"ref:\".concat(lead).concat(this.key || '');\n }\n }]);\n\n return _class;\n}();\n\ninternals.Ref.prototype[Common.symbols.ref] = true;\n\nexports.build = function (desc) {\n desc = Object.assign({}, internals.defaults, desc);\n\n if (desc.type === 'value' && desc.ancestor === undefined) {\n desc.ancestor = 1;\n }\n\n return new internals.Ref(desc);\n};\n\ninternals.context = function (key) {\n var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n key = key.trim();\n var globalp = prefix.global || '$';\n\n if (key.startsWith(globalp)) {\n return {\n key: key.slice(globalp.length),\n type: 'global'\n };\n }\n\n var local = prefix.local || '#';\n\n if (key.startsWith(local)) {\n return {\n key: key.slice(local.length),\n type: 'local'\n };\n }\n\n var root = prefix.root || '/';\n\n if (key.startsWith(root)) {\n return {\n key: key.slice(root.length),\n type: 'value',\n root: true\n };\n }\n\n return {\n key: key,\n type: 'value'\n };\n};\n\ninternals.ancestor = function (key, separator) {\n if (!separator) {\n return [1, 0]; // 'a_b' -> 1 (parent)\n }\n\n if (key[0] !== separator) {\n // 'a.b' -> 1 (parent)\n return [1, 0];\n }\n\n if (key[1] !== separator) {\n // '.a.b' -> 0 (self)\n return [0, 1];\n }\n\n var i = 2;\n\n while (key[i] === separator) {\n ++i;\n }\n\n return [i - 1, i]; // '...a.b.' -> 2 (grandparent)\n};\n\nexports.toSibling = 0;\nexports.toParent = 1;\n\nexports.Manager =\n/*#__PURE__*/\nfunction () {\n function _class2() {\n _classCallCheck(this, _class2);\n\n this.refs = []; // 0: [self refs], 1: [parent refs], 2: [grandparent refs], ...\n }\n\n _createClass(_class2, [{\n key: \"register\",\n value: function register(source, target) {\n if (!source) {\n return;\n }\n\n target = target === undefined ? exports.toParent : target; // Array\n\n if (Array.isArray(source)) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = source[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var ref = _step.value;\n this.register(ref, target);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return;\n } // Schema\n\n\n if (Common.isSchema(source)) {\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = source._refs.refs[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var item = _step2.value;\n\n if (item.ancestor - target >= 0) {\n this.refs.push({\n ancestor: item.ancestor - target,\n root: item.root\n });\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return;\n } // Reference\n\n\n if (exports.isRef(source) && source.type === 'value' && source.ancestor - target >= 0) {\n this.refs.push({\n ancestor: source.ancestor - target,\n root: source.root\n });\n } // Template\n\n\n Template = Template || require('./template');\n\n if (Template.isTemplate(source)) {\n this.register(source.refs(), target);\n }\n }\n }, {\n key: \"clone\",\n value: function clone() {\n var copy = new exports.Manager();\n copy.refs = Clone(this.refs);\n return copy;\n }\n }, {\n key: \"reset\",\n value: function reset() {\n this.refs = [];\n }\n }, {\n key: \"roots\",\n value: function roots() {\n return this.refs.filter(function (ref) {\n return !ref.ancestor;\n }).map(function (ref) {\n return ref.root;\n });\n }\n }, {\n key: \"length\",\n get: function get() {\n return this.refs.length;\n }\n }]);\n\n return _class2;\n}();" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Reach = require('@hapi/hoek/lib/reach');\n\nconst Common = require('./common');\n\nlet Template;\nconst internals = {\n symbol: Symbol('ref'),\n // Used to internally identify references (shared with other joi versions)\n defaults: {\n adjust: null,\n iterables: null,\n map: null,\n separator: '.',\n type: 'value'\n }\n};\n\nexports.create = function (key) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(typeof key === 'string', 'Invalid reference key:', key);\n Common.assertOptions(options, ['adjust', 'ancestor', 'iterables', 'map', 'prefix', 'separator']);\n Assert(!options.prefix || typeof options.prefix === 'object', 'options.prefix must be of type object');\n const ref = Object.assign({}, internals.defaults, options);\n delete ref.prefix;\n const separator = ref.separator;\n const context = internals.context(key, options.prefix);\n ref.type = context.type;\n key = context.key;\n\n if (ref.type === 'value') {\n if (context.root) {\n Assert(!separator || key[0] !== separator, 'Cannot specify relative path with root prefix');\n ref.ancestor = 'root';\n\n if (!key) {\n key = null;\n }\n }\n\n if (separator && separator === key) {\n key = null;\n ref.ancestor = 0;\n } else {\n if (ref.ancestor !== undefined) {\n Assert(!separator || !key || key[0] !== separator, 'Cannot combine prefix with ancestor option');\n } else {\n const [ancestor, slice] = internals.ancestor(key, separator);\n\n if (slice) {\n key = key.slice(slice);\n\n if (key === '') {\n key = null;\n }\n }\n\n ref.ancestor = ancestor;\n }\n }\n }\n\n ref.path = separator ? key === null ? [] : key.split(separator) : [key];\n return new internals.Ref(ref);\n};\n\nexports.isRef = function (ref) {\n return ref ? !!ref[Common.symbols.ref] : false;\n};\n\ninternals.Ref = class {\n constructor(options) {\n Assert(typeof options === 'object', 'Invalid reference construction');\n Common.assertOptions(options, ['adjust', 'ancestor', 'iterables', 'map', 'path', 'separator', 'type', // Copied\n 'depth', 'key', 'root', 'display' // Overridden\n ]);\n Assert([false, undefined].includes(options.separator) || typeof options.separator === 'string' && options.separator.length === 1, 'Invalid separator');\n Assert(!options.adjust || typeof options.adjust === 'function', 'options.adjust must be a function');\n Assert(!options.map || Array.isArray(options.map), 'options.map must be an array');\n Assert(!options.map || !options.adjust, 'Cannot set both map and adjust options');\n Object.assign(this, internals.defaults, options);\n Assert(this.type === 'value' || this.ancestor === undefined, 'Non-value references cannot reference ancestors');\n\n if (Array.isArray(this.map)) {\n this.map = new Map(this.map);\n }\n\n this.depth = this.path.length;\n this.key = this.path.length ? this.path.join(this.separator) : null;\n this.root = this.path[0];\n this.updateDisplay();\n }\n\n resolve(value, state, prefs, local) {\n let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};\n\n if (this.type === 'global') {\n return this._resolve(prefs.context, state, options);\n }\n\n if (this.type === 'local') {\n return this._resolve(local, state, options);\n }\n\n if (!this.ancestor) {\n return this._resolve(value, state, options);\n }\n\n if (this.ancestor === 'root') {\n return this._resolve(state.ancestors[state.ancestors.length - 1], state, options);\n }\n\n Assert(this.ancestor <= state.ancestors.length, 'Invalid reference exceeds the schema root:', this.display);\n return this._resolve(state.ancestors[this.ancestor - 1], state, options);\n }\n\n _resolve(target, state, options) {\n let resolved;\n\n if (this.type === 'value' && state.mainstay && state.mainstay.shadow && options.shadow !== false) {\n resolved = state.mainstay.shadow.get(this.path);\n }\n\n if (resolved === undefined) {\n resolved = Reach(target, this.path, {\n iterables: this.iterables,\n functions: true\n });\n }\n\n if (this.adjust) {\n resolved = this.adjust(resolved);\n }\n\n if (this.map) {\n const mapped = this.map.get(resolved);\n\n if (mapped !== undefined) {\n return mapped;\n }\n }\n\n return resolved;\n }\n\n toString() {\n return this.display;\n }\n\n clone() {\n return new internals.Ref(this);\n }\n\n describe() {\n const ref = {\n path: this.path\n };\n\n if (this.type !== 'value') {\n ref.type = this.type;\n }\n\n if (this.separator !== '.') {\n ref.separator = this.separator;\n }\n\n if (this.type === 'value' && this.ancestor !== 1) {\n ref.ancestor = this.ancestor;\n }\n\n if (this.map) {\n ref.map = [...this.map];\n }\n\n for (const key of ['adjust', 'iterables']) {\n if (this[key] !== null) {\n ref[key] = this[key];\n }\n }\n\n return {\n ref\n };\n }\n\n updateDisplay() {\n if (this.type !== 'value') {\n this.display = \"ref:\".concat(this.type, \":\").concat(this.key);\n return;\n }\n\n if (!this.separator) {\n this.display = \"ref:\".concat(this.key);\n return;\n }\n\n if (!this.ancestor) {\n this.display = \"ref:\".concat(this.separator).concat(this.key);\n return;\n }\n\n if (this.ancestor === 'root') {\n this.display = \"ref:root:\".concat(this.key);\n return;\n }\n\n if (this.ancestor === 1) {\n this.display = \"ref:\".concat(this.key);\n return;\n }\n\n const lead = new Array(this.ancestor + 1).fill(this.separator).join('');\n this.display = \"ref:\".concat(lead).concat(this.key || '');\n }\n\n};\ninternals.Ref.prototype[Common.symbols.ref] = true;\n\nexports.build = function (desc) {\n desc = Object.assign({}, internals.defaults, desc);\n\n if (desc.type === 'value' && desc.ancestor === undefined) {\n desc.ancestor = 1;\n }\n\n return new internals.Ref(desc);\n};\n\ninternals.context = function (key) {\n let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n key = key.trim();\n const globalp = prefix.global || '$';\n\n if (key.startsWith(globalp)) {\n return {\n key: key.slice(globalp.length),\n type: 'global'\n };\n }\n\n const local = prefix.local || '#';\n\n if (key.startsWith(local)) {\n return {\n key: key.slice(local.length),\n type: 'local'\n };\n }\n\n const root = prefix.root || '/';\n\n if (key.startsWith(root)) {\n return {\n key: key.slice(root.length),\n type: 'value',\n root: true\n };\n }\n\n return {\n key,\n type: 'value'\n };\n};\n\ninternals.ancestor = function (key, separator) {\n if (!separator) {\n return [1, 0]; // 'a_b' -> 1 (parent)\n }\n\n if (key[0] !== separator) {\n // 'a.b' -> 1 (parent)\n return [1, 0];\n }\n\n if (key[1] !== separator) {\n // '.a.b' -> 0 (self)\n return [0, 1];\n }\n\n let i = 2;\n\n while (key[i] === separator) {\n ++i;\n }\n\n return [i - 1, i]; // '...a.b.' -> 2 (grandparent)\n};\n\nexports.toSibling = 0;\nexports.toParent = 1;\nexports.Manager = class {\n constructor() {\n this.refs = []; // 0: [self refs], 1: [parent refs], 2: [grandparent refs], ...\n }\n\n register(source, target) {\n if (!source) {\n return;\n }\n\n target = target === undefined ? exports.toParent : target; // Array\n\n if (Array.isArray(source)) {\n for (const ref of source) {\n this.register(ref, target);\n }\n\n return;\n } // Schema\n\n\n if (Common.isSchema(source)) {\n for (const item of source._refs.refs) {\n if (item.ancestor - target >= 0) {\n this.refs.push({\n ancestor: item.ancestor - target,\n root: item.root\n });\n }\n }\n\n return;\n } // Reference\n\n\n if (exports.isRef(source) && source.type === 'value' && source.ancestor - target >= 0) {\n this.refs.push({\n ancestor: source.ancestor - target,\n root: source.root\n });\n } // Template\n\n\n Template = Template || require('./template');\n\n if (Template.isTemplate(source)) {\n this.register(source.refs(), target);\n }\n }\n\n get length() {\n return this.refs.length;\n }\n\n clone() {\n const copy = new exports.Manager();\n copy.refs = Clone(this.refs);\n return copy;\n }\n\n reset() {\n this.refs = [];\n }\n\n roots() {\n return this.refs.filter(ref => !ref.ancestor).map(ref => ref.root);\n }\n\n};" }, { "id": 6, @@ -1120,7 +1120,7 @@ "name": "../lib/compile.js", "index": 18, "index2": 17, - "size": 4225, + "size": 3264, "cacheable": true, "built": true, "optional": false, @@ -1137,15 +1137,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -1159,7 +1159,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./compile", - "loc": "23:14-34" + "loc": "9:16-36" }, { "moduleId": 23, @@ -1168,43 +1168,43 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "../compile", - "loc": "53:14-35" + "loc": "17:16-37" }, { - "moduleId": 30, + "moduleId": 29, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "module": "../lib/types/alternatives.js", "moduleName": "../lib/types/alternatives.js", "type": "cjs require", "userRequest": "../compile", - "loc": "27:14-35" + "loc": "9:16-37" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./compile", - "loc": "33:14-34" + "loc": "15:16-36" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "../compile", - "loc": "25:14-35" + "loc": "15:16-37" }, { - "moduleId": 41, + "moduleId": 40, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/link.js", "module": "../lib/types/link.js", "moduleName": "../lib/types/link.js", "type": "cjs require", "userRequest": "../compile", - "loc": "9:14-35" + "loc": "9:16-37" } ], "usedExports": true, @@ -1213,7 +1213,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Common = require('./common');\n\nvar Ref = require('./ref');\n\nvar internals = {};\n\nexports.schema = function (Joi, config) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Common.assertOptions(options, ['appendPath']);\n\n try {\n return internals.schema(Joi, config);\n } catch (err) {\n if (options.appendPath && err.path !== undefined) {\n err.message = \"\".concat(err.message).concat(err.message[err.message.length - 1] === ' ' ? '' : ' ', \"(\").concat(err.path, \")\");\n }\n\n throw err;\n }\n};\n\ninternals.schema = function (Joi, config) {\n if (config !== undefined && config !== null && _typeof(config) === 'object') {\n if (Common.isResolvable(config)) {\n return Joi.valid(config);\n }\n\n if (Common.isSchema(config)) {\n return config;\n }\n\n if (Array.isArray(config)) {\n return Joi.alternatives().try(config);\n }\n\n if (config instanceof RegExp) {\n return Joi.string().regex(config);\n }\n\n if (config instanceof Date) {\n return Joi.date().valid(config);\n }\n\n Assert(Object.getPrototypeOf(config) === Object.getPrototypeOf({}), 'Schema can only contain plain objects');\n return Joi.object().keys(config);\n }\n\n if (typeof config === 'string') {\n return Joi.string().valid(config);\n }\n\n if (typeof config === 'number') {\n return Joi.number().valid(config);\n }\n\n if (typeof config === 'boolean') {\n return Joi.boolean().valid(config);\n }\n\n Assert(config === null, 'Invalid schema content:', config);\n return Joi.valid(null);\n};\n\nexports.ref = function (id, options) {\n return Ref.isRef(id) ? id : Ref.create(id, options);\n};\n\nexports.compile = function (root, schema) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Common.assertOptions(options, ['legacy']); // Compiled by any supported version\n\n var any = schema && schema[Common.symbols.any];\n\n if (any) {\n Assert(options.legacy || any.version === Common.version, 'Cannot mix different versions of joi schemas');\n return schema;\n } // Uncompiled root\n\n\n if (_typeof(schema) !== 'object' || !options.legacy) {\n return exports.schema(root, schema, {\n appendPath: true\n }); // Will error if schema contains other versions\n } // Scan schema for compiled parts\n\n\n var compiler = internals.walk(schema);\n\n if (!compiler) {\n return exports.schema(root, schema, {\n appendPath: true\n });\n }\n\n return compiler.compile(compiler.root, schema);\n};\n\ninternals.walk = function (schema) {\n if (_typeof(schema) !== 'object') {\n return null;\n }\n\n if (Array.isArray(schema)) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = schema[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var item = _step.value;\n var compiler = internals.walk(item);\n\n if (compiler) {\n return compiler;\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return null;\n }\n\n var any = schema[Common.symbols.any];\n\n if (any) {\n return {\n root: schema[any.root],\n compile: any.compile\n };\n }\n\n Assert(Object.getPrototypeOf(schema) === Object.getPrototypeOf({}), 'Schema can only contain plain objects');\n\n for (var key in schema) {\n var _compiler = internals.walk(schema[key]);\n\n if (_compiler) {\n return _compiler;\n }\n }\n\n return null;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Common = require('./common');\n\nconst Ref = require('./ref');\n\nconst internals = {};\n\nexports.schema = function (Joi, config) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Common.assertOptions(options, ['appendPath']);\n\n try {\n return internals.schema(Joi, config);\n } catch (err) {\n if (options.appendPath && err.path !== undefined) {\n err.message = \"\".concat(err.message).concat(err.message[err.message.length - 1] === ' ' ? '' : ' ', \"(\").concat(err.path, \")\");\n }\n\n throw err;\n }\n};\n\ninternals.schema = function (Joi, config) {\n if (config !== undefined && config !== null && typeof config === 'object') {\n if (Common.isResolvable(config)) {\n return Joi.valid(config);\n }\n\n if (Common.isSchema(config)) {\n return config;\n }\n\n if (Array.isArray(config)) {\n return Joi.alternatives().try(config);\n }\n\n if (config instanceof RegExp) {\n return Joi.string().regex(config);\n }\n\n if (config instanceof Date) {\n return Joi.date().valid(config);\n }\n\n Assert(Object.getPrototypeOf(config) === Object.getPrototypeOf({}), 'Schema can only contain plain objects');\n return Joi.object().keys(config);\n }\n\n if (typeof config === 'string') {\n return Joi.string().valid(config);\n }\n\n if (typeof config === 'number') {\n return Joi.number().valid(config);\n }\n\n if (typeof config === 'boolean') {\n return Joi.boolean().valid(config);\n }\n\n Assert(config === null, 'Invalid schema content:', config);\n return Joi.valid(null);\n};\n\nexports.ref = function (id, options) {\n return Ref.isRef(id) ? id : Ref.create(id, options);\n};\n\nexports.compile = function (root, schema) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Common.assertOptions(options, ['legacy']); // Compiled by any supported version\n\n const any = schema && schema[Common.symbols.any];\n\n if (any) {\n Assert(options.legacy || any.version === Common.version, 'Cannot mix different versions of joi schemas');\n return schema;\n } // Uncompiled root\n\n\n if (typeof schema !== 'object' || !options.legacy) {\n return exports.schema(root, schema, {\n appendPath: true\n }); // Will error if schema contains other versions\n } // Scan schema for compiled parts\n\n\n const compiler = internals.walk(schema);\n\n if (!compiler) {\n return exports.schema(root, schema, {\n appendPath: true\n });\n }\n\n return compiler.compile(compiler.root, schema);\n};\n\ninternals.walk = function (schema) {\n if (typeof schema !== 'object') {\n return null;\n }\n\n if (Array.isArray(schema)) {\n for (const item of schema) {\n const compiler = internals.walk(item);\n\n if (compiler) {\n return compiler;\n }\n }\n\n return null;\n }\n\n const any = schema[Common.symbols.any];\n\n if (any) {\n return {\n root: schema[any.root],\n compile: any.compile\n };\n }\n\n Assert(Object.getPrototypeOf(schema) === Object.getPrototypeOf({}), 'Schema can only contain plain objects');\n\n for (const key in schema) {\n const compiler = internals.walk(schema[key]);\n\n if (compiler) {\n return compiler;\n }\n }\n\n return null;\n};" }, { "id": 7, @@ -1221,7 +1221,7 @@ "name": "../lib/errors.js", "index": 19, "index2": 18, - "size": 15899, + "size": 9361, "cacheable": true, "built": true, "optional": false, @@ -1238,15 +1238,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -1260,7 +1260,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./errors", - "loc": "25:13-32" + "loc": "11:15-34" }, { "moduleId": 23, @@ -1269,34 +1269,34 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "../errors", - "loc": "55:13-33" + "loc": "19:15-35" }, { - "moduleId": 30, + "moduleId": 29, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "module": "../lib/types/alternatives.js", "moduleName": "../lib/types/alternatives.js", "type": "cjs require", "userRequest": "../errors", - "loc": "29:13-33" + "loc": "11:15-35" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./errors", - "loc": "35:13-32" + "loc": "17:15-34" }, { - "moduleId": 34, + "moduleId": 33, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/validator.js", "module": "../lib/validator.js", "moduleName": "../lib/validator.js", "type": "cjs require", "userRequest": "./errors", - "loc": "31:13-32" + "loc": "11:15-34" } ], "usedExports": true, @@ -1305,7 +1305,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Common = require('./common');\n\nvar Template = require('./template');\n\nvar internals = {\n annotations: Symbol('annotations')\n};\n\nexports.Report =\n/*#__PURE__*/\nfunction () {\n function _class(code, value, local, flags, messages, state, prefs) {\n _classCallCheck(this, _class);\n\n this.code = code;\n this.flags = flags;\n this.messages = messages;\n this.path = state.path;\n this.prefs = prefs;\n this.state = state;\n this.value = value;\n this.message = null;\n this.template = null;\n this.local = local || {};\n this.local.label = exports.label(this.flags, this.state, this.prefs, this.messages);\n\n if (this.value !== undefined && !this.local.hasOwnProperty('value')) {\n this.local.value = this.value;\n }\n\n if (this.path.length) {\n var key = this.path[this.path.length - 1];\n\n if (_typeof(key) !== 'object') {\n this.local.key = key;\n }\n }\n }\n\n _createClass(_class, [{\n key: \"_setTemplate\",\n value: function _setTemplate(template) {\n this.template = template;\n\n if (!this.flags.label && this.path.length === 0) {\n var localized = this._template(this.template, 'root');\n\n if (localized) {\n this.local.label = localized;\n }\n }\n }\n }, {\n key: \"toString\",\n value: function toString() {\n if (this.message) {\n return this.message;\n }\n\n var code = this.code;\n\n var template = this._template(this.template) || this._template(this.prefs.messages) || this._template(this.messages);\n\n if (template === undefined) {\n return \"Error code \\\"\".concat(code, \"\\\" is not defined, your custom type is missing the correct messages definition\");\n }\n\n this.message = template.render(this.value, this.state, this.prefs, this.local, this.prefs.errors); // Cache result\n\n return this.message;\n }\n }, {\n key: \"_template\",\n value: function _template(messages, code) {\n return internals.template(this.value, messages, code || this.code, this.state, this.prefs);\n }\n }]);\n\n return _class;\n}();\n\ninternals.label = function (path) {\n var label = '';\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = path[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var segment = _step.value;\n\n if (_typeof(segment) === 'object') {\n // Exclude array single path segment\n continue;\n }\n\n if (typeof segment === 'string') {\n if (label) {\n label += '.';\n }\n\n label += segment;\n } else {\n label += \"[\".concat(segment, \"]\");\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return label;\n};\n\ninternals.template = function (value, messages, code, state, prefs) {\n if (!messages) {\n return;\n }\n\n if (Template.isTemplate(messages)) {\n return code !== 'root' ? messages : null;\n }\n\n var lang = prefs.errors.language;\n\n if (Common.isResolvable(lang)) {\n var local = state.ancestors[state.ancestors.length - 1];\n lang = lang.resolve(value, state, prefs, local);\n }\n\n if (lang && messages[lang] && messages[lang][code] !== undefined) {\n return messages[lang][code];\n }\n\n return messages[code];\n};\n\nexports.label = function (flags, state, prefs, messages) {\n return flags.label || internals.label(state.path) || internals.template(null, prefs.messages, 'root', state, prefs) || messages && internals.template(null, messages, 'root', state, prefs) || 'value';\n};\n\nexports.process = function (errors, original, prefs) {\n if (!errors) {\n return null;\n }\n\n var _exports$details = exports.details(errors),\n override = _exports$details.override,\n message = _exports$details.message,\n details = _exports$details.details;\n\n if (override) {\n return override;\n }\n\n if (prefs.errors.stack) {\n return new exports.ValidationError(message, details, original);\n }\n\n var limit = Error.stackTraceLimit;\n Error.stackTraceLimit = 0;\n var validationError = new exports.ValidationError(message, details, original);\n Error.stackTraceLimit = limit;\n return validationError;\n};\n\nexports.details = function (errors) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var messages = [];\n var details = [];\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = errors[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var item = _step2.value;\n\n // Override\n if (item instanceof Error) {\n if (options.override !== false) {\n return {\n override: item\n };\n }\n\n var _message = item.toString();\n\n messages.push(_message);\n details.push({\n message: _message,\n type: 'override',\n context: {\n error: item\n }\n });\n continue;\n } // Report\n\n\n var message = item.toString();\n messages.push(message);\n details.push({\n message: message,\n path: item.path.filter(function (v) {\n return _typeof(v) !== 'object';\n }),\n type: item.code,\n context: item.local\n });\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (messages.length > 1) {\n messages = _toConsumableArray(new Set(messages));\n }\n\n return {\n message: messages.join('. '),\n details: details\n };\n};\n\nexports.ValidationError =\n/*#__PURE__*/\nfunction (_Error) {\n _inherits(_class2, _Error);\n\n function _class2(message, details, original) {\n var _this;\n\n _classCallCheck(this, _class2);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(_class2).call(this, message));\n _this._original = original;\n _this.details = details;\n return _this;\n }\n\n _createClass(_class2, [{\n key: \"annotate\",\n value: function annotate(stripColorCodes) {\n if (!this._original || _typeof(this._original) !== 'object') {\n return this.details[0].message;\n }\n\n var redFgEscape = stripColorCodes ? '' : \"\\x1B[31m\";\n var redBgEscape = stripColorCodes ? '' : \"\\x1B[41m\";\n var endColor = stripColorCodes ? '' : \"\\x1B[0m\";\n var obj = Clone(this._original);\n\n for (var i = this.details.length - 1; i >= 0; --i) {\n // Reverse order to process deepest child first\n var pos = i + 1;\n var error = this.details[i];\n var path = error.path;\n var node = obj;\n\n for (var j = 0;; ++j) {\n var seg = path[j];\n\n if (Common.isSchema(node)) {\n node = node.clone(); // joi schemas are not cloned by hoek, we have to take this extra step\n }\n\n if (j + 1 < path.length && typeof node[seg] !== 'string') {\n node = node[seg];\n } else {\n var refAnnotations = node[internals.annotations] || {\n errors: {},\n missing: {}\n };\n node[internals.annotations] = refAnnotations;\n var cacheKey = seg || error.context.key;\n\n if (node[seg] !== undefined) {\n refAnnotations.errors[cacheKey] = refAnnotations.errors[cacheKey] || [];\n refAnnotations.errors[cacheKey].push(pos);\n } else {\n refAnnotations.missing[cacheKey] = pos;\n }\n\n break;\n }\n }\n }\n\n var replacers = {\n key: /_\\$key\\$_([, \\d]+)_\\$end\\$_\"/g,\n missing: /\"_\\$miss\\$_([^|]+)\\|(\\d+)_\\$end\\$_\": \"__missing__\"/g,\n arrayIndex: /\\s*\"_\\$idx\\$_([, \\d]+)_\\$end\\$_\",?\\n(.*)/g,\n specials: /\"\\[(NaN|Symbol.*|-?Infinity|function.*|\\(.*)]\"/g\n };\n var message = internals.safeStringify(obj, 2).replace(replacers.key, function ($0, $1) {\n return \"\\\" \".concat(redFgEscape, \"[\").concat($1, \"]\").concat(endColor);\n }).replace(replacers.missing, function ($0, $1, $2) {\n return \"\".concat(redBgEscape, \"\\\"\").concat($1, \"\\\"\").concat(endColor).concat(redFgEscape, \" [\").concat($2, \"]: -- missing --\").concat(endColor);\n }).replace(replacers.arrayIndex, function ($0, $1, $2) {\n return \"\\n\".concat($2, \" \").concat(redFgEscape, \"[\").concat($1, \"]\").concat(endColor);\n }).replace(replacers.specials, function ($0, $1) {\n return $1;\n });\n message = \"\".concat(message, \"\\n\").concat(redFgEscape);\n\n for (var _i = 0; _i < this.details.length; ++_i) {\n var _pos = _i + 1;\n\n message = \"\".concat(message, \"\\n[\").concat(_pos, \"] \").concat(this.details[_i].message);\n }\n\n message = message + endColor;\n return message;\n }\n }]);\n\n return _class2;\n}(_wrapNativeSuper(Error));\n\nexports.ValidationError.prototype.isJoi = true;\nexports.ValidationError.prototype.name = 'ValidationError'; // Inspired by json-stringify-safe\n\ninternals.safeStringify = function (obj, spaces) {\n return JSON.stringify(obj, internals.serializer(), spaces);\n};\n\ninternals.serializer = function () {\n var keys = [];\n var stack = [];\n\n var cycleReplacer = function cycleReplacer(key, value) {\n if (stack[0] === value) {\n return '[Circular ~]';\n }\n\n return '[Circular ~.' + keys.slice(0, stack.indexOf(value)).join('.') + ']';\n };\n\n return function (key, value) {\n if (stack.length > 0) {\n var thisPos = stack.indexOf(this);\n\n if (~thisPos) {\n stack.length = thisPos + 1;\n keys.length = thisPos + 1;\n keys[thisPos] = key;\n } else {\n stack.push(this);\n keys.push(key);\n }\n\n if (~stack.indexOf(value)) {\n value = cycleReplacer.call(this, key, value);\n }\n } else {\n stack.push(value);\n }\n\n if (value) {\n var annotations = value[internals.annotations];\n\n if (annotations) {\n if (Array.isArray(value)) {\n var annotated = [];\n\n for (var i = 0; i < value.length; ++i) {\n if (annotations.errors[i]) {\n annotated.push(\"_$idx$_\".concat(annotations.errors[i].sort().join(', '), \"_$end$_\"));\n }\n\n annotated.push(value[i]);\n }\n\n value = annotated;\n } else {\n for (var errorKey in annotations.errors) {\n value[\"\".concat(errorKey, \"_$key$_\").concat(annotations.errors[errorKey].sort().join(', '), \"_$end$_\")] = value[errorKey];\n value[errorKey] = undefined;\n }\n\n for (var missingKey in annotations.missing) {\n value[\"_$miss$_\".concat(missingKey, \"|\").concat(annotations.missing[missingKey], \"_$end$_\")] = '__missing__';\n }\n }\n\n return value;\n }\n }\n\n if (value === Infinity || value === -Infinity || Number.isNaN(value) || typeof value === 'function' || _typeof(value) === 'symbol') {\n return '[' + value.toString() + ']';\n }\n\n return value;\n };\n};" + "source": "'use strict';\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Common = require('./common');\n\nconst Template = require('./template');\n\nconst internals = {\n annotations: Symbol('annotations')\n};\nexports.Report = class {\n constructor(code, value, local, flags, messages, state, prefs) {\n this.code = code;\n this.flags = flags;\n this.messages = messages;\n this.path = state.path;\n this.prefs = prefs;\n this.state = state;\n this.value = value;\n this.message = null;\n this.template = null;\n this.local = local || {};\n this.local.label = exports.label(this.flags, this.state, this.prefs, this.messages);\n\n if (this.value !== undefined && !this.local.hasOwnProperty('value')) {\n this.local.value = this.value;\n }\n\n if (this.path.length) {\n const key = this.path[this.path.length - 1];\n\n if (typeof key !== 'object') {\n this.local.key = key;\n }\n }\n }\n\n _setTemplate(template) {\n this.template = template;\n\n if (!this.flags.label && this.path.length === 0) {\n const localized = this._template(this.template, 'root');\n\n if (localized) {\n this.local.label = localized;\n }\n }\n }\n\n toString() {\n if (this.message) {\n return this.message;\n }\n\n const code = this.code;\n\n const template = this._template(this.template) || this._template(this.prefs.messages) || this._template(this.messages);\n\n if (template === undefined) {\n return \"Error code \\\"\".concat(code, \"\\\" is not defined, your custom type is missing the correct messages definition\");\n }\n\n this.message = template.render(this.value, this.state, this.prefs, this.local, this.prefs.errors); // Cache result\n\n return this.message;\n }\n\n _template(messages, code) {\n return internals.template(this.value, messages, code || this.code, this.state, this.prefs);\n }\n\n};\n\ninternals.label = function (path) {\n let label = '';\n\n for (const segment of path) {\n if (typeof segment === 'object') {\n // Exclude array single path segment\n continue;\n }\n\n if (typeof segment === 'string') {\n if (label) {\n label += '.';\n }\n\n label += segment;\n } else {\n label += \"[\".concat(segment, \"]\");\n }\n }\n\n return label;\n};\n\ninternals.template = function (value, messages, code, state, prefs) {\n if (!messages) {\n return;\n }\n\n if (Template.isTemplate(messages)) {\n return code !== 'root' ? messages : null;\n }\n\n let lang = prefs.errors.language;\n\n if (Common.isResolvable(lang)) {\n const local = state.ancestors[state.ancestors.length - 1];\n lang = lang.resolve(value, state, prefs, local);\n }\n\n if (lang && messages[lang] && messages[lang][code] !== undefined) {\n return messages[lang][code];\n }\n\n return messages[code];\n};\n\nexports.label = function (flags, state, prefs, messages) {\n return flags.label || internals.label(state.path) || internals.template(null, prefs.messages, 'root', state, prefs) || messages && internals.template(null, messages, 'root', state, prefs) || 'value';\n};\n\nexports.process = function (errors, original, prefs) {\n if (!errors) {\n return null;\n }\n\n const {\n override,\n message,\n details\n } = exports.details(errors);\n\n if (override) {\n return override;\n }\n\n if (prefs.errors.stack) {\n return new exports.ValidationError(message, details, original);\n }\n\n const limit = Error.stackTraceLimit;\n Error.stackTraceLimit = 0;\n const validationError = new exports.ValidationError(message, details, original);\n Error.stackTraceLimit = limit;\n return validationError;\n};\n\nexports.details = function (errors) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n let messages = [];\n const details = [];\n\n for (const item of errors) {\n // Override\n if (item instanceof Error) {\n if (options.override !== false) {\n return {\n override: item\n };\n }\n\n const message = item.toString();\n messages.push(message);\n details.push({\n message,\n type: 'override',\n context: {\n error: item\n }\n });\n continue;\n } // Report\n\n\n const message = item.toString();\n messages.push(message);\n details.push({\n message,\n path: item.path.filter(v => typeof v !== 'object'),\n type: item.code,\n context: item.local\n });\n }\n\n if (messages.length > 1) {\n messages = [...new Set(messages)];\n }\n\n return {\n message: messages.join('. '),\n details\n };\n};\n\nexports.ValidationError = class extends Error {\n constructor(message, details, original) {\n super(message);\n this._original = original;\n this.details = details;\n }\n\n annotate(stripColorCodes) {\n if (!this._original || typeof this._original !== 'object') {\n return this.details[0].message;\n }\n\n const redFgEscape = stripColorCodes ? '' : '\\u001b[31m';\n const redBgEscape = stripColorCodes ? '' : '\\u001b[41m';\n const endColor = stripColorCodes ? '' : '\\u001b[0m';\n const obj = Clone(this._original);\n\n for (let i = this.details.length - 1; i >= 0; --i) {\n // Reverse order to process deepest child first\n const pos = i + 1;\n const error = this.details[i];\n const path = error.path;\n let node = obj;\n\n for (let j = 0;; ++j) {\n const seg = path[j];\n\n if (Common.isSchema(node)) {\n node = node.clone(); // joi schemas are not cloned by hoek, we have to take this extra step\n }\n\n if (j + 1 < path.length && typeof node[seg] !== 'string') {\n node = node[seg];\n } else {\n const refAnnotations = node[internals.annotations] || {\n errors: {},\n missing: {}\n };\n node[internals.annotations] = refAnnotations;\n const cacheKey = seg || error.context.key;\n\n if (node[seg] !== undefined) {\n refAnnotations.errors[cacheKey] = refAnnotations.errors[cacheKey] || [];\n refAnnotations.errors[cacheKey].push(pos);\n } else {\n refAnnotations.missing[cacheKey] = pos;\n }\n\n break;\n }\n }\n }\n\n const replacers = {\n key: /_\\$key\\$_([, \\d]+)_\\$end\\$_\"/g,\n missing: /\"_\\$miss\\$_([^|]+)\\|(\\d+)_\\$end\\$_\": \"__missing__\"/g,\n arrayIndex: /\\s*\"_\\$idx\\$_([, \\d]+)_\\$end\\$_\",?\\n(.*)/g,\n specials: /\"\\[(NaN|Symbol.*|-?Infinity|function.*|\\(.*)]\"/g\n };\n let message = internals.safeStringify(obj, 2).replace(replacers.key, ($0, $1) => \"\\\" \".concat(redFgEscape, \"[\").concat($1, \"]\").concat(endColor)).replace(replacers.missing, ($0, $1, $2) => \"\".concat(redBgEscape, \"\\\"\").concat($1, \"\\\"\").concat(endColor).concat(redFgEscape, \" [\").concat($2, \"]: -- missing --\").concat(endColor)).replace(replacers.arrayIndex, ($0, $1, $2) => \"\\n\".concat($2, \" \").concat(redFgEscape, \"[\").concat($1, \"]\").concat(endColor)).replace(replacers.specials, ($0, $1) => $1);\n message = \"\".concat(message, \"\\n\").concat(redFgEscape);\n\n for (let i = 0; i < this.details.length; ++i) {\n const pos = i + 1;\n message = \"\".concat(message, \"\\n[\").concat(pos, \"] \").concat(this.details[i].message);\n }\n\n message = message + endColor;\n return message;\n }\n\n};\nexports.ValidationError.prototype.isJoi = true;\nexports.ValidationError.prototype.name = 'ValidationError'; // Inspired by json-stringify-safe\n\ninternals.safeStringify = function (obj, spaces) {\n return JSON.stringify(obj, internals.serializer(), spaces);\n};\n\ninternals.serializer = function () {\n const keys = [];\n const stack = [];\n\n const cycleReplacer = (key, value) => {\n if (stack[0] === value) {\n return '[Circular ~]';\n }\n\n return '[Circular ~.' + keys.slice(0, stack.indexOf(value)).join('.') + ']';\n };\n\n return function (key, value) {\n if (stack.length > 0) {\n const thisPos = stack.indexOf(this);\n\n if (~thisPos) {\n stack.length = thisPos + 1;\n keys.length = thisPos + 1;\n keys[thisPos] = key;\n } else {\n stack.push(this);\n keys.push(key);\n }\n\n if (~stack.indexOf(value)) {\n value = cycleReplacer.call(this, key, value);\n }\n } else {\n stack.push(value);\n }\n\n if (value) {\n const annotations = value[internals.annotations];\n\n if (annotations) {\n if (Array.isArray(value)) {\n const annotated = [];\n\n for (let i = 0; i < value.length; ++i) {\n if (annotations.errors[i]) {\n annotated.push(\"_$idx$_\".concat(annotations.errors[i].sort().join(', '), \"_$end$_\"));\n }\n\n annotated.push(value[i]);\n }\n\n value = annotated;\n } else {\n for (const errorKey in annotations.errors) {\n value[\"\".concat(errorKey, \"_$key$_\").concat(annotations.errors[errorKey].sort().join(', '), \"_$end$_\")] = value[errorKey];\n value[errorKey] = undefined;\n }\n\n for (const missingKey in annotations.missing) {\n value[\"_$miss$_\".concat(missingKey, \"|\").concat(annotations.missing[missingKey], \"_$end$_\")] = '__missing__';\n }\n }\n\n return value;\n }\n }\n\n if (value === Infinity || value === -Infinity || Number.isNaN(value) || typeof value === 'function' || typeof value === 'symbol') {\n return '[' + value.toString() + ']';\n }\n\n return value;\n };\n};" }, { "id": 8, @@ -1313,7 +1313,7 @@ "name": "../node_modules/@hapi/hoek/lib/utils.js", "index": 7, "index2": 5, - "size": 2869, + "size": 1153, "cacheable": true, "built": true, "optional": false, @@ -1330,8 +1330,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -1339,9 +1339,9 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/cache.js", "name": "../lib/cache.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { @@ -1349,14 +1349,14 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/clone.js", "name": "../node_modules/@hapi/hoek/lib/clone.js", "profile": { - "factory": 1052, - "building": 123 + "factory": 614, + "building": 142 } } ], "profile": { - "factory": 368, - "building": 118, + "factory": 185, + "building": 102, "dependencies": 0 }, "failed": false, @@ -1371,7 +1371,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/clone.js", "type": "cjs require", "userRequest": "./utils", - "loc": "15:12-30" + "loc": "5:14-32" }, { "moduleId": 20, @@ -1380,25 +1380,25 @@ "moduleName": "../node_modules/@hapi/hoek/lib/merge.js", "type": "cjs require", "userRequest": "./utils", - "loc": "9:12-30" + "loc": "7:14-32" }, { - "moduleId": 39, + "moduleId": 38, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/applyToDefaults.js", "module": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "moduleName": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "type": "cjs require", "userRequest": "./utils", - "loc": "11:12-30" + "loc": "9:14-32" }, { - "moduleId": 50, + "moduleId": 49, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/contain.js", "module": "../node_modules/@hapi/hoek/lib/contain.js", "moduleName": "../node_modules/@hapi/hoek/lib/contain.js", "type": "cjs require", "userRequest": "./utils", - "loc": "19:12-30" + "loc": "9:14-32" } ], "usedExports": true, @@ -1407,7 +1407,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Reach = require('./reach');\n\nvar internals = {};\n\nexports.keys = function (obj) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return options.symbols !== false ? Reflect.ownKeys(obj) : Object.getOwnPropertyNames(obj); // Defaults to true\n};\n\nexports.store = function (source, keys) {\n var storage = new Map();\n\n for (var i = 0; i < keys.length; ++i) {\n var key = keys[i];\n var value = Reach(source, key);\n\n if (_typeof(value) === 'object' || typeof value === 'function') {\n storage.set(key, value);\n internals.reachSet(source, key, undefined);\n }\n }\n\n return storage;\n};\n\nexports.restore = function (copy, source, storage) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = storage[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var _step$value = _slicedToArray(_step.value, 2),\n key = _step$value[0],\n value = _step$value[1];\n\n internals.reachSet(copy, key, value);\n internals.reachSet(source, key, value);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n};\n\ninternals.reachSet = function (obj, key, value) {\n var path = Array.isArray(key) ? key : key.split('.');\n var ref = obj;\n\n for (var i = 0; i < path.length; ++i) {\n var segment = path[i];\n\n if (i + 1 === path.length) {\n ref[segment] = value;\n }\n\n ref = ref[segment];\n }\n};" + "source": "'use strict';\n\nconst Reach = require('./reach');\n\nconst internals = {};\n\nexports.keys = function (obj) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return options.symbols !== false ? Reflect.ownKeys(obj) : Object.getOwnPropertyNames(obj); // Defaults to true\n};\n\nexports.store = function (source, keys) {\n const storage = new Map();\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n const value = Reach(source, key);\n\n if (typeof value === 'object' || typeof value === 'function') {\n storage.set(key, value);\n internals.reachSet(source, key, undefined);\n }\n }\n\n return storage;\n};\n\nexports.restore = function (copy, source, storage) {\n for (const [key, value] of storage) {\n internals.reachSet(copy, key, value);\n internals.reachSet(source, key, value);\n }\n};\n\ninternals.reachSet = function (obj, key, value) {\n const path = Array.isArray(key) ? key : key.split('.');\n let ref = obj;\n\n for (let i = 0; i < path.length; ++i) {\n const segment = path[i];\n\n if (i + 1 === path.length) {\n ref[segment] = value;\n }\n\n ref = ref[segment];\n }\n};" }, { "id": 9, @@ -1415,7 +1415,7 @@ "name": "../node_modules/@hapi/hoek/lib/reach.js", "index": 8, "index2": 4, - "size": 2576, + "size": 1660, "cacheable": true, "built": true, "optional": false, @@ -1423,34 +1423,34 @@ "chunks": [ 0 ], - "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", - "issuerId": 35, - "issuerName": "../lib/types/array.js", + "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/ref.js", + "issuerId": 5, + "issuerName": "../lib/ref.js", "issuerPath": [ { "id": 14, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 35, - "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", - "name": "../lib/types/array.js", + "id": 5, + "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/ref.js", + "name": "../lib/ref.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1026, - "building": 91, - "dependencies": 298 + "factory": 505, + "building": 170, + "dependencies": 0 }, "failed": false, "errors": 0, @@ -1464,7 +1464,7 @@ "moduleName": "../lib/ref.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/reach", - "loc": "31:12-43" + "loc": "7:14-45" }, { "moduleId": 8, @@ -1473,25 +1473,25 @@ "moduleName": "../node_modules/@hapi/hoek/lib/utils.js", "type": "cjs require", "userRequest": "./reach", - "loc": "13:12-30" + "loc": "3:14-32" }, { - "moduleId": 34, + "moduleId": 33, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/validator.js", "module": "../lib/validator.js", "moduleName": "../lib/validator.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/reach", - "loc": "27:12-43" + "loc": "7:14-45" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/reach", - "loc": "19:12-43" + "loc": "9:14-45" } ], "usedExports": true, @@ -1500,7 +1500,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('./assert');\n\nvar internals = {};\n\nmodule.exports = function (obj, chain, options) {\n if (chain === false || chain === null || chain === undefined) {\n return obj;\n }\n\n options = options || {};\n\n if (typeof options === 'string') {\n options = {\n separator: options\n };\n }\n\n var isChainArray = Array.isArray(chain);\n Assert(!isChainArray || !options.separator, 'Separator option no valid for array-based chain');\n var path = isChainArray ? chain : chain.split(options.separator || '.');\n var ref = obj;\n\n for (var i = 0; i < path.length; ++i) {\n var key = path[i];\n var type = options.iterables && internals.iterables(ref);\n\n if (Array.isArray(ref) || type === 'set') {\n var number = Number(key);\n\n if (Number.isInteger(number)) {\n key = number < 0 ? ref.length + number : number;\n }\n }\n\n if (!ref || typeof ref === 'function' && options.functions === false || // Defaults to true\n !type && ref[key] === undefined) {\n Assert(!options.strict || i + 1 === path.length, 'Missing segment', key, 'in reach path ', chain);\n Assert(_typeof(ref) === 'object' || options.functions === true || typeof ref !== 'function', 'Invalid segment', key, 'in reach path ', chain);\n ref = options.default;\n break;\n }\n\n if (!type) {\n ref = ref[key];\n } else if (type === 'set') {\n ref = _toConsumableArray(ref)[key];\n } else {\n // type === 'map'\n ref = ref.get(key);\n }\n }\n\n return ref;\n};\n\ninternals.iterables = function (ref) {\n if (ref instanceof Set) {\n return 'set';\n }\n\n if (ref instanceof Map) {\n return 'map';\n }\n};" + "source": "'use strict';\n\nconst Assert = require('./assert');\n\nconst internals = {};\n\nmodule.exports = function (obj, chain, options) {\n if (chain === false || chain === null || chain === undefined) {\n return obj;\n }\n\n options = options || {};\n\n if (typeof options === 'string') {\n options = {\n separator: options\n };\n }\n\n const isChainArray = Array.isArray(chain);\n Assert(!isChainArray || !options.separator, 'Separator option no valid for array-based chain');\n const path = isChainArray ? chain : chain.split(options.separator || '.');\n let ref = obj;\n\n for (let i = 0; i < path.length; ++i) {\n let key = path[i];\n const type = options.iterables && internals.iterables(ref);\n\n if (Array.isArray(ref) || type === 'set') {\n const number = Number(key);\n\n if (Number.isInteger(number)) {\n key = number < 0 ? ref.length + number : number;\n }\n }\n\n if (!ref || typeof ref === 'function' && options.functions === false || // Defaults to true\n !type && ref[key] === undefined) {\n Assert(!options.strict || i + 1 === path.length, 'Missing segment', key, 'in reach path ', chain);\n Assert(typeof ref === 'object' || options.functions === true || typeof ref !== 'function', 'Invalid segment', key, 'in reach path ', chain);\n ref = options.default;\n break;\n }\n\n if (!type) {\n ref = ref[key];\n } else if (type === 'set') {\n ref = [...ref][key];\n } else {\n // type === 'map'\n ref = ref.get(key);\n }\n }\n\n return ref;\n};\n\ninternals.iterables = function (ref) {\n if (ref instanceof Set) {\n return 'set';\n }\n\n if (ref instanceof Map) {\n return 'map';\n }\n};" }, { "id": 10, @@ -1508,7 +1508,7 @@ "name": "../lib/messages.js", "index": 13, "index2": 14, - "size": 4149, + "size": 3820, "cacheable": true, "built": true, "optional": false, @@ -1525,8 +1525,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -1534,16 +1534,16 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/common.js", "name": "../lib/common.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1398, - "building": 8, - "dependencies": 1 + "factory": 890, + "building": 9, + "dependencies": 0 }, "failed": false, "errors": 0, @@ -1557,7 +1557,7 @@ "moduleName": "../lib/common.js", "type": "cjs require", "userRequest": "./messages", - "loc": "145:25-46" + "loc": "127:25-46" }, { "moduleId": 19, @@ -1566,25 +1566,25 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "./messages", - "loc": "27:15-36" + "loc": "9:17-38" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./messages", - "loc": "41:15-36" + "loc": "23:17-38" }, { - "moduleId": 32, + "moduleId": 31, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/extend.js", "module": "../lib/extend.js", "moduleName": "../lib/extend.js", "type": "cjs require", "userRequest": "./messages", - "loc": "17:15-36" + "loc": "7:17-38" } ], "usedExports": true, @@ -1593,7 +1593,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Template = require('./template');\n\nvar internals = {};\n\nexports.compile = function (messages, target) {\n // Single value string ('plain error message', 'template {error} message')\n if (typeof messages === 'string') {\n Assert(!target, 'Cannot set single message string');\n return new Template(messages);\n } // Single value template\n\n\n if (Template.isTemplate(messages)) {\n Assert(!target, 'Cannot set single message template');\n return messages;\n } // By error code { 'number.min': }\n\n\n Assert(_typeof(messages) === 'object' && !Array.isArray(messages), 'Invalid message options');\n target = target ? Clone(target) : {};\n\n for (var code in messages) {\n var message = messages[code];\n\n if (code === 'root' || Template.isTemplate(message)) {\n target[code] = message;\n continue;\n }\n\n if (typeof message === 'string') {\n target[code] = new Template(message);\n continue;\n } // By language { english: { 'number.min': } }\n\n\n Assert(_typeof(message) === 'object' && !Array.isArray(message), 'Invalid message for', code);\n var language = code;\n target[language] = target[language] || {};\n\n for (code in message) {\n var localized = message[code];\n\n if (code === 'root' || Template.isTemplate(localized)) {\n target[language][code] = localized;\n continue;\n }\n\n Assert(typeof localized === 'string', 'Invalid message for', code, 'in', language);\n target[language][code] = new Template(localized);\n }\n }\n\n return target;\n};\n\nexports.decompile = function (messages) {\n // By error code { 'number.min': }\n var target = {};\n\n for (var code in messages) {\n var message = messages[code];\n\n if (code === 'root') {\n target[code] = message;\n continue;\n }\n\n if (Template.isTemplate(message)) {\n target[code] = message.describe({\n compact: true\n });\n continue;\n } // By language { english: { 'number.min': } }\n\n\n var language = code;\n target[language] = {};\n\n for (code in message) {\n var localized = message[code];\n\n if (code === 'root') {\n target[language][code] = localized;\n continue;\n }\n\n target[language][code] = localized.describe({\n compact: true\n });\n }\n }\n\n return target;\n};\n\nexports.merge = function (base, extended) {\n if (!base) {\n return exports.compile(extended);\n }\n\n if (!extended) {\n return base;\n } // Single value string\n\n\n if (typeof extended === 'string') {\n return new Template(extended);\n } // Single value template\n\n\n if (Template.isTemplate(extended)) {\n return extended;\n } // By error code { 'number.min': }\n\n\n var target = Clone(base);\n\n for (var code in extended) {\n var message = extended[code];\n\n if (code === 'root' || Template.isTemplate(message)) {\n target[code] = message;\n continue;\n }\n\n if (typeof message === 'string') {\n target[code] = new Template(message);\n continue;\n } // By language { english: { 'number.min': } }\n\n\n Assert(_typeof(message) === 'object' && !Array.isArray(message), 'Invalid message for', code);\n var language = code;\n target[language] = target[language] || {};\n\n for (code in message) {\n var localized = message[code];\n\n if (code === 'root' || Template.isTemplate(localized)) {\n target[language][code] = localized;\n continue;\n }\n\n Assert(typeof localized === 'string', 'Invalid message for', code, 'in', language);\n target[language][code] = new Template(localized);\n }\n }\n\n return target;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Template = require('./template');\n\nconst internals = {};\n\nexports.compile = function (messages, target) {\n // Single value string ('plain error message', 'template {error} message')\n if (typeof messages === 'string') {\n Assert(!target, 'Cannot set single message string');\n return new Template(messages);\n } // Single value template\n\n\n if (Template.isTemplate(messages)) {\n Assert(!target, 'Cannot set single message template');\n return messages;\n } // By error code { 'number.min': }\n\n\n Assert(typeof messages === 'object' && !Array.isArray(messages), 'Invalid message options');\n target = target ? Clone(target) : {};\n\n for (let code in messages) {\n const message = messages[code];\n\n if (code === 'root' || Template.isTemplate(message)) {\n target[code] = message;\n continue;\n }\n\n if (typeof message === 'string') {\n target[code] = new Template(message);\n continue;\n } // By language { english: { 'number.min': } }\n\n\n Assert(typeof message === 'object' && !Array.isArray(message), 'Invalid message for', code);\n const language = code;\n target[language] = target[language] || {};\n\n for (code in message) {\n const localized = message[code];\n\n if (code === 'root' || Template.isTemplate(localized)) {\n target[language][code] = localized;\n continue;\n }\n\n Assert(typeof localized === 'string', 'Invalid message for', code, 'in', language);\n target[language][code] = new Template(localized);\n }\n }\n\n return target;\n};\n\nexports.decompile = function (messages) {\n // By error code { 'number.min': }\n const target = {};\n\n for (let code in messages) {\n const message = messages[code];\n\n if (code === 'root') {\n target[code] = message;\n continue;\n }\n\n if (Template.isTemplate(message)) {\n target[code] = message.describe({\n compact: true\n });\n continue;\n } // By language { english: { 'number.min': } }\n\n\n const language = code;\n target[language] = {};\n\n for (code in message) {\n const localized = message[code];\n\n if (code === 'root') {\n target[language][code] = localized;\n continue;\n }\n\n target[language][code] = localized.describe({\n compact: true\n });\n }\n }\n\n return target;\n};\n\nexports.merge = function (base, extended) {\n if (!base) {\n return exports.compile(extended);\n }\n\n if (!extended) {\n return base;\n } // Single value string\n\n\n if (typeof extended === 'string') {\n return new Template(extended);\n } // Single value template\n\n\n if (Template.isTemplate(extended)) {\n return extended;\n } // By error code { 'number.min': }\n\n\n const target = Clone(base);\n\n for (let code in extended) {\n const message = extended[code];\n\n if (code === 'root' || Template.isTemplate(message)) {\n target[code] = message;\n continue;\n }\n\n if (typeof message === 'string') {\n target[code] = new Template(message);\n continue;\n } // By language { english: { 'number.min': } }\n\n\n Assert(typeof message === 'object' && !Array.isArray(message), 'Invalid message for', code);\n const language = code;\n target[language] = target[language] || {};\n\n for (code in message) {\n const localized = message[code];\n\n if (code === 'root' || Template.isTemplate(localized)) {\n target[language][code] = localized;\n continue;\n }\n\n Assert(typeof localized === 'string', 'Invalid message for', code, 'in', language);\n target[language][code] = new Template(localized);\n }\n }\n\n return target;\n};" }, { "id": 11, @@ -1601,7 +1601,7 @@ "name": "../lib/schemas.js", "index": 12, "index2": 9, - "size": 5717, + "size": 5721, "cacheable": true, "built": true, "optional": false, @@ -1618,15 +1618,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -1640,7 +1640,7 @@ "moduleName": "../lib/common.js", "type": "cjs require", "userRequest": "./schemas", - "loc": "77:23-43" + "loc": "59:23-43" }, { "moduleId": 14, @@ -1649,7 +1649,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./schemas", - "loc": "175:25-45" + "loc": "126:25-45" }, { "moduleId": 19, @@ -1658,7 +1658,7 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "./schemas", - "loc": "641:23-43" + "loc": "476:23-43" } ], "usedExports": true, @@ -1667,7 +1667,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar Joi = require('./index');\n\nvar internals = {}; // Preferences\n\nexports.preferences = Joi.object({\n allowUnknown: Joi.boolean(),\n abortEarly: Joi.boolean(),\n cache: Joi.boolean(),\n context: Joi.object(),\n convert: Joi.boolean(),\n dateFormat: Joi.valid('date', 'iso', 'string', 'time', 'utc'),\n errors: {\n escapeHtml: Joi.boolean(),\n language: [Joi.string(), Joi.object().ref()],\n stack: Joi.boolean(),\n wrapArrays: Joi.boolean()\n },\n externals: Joi.boolean(),\n messages: Joi.object(),\n noDefaults: Joi.boolean(),\n nonEnumerables: Joi.boolean(),\n presence: Joi.valid('required', 'optional', 'forbidden'),\n skipFunctions: Joi.boolean(),\n stripUnknown: Joi.object({\n arrays: Joi.boolean(),\n objects: Joi.boolean()\n }).or('arrays', 'objects').allow(true, false),\n warnings: Joi.boolean()\n}).strict(); // Extensions\n\ninternals.nameRx = /^[a-zA-Z0-9]+$/;\ninternals.rule = Joi.object({\n alias: Joi.array().items(Joi.string().pattern(internals.nameRx)).single(),\n method: Joi.func().allow(false),\n validate: Joi.func(),\n args: Joi.array().items(Joi.string(), Joi.object({\n name: Joi.string().pattern(internals.nameRx).required(),\n ref: Joi.boolean(),\n assert: Joi.alternatives([Joi.func(), Joi.object().schema()]).when('ref', {\n is: true,\n then: Joi.required(),\n otherwise: Joi.forbidden()\n }),\n normalize: Joi.func().when('ref', {\n is: true,\n otherwise: Joi.forbidden()\n }),\n message: Joi.string().when('assert', {\n is: Joi.object(),\n then: Joi.forbidden(),\n otherwise: Joi.required()\n })\n })),\n multi: Joi.boolean(),\n convert: Joi.boolean()\n});\nexports.extension = Joi.object({\n type: Joi.string().required(),\n args: Joi.func(),\n base: Joi.object().schema(),\n build: Joi.func().arity(2),\n coerce: Joi.func().maxArity(3),\n initialize: Joi.func().arity(1),\n messages: [Joi.object(), Joi.string()],\n modify: Joi.func().arity(3),\n rebuild: Joi.func().arity(1),\n rules: Joi.object().pattern(internals.nameRx, internals.rule),\n validate: Joi.func().maxArity(3)\n}).and('modify', 'rebuild').strict();\nexports.extensions = Joi.array().items(Joi.object(), Joi.func().arity(1)).strict(); // Manifest\n\ninternals.desc = {\n buffer: Joi.object({\n buffer: Joi.string()\n }),\n func: Joi.object({\n function: Joi.func().required(),\n options: {\n literal: true\n }\n }),\n ref: Joi.object({\n ref: Joi.object({\n type: Joi.valid('value', 'global', 'local'),\n path: Joi.array().required(),\n separator: Joi.string().length(1).allow(false),\n ancestor: Joi.number().min(0).integer().allow('root'),\n map: Joi.array().items(Joi.array().length(2)).min(1),\n adjust: Joi.func(),\n iterables: Joi.boolean()\n }).required()\n }),\n regex: Joi.object({\n regex: Joi.string().min(3)\n }),\n special: Joi.object({\n special: Joi.valid('deep').required()\n }),\n template: Joi.object({\n template: Joi.string().required(),\n options: Joi.object()\n }),\n value: Joi.object({\n value: Joi.alternatives([Joi.object(), Joi.array()]).required()\n })\n};\ninternals.desc.entity = Joi.alternatives([Joi.boolean(), Joi.func(), Joi.number(), Joi.string(), internals.desc.buffer, internals.desc.func, internals.desc.ref, internals.desc.regex, internals.desc.special, internals.desc.template, internals.desc.value, Joi.link('/')]);\ninternals.desc.values = Joi.array().items(null, Joi.boolean(), Joi.func(), Joi.number().allow(Infinity, -Infinity), Joi.string().allow(''), Joi.symbol(), internals.desc.buffer, internals.desc.func, internals.desc.ref, internals.desc.regex, internals.desc.template, internals.desc.value);\ninternals.desc.messages = Joi.object().pattern(/.+/, [Joi.string(), internals.desc.template, Joi.object().pattern(/.+/, [Joi.string(), internals.desc.template])]);\nexports.description = Joi.object({\n type: Joi.string().required(),\n flags: Joi.object({\n cast: Joi.string(),\n default: internals.desc.entity,\n description: Joi.string(),\n empty: Joi.link('/'),\n encoding: Joi.string(),\n failover: internals.desc.entity,\n format: Joi.string().valid('iso', 'javascript', 'unix'),\n id: Joi.string(),\n insensitive: Joi.boolean(),\n label: Joi.string(),\n only: true,\n presence: Joi.string().valid('optional', 'required', 'forbidden'),\n result: Joi.string().valid('raw', 'strip'),\n single: Joi.boolean(),\n sparse: Joi.boolean(),\n strip: Joi.boolean(),\n truncate: Joi.boolean(),\n unit: Joi.string(),\n unknown: true,\n unsafe: Joi.boolean()\n }).unknown(),\n preferences: {\n allowUnknown: Joi.boolean(),\n abortEarly: Joi.boolean(),\n cache: Joi.boolean(),\n convert: Joi.boolean(),\n dateFormat: Joi.valid('date', 'iso', 'string', 'time', 'utc'),\n errors: {\n escapeHtml: Joi.boolean(),\n language: [Joi.string(), internals.desc.ref],\n wrapArrays: Joi.boolean()\n },\n externals: Joi.boolean(),\n messages: internals.desc.messages,\n noDefaults: Joi.boolean(),\n nonEnumerables: Joi.boolean(),\n presence: Joi.valid('required', 'optional', 'forbidden'),\n skipFunctions: Joi.boolean(),\n stripUnknown: Joi.object({\n arrays: Joi.boolean(),\n objects: Joi.boolean()\n }).or('arrays', 'objects').allow(true, false),\n warnings: Joi.boolean()\n },\n allow: internals.desc.values,\n invalid: internals.desc.values,\n rules: Joi.array().min(1).items({\n name: Joi.string().required(),\n args: Joi.object().min(1),\n keep: Joi.boolean(),\n message: [Joi.string(), internals.desc.messages],\n warn: Joi.boolean()\n }),\n // Terms\n keys: Joi.object().pattern(/.*/, Joi.link('/')),\n link: internals.desc.ref\n}).pattern(/^[a-z]\\w*$/, Joi.any());" + "source": "'use strict';\n\nconst Joi = require('./index');\n\nconst internals = {}; // Preferences\n\nexports.preferences = Joi.object({\n allowUnknown: Joi.boolean(),\n abortEarly: Joi.boolean(),\n cache: Joi.boolean(),\n context: Joi.object(),\n convert: Joi.boolean(),\n dateFormat: Joi.valid('date', 'iso', 'string', 'time', 'utc'),\n errors: {\n escapeHtml: Joi.boolean(),\n language: [Joi.string(), Joi.object().ref()],\n stack: Joi.boolean(),\n wrapArrays: Joi.boolean()\n },\n externals: Joi.boolean(),\n messages: Joi.object(),\n noDefaults: Joi.boolean(),\n nonEnumerables: Joi.boolean(),\n presence: Joi.valid('required', 'optional', 'forbidden'),\n skipFunctions: Joi.boolean(),\n stripUnknown: Joi.object({\n arrays: Joi.boolean(),\n objects: Joi.boolean()\n }).or('arrays', 'objects').allow(true, false),\n warnings: Joi.boolean()\n}).strict(); // Extensions\n\ninternals.nameRx = /^[a-zA-Z0-9]+$/;\ninternals.rule = Joi.object({\n alias: Joi.array().items(Joi.string().pattern(internals.nameRx)).single(),\n method: Joi.func().allow(false),\n validate: Joi.func(),\n args: Joi.array().items(Joi.string(), Joi.object({\n name: Joi.string().pattern(internals.nameRx).required(),\n ref: Joi.boolean(),\n assert: Joi.alternatives([Joi.func(), Joi.object().schema()]).when('ref', {\n is: true,\n then: Joi.required(),\n otherwise: Joi.forbidden()\n }),\n normalize: Joi.func().when('ref', {\n is: true,\n otherwise: Joi.forbidden()\n }),\n message: Joi.string().when('assert', {\n is: Joi.object(),\n then: Joi.forbidden(),\n otherwise: Joi.required()\n })\n })),\n multi: Joi.boolean(),\n convert: Joi.boolean()\n});\nexports.extension = Joi.object({\n type: Joi.string().required(),\n args: Joi.func(),\n base: Joi.object().schema(),\n build: Joi.func().arity(2),\n coerce: Joi.func().maxArity(3),\n initialize: Joi.func().arity(1),\n messages: [Joi.object(), Joi.string()],\n modify: Joi.func().arity(3),\n rebuild: Joi.func().arity(1),\n rules: Joi.object().pattern(internals.nameRx, internals.rule),\n validate: Joi.func().maxArity(3)\n}).and('modify', 'rebuild').strict();\nexports.extensions = Joi.array().items(Joi.object(), Joi.func().arity(1)).strict(); // Manifest\n\ninternals.desc = {\n buffer: Joi.object({\n buffer: Joi.string()\n }),\n func: Joi.object({\n function: Joi.func().required(),\n options: {\n literal: true\n }\n }),\n ref: Joi.object({\n ref: Joi.object({\n type: Joi.valid('value', 'global', 'local'),\n path: Joi.array().required(),\n separator: Joi.string().length(1).allow(false),\n ancestor: Joi.number().min(0).integer().allow('root'),\n map: Joi.array().items(Joi.array().length(2)).min(1),\n adjust: Joi.func(),\n iterables: Joi.boolean()\n }).required()\n }),\n regex: Joi.object({\n regex: Joi.string().min(3)\n }),\n special: Joi.object({\n special: Joi.valid('deep').required()\n }),\n template: Joi.object({\n template: Joi.string().required(),\n options: Joi.object()\n }),\n value: Joi.object({\n value: Joi.alternatives([Joi.object(), Joi.array()]).required()\n })\n};\ninternals.desc.entity = Joi.alternatives([Joi.boolean(), Joi.func(), Joi.number(), Joi.string(), internals.desc.buffer, internals.desc.func, internals.desc.ref, internals.desc.regex, internals.desc.special, internals.desc.template, internals.desc.value, Joi.link('/')]);\ninternals.desc.values = Joi.array().items(null, Joi.boolean(), Joi.func(), Joi.number().allow(Infinity, -Infinity), Joi.string().allow(''), Joi.symbol(), internals.desc.buffer, internals.desc.func, internals.desc.ref, internals.desc.regex, internals.desc.template, internals.desc.value);\ninternals.desc.messages = Joi.object().pattern(/.+/, [Joi.string(), internals.desc.template, Joi.object().pattern(/.+/, [Joi.string(), internals.desc.template])]);\nexports.description = Joi.object({\n type: Joi.string().required(),\n flags: Joi.object({\n cast: Joi.string(),\n default: internals.desc.entity,\n description: Joi.string(),\n empty: Joi.link('/'),\n encoding: Joi.string(),\n failover: internals.desc.entity,\n format: Joi.string().valid('iso', 'javascript', 'unix'),\n id: Joi.string(),\n insensitive: Joi.boolean(),\n label: Joi.string(),\n only: true,\n presence: Joi.string().valid('optional', 'required', 'forbidden'),\n result: Joi.string().valid('raw', 'strip'),\n single: Joi.boolean(),\n sparse: Joi.boolean(),\n strip: Joi.boolean(),\n truncate: Joi.boolean(),\n unit: Joi.string(),\n unknown: true,\n unsafe: Joi.boolean()\n }).unknown(),\n preferences: {\n allowUnknown: Joi.boolean(),\n abortEarly: Joi.boolean(),\n cache: Joi.boolean(),\n convert: Joi.boolean(),\n dateFormat: Joi.valid('date', 'iso', 'string', 'time', 'utc'),\n errors: {\n escapeHtml: Joi.boolean(),\n language: [Joi.string(), internals.desc.ref],\n wrapArrays: Joi.boolean()\n },\n externals: Joi.boolean(),\n messages: internals.desc.messages,\n noDefaults: Joi.boolean(),\n nonEnumerables: Joi.boolean(),\n presence: Joi.valid('required', 'optional', 'forbidden'),\n skipFunctions: Joi.boolean(),\n stripUnknown: Joi.object({\n arrays: Joi.boolean(),\n objects: Joi.boolean()\n }).or('arrays', 'objects').allow(true, false),\n warnings: Joi.boolean()\n },\n allow: internals.desc.values,\n invalid: internals.desc.values,\n rules: Joi.array().min(1).items({\n name: Joi.string().required(),\n args: Joi.object().min(1),\n keep: Joi.boolean(),\n message: [Joi.string(), internals.desc.messages],\n warn: Joi.boolean()\n }),\n // Terms\n keys: Joi.object().pattern(/.*/, Joi.link('/')),\n link: internals.desc.ref\n}).pattern(/^[a-z]\\w*$/, Joi.any());" }, { "id": 12, @@ -1675,7 +1675,7 @@ "name": "../node_modules/@hapi/hoek/lib/deepEqual.js", "index": 24, "index2": 20, - "size": 11569, + "size": 6172, "cacheable": true, "built": true, "optional": false, @@ -1684,7 +1684,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", - "issuerId": 35, + "issuerId": 34, "issuerName": "../lib/types/array.js", "issuerPath": [ { @@ -1692,25 +1692,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 35, + "id": 34, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "name": "../lib/types/array.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1026, - "building": 91, - "dependencies": 298 + "factory": 574, + "building": 43, + "dependencies": 24 }, "failed": false, "errors": 0, @@ -1718,31 +1718,31 @@ "assets": [], "reasons": [ { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/deepEqual", - "loc": "25:16-51" + "loc": "7:18-53" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/deepEqual", - "loc": "17:16-51" + "loc": "7:18-53" }, { - "moduleId": 50, + "moduleId": 49, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/contain.js", "module": "../node_modules/@hapi/hoek/lib/contain.js", "moduleName": "../node_modules/@hapi/hoek/lib/contain.js", "type": "cjs require", "userRequest": "./deepEqual", - "loc": "15:16-38" + "loc": "5:18-40" } ], "usedExports": true, @@ -1751,15 +1751,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Types = require('./types');\n\nvar internals = {\n mismatched: null\n};\n\nmodule.exports = function (obj, ref, options) {\n options = Object.assign({\n prototype: true\n }, options);\n return !!internals.isDeepEqual(obj, ref, options, []);\n};\n\ninternals.isDeepEqual = function (obj, ref, options, seen) {\n if (obj === ref) {\n // Copied from Deep-eql, copyright(c) 2013 Jake Luer, jake@alogicalparadox.com, MIT Licensed, https://github.com/chaijs/deep-eql\n return obj !== 0 || 1 / obj === 1 / ref;\n }\n\n var type = _typeof(obj);\n\n if (type !== _typeof(ref)) {\n return false;\n }\n\n if (obj === null || ref === null) {\n return false;\n }\n\n if (type === 'function') {\n if (!options.deepFunction || obj.toString() !== ref.toString()) {\n return false;\n } // Continue as object\n\n } else if (type !== 'object') {\n return obj !== obj && ref !== ref; // NaN\n }\n\n var instanceType = internals.getSharedType(obj, ref, !!options.prototype);\n\n switch (instanceType) {\n case Types.buffer:\n return Buffer && Buffer.prototype.equals.call(obj, ref);\n // $lab:coverage:ignore$\n\n case Types.promise:\n return obj === ref;\n\n case Types.regex:\n return obj.toString() === ref.toString();\n\n case internals.mismatched:\n return false;\n }\n\n for (var i = seen.length - 1; i >= 0; --i) {\n if (seen[i].isSame(obj, ref)) {\n return true; // If previous comparison failed, it would have stopped execution\n }\n }\n\n seen.push(new internals.SeenEntry(obj, ref));\n\n try {\n return !!internals.isDeepEqualObj(instanceType, obj, ref, options, seen);\n } finally {\n seen.pop();\n }\n};\n\ninternals.getSharedType = function (obj, ref, checkPrototype) {\n if (checkPrototype) {\n if (Object.getPrototypeOf(obj) !== Object.getPrototypeOf(ref)) {\n return internals.mismatched;\n }\n\n return Types.getInternalProto(obj);\n }\n\n var type = Types.getInternalProto(obj);\n\n if (type !== Types.getInternalProto(ref)) {\n return internals.mismatched;\n }\n\n return type;\n};\n\ninternals.valueOf = function (obj) {\n var objValueOf = obj.valueOf;\n\n if (objValueOf === undefined) {\n return obj;\n }\n\n try {\n return objValueOf.call(obj);\n } catch (err) {\n return err;\n }\n};\n\ninternals.hasOwnEnumerableProperty = function (obj, key) {\n return Object.prototype.propertyIsEnumerable.call(obj, key);\n};\n\ninternals.isSetSimpleEqual = function (obj, ref) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = obj[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var entry = _step.value;\n\n if (!ref.has(entry)) {\n return false;\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return true;\n};\n\ninternals.isDeepEqualObj = function (instanceType, obj, ref, options, seen) {\n var isDeepEqual = internals.isDeepEqual,\n valueOf = internals.valueOf,\n hasOwnEnumerableProperty = internals.hasOwnEnumerableProperty;\n var keys = Object.keys,\n getOwnPropertySymbols = Object.getOwnPropertySymbols;\n\n if (instanceType === Types.array) {\n if (options.part) {\n // Check if any index match any other index\n for (var i = 0; i < obj.length; ++i) {\n var objValue = obj[i];\n\n for (var j = 0; j < ref.length; ++j) {\n if (isDeepEqual(objValue, ref[j], options, seen)) {\n return true;\n }\n }\n }\n } else {\n if (obj.length !== ref.length) {\n return false;\n }\n\n for (var _i = 0; _i < obj.length; ++_i) {\n if (!isDeepEqual(obj[_i], ref[_i], options, seen)) {\n return false;\n }\n }\n\n return true;\n }\n } else if (instanceType === Types.set) {\n if (obj.size !== ref.size) {\n return false;\n }\n\n if (!internals.isSetSimpleEqual(obj, ref)) {\n // Check for deep equality\n var ref2 = new Set(ref);\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = obj[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var objEntry = _step2.value;\n\n if (ref2.delete(objEntry)) {\n continue;\n }\n\n var found = false;\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = ref2[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var refEntry = _step3.value;\n\n if (isDeepEqual(objEntry, refEntry, options, seen)) {\n ref2.delete(refEntry);\n found = true;\n break;\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n if (!found) {\n return false;\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n } else if (instanceType === Types.map) {\n if (obj.size !== ref.size) {\n return false;\n }\n\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = obj[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var _step4$value = _slicedToArray(_step4.value, 2),\n key = _step4$value[0],\n value = _step4$value[1];\n\n if (value === undefined && !ref.has(key)) {\n return false;\n }\n\n if (!isDeepEqual(value, ref.get(key), options, seen)) {\n return false;\n }\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n } else if (instanceType === Types.error) {\n // Always check name and message\n if (obj.name !== ref.name || obj.message !== ref.message) {\n return false;\n }\n } // Check .valueOf()\n\n\n var valueOfObj = valueOf(obj);\n var valueOfRef = valueOf(ref);\n\n if (!(obj === valueOfObj && ref === valueOfRef) && !isDeepEqual(valueOfObj, valueOfRef, options, seen)) {\n return false;\n } // Check properties\n\n\n var objKeys = keys(obj);\n\n if (!options.part && objKeys.length !== keys(ref).length) {\n return false;\n }\n\n for (var _i2 = 0; _i2 < objKeys.length; ++_i2) {\n var key = objKeys[_i2];\n\n if (!hasOwnEnumerableProperty(ref, key)) {\n return false;\n }\n\n if (options.skip && options.skip.includes(key)) {\n continue;\n }\n\n if (!isDeepEqual(obj[key], ref[key], options, seen)) {\n return false;\n }\n } // Check symbols\n\n\n if (options.symbols !== false) {\n // Defaults to true\n var objSymbols = getOwnPropertySymbols(obj);\n var refSymbols = new Set(getOwnPropertySymbols(ref));\n\n for (var _i3 = 0; _i3 < objSymbols.length; ++_i3) {\n var _key = objSymbols[_i3];\n\n if (hasOwnEnumerableProperty(obj, _key)) {\n if (!hasOwnEnumerableProperty(ref, _key)) {\n return false;\n }\n\n if (!(options.skip && options.skip.includes(_key)) && !isDeepEqual(obj[_key], ref[_key], options, seen)) {\n return false;\n }\n } else if (hasOwnEnumerableProperty(ref, _key)) {\n return false;\n }\n\n refSymbols.delete(_key);\n }\n\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = refSymbols[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var _key2 = _step5.value;\n\n if (hasOwnEnumerableProperty(ref, _key2)) {\n return false;\n }\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n }\n\n return true;\n};\n\ninternals.SeenEntry =\n/*#__PURE__*/\nfunction () {\n function _class(obj, ref) {\n _classCallCheck(this, _class);\n\n this.obj = obj;\n this.ref = ref;\n }\n\n _createClass(_class, [{\n key: \"isSame\",\n value: function isSame(obj, ref) {\n return this.obj === obj && this.ref === ref;\n }\n }]);\n\n return _class;\n}();" + "source": "'use strict';\n\nconst Types = require('./types');\n\nconst internals = {\n mismatched: null\n};\n\nmodule.exports = function (obj, ref, options) {\n options = Object.assign({\n prototype: true\n }, options);\n return !!internals.isDeepEqual(obj, ref, options, []);\n};\n\ninternals.isDeepEqual = function (obj, ref, options, seen) {\n if (obj === ref) {\n // Copied from Deep-eql, copyright(c) 2013 Jake Luer, jake@alogicalparadox.com, MIT Licensed, https://github.com/chaijs/deep-eql\n return obj !== 0 || 1 / obj === 1 / ref;\n }\n\n const type = typeof obj;\n\n if (type !== typeof ref) {\n return false;\n }\n\n if (obj === null || ref === null) {\n return false;\n }\n\n if (type === 'function') {\n if (!options.deepFunction || obj.toString() !== ref.toString()) {\n return false;\n } // Continue as object\n\n } else if (type !== 'object') {\n return obj !== obj && ref !== ref; // NaN\n }\n\n const instanceType = internals.getSharedType(obj, ref, !!options.prototype);\n\n switch (instanceType) {\n case Types.buffer:\n return Buffer && Buffer.prototype.equals.call(obj, ref);\n // $lab:coverage:ignore$\n\n case Types.promise:\n return obj === ref;\n\n case Types.regex:\n return obj.toString() === ref.toString();\n\n case internals.mismatched:\n return false;\n }\n\n for (let i = seen.length - 1; i >= 0; --i) {\n if (seen[i].isSame(obj, ref)) {\n return true; // If previous comparison failed, it would have stopped execution\n }\n }\n\n seen.push(new internals.SeenEntry(obj, ref));\n\n try {\n return !!internals.isDeepEqualObj(instanceType, obj, ref, options, seen);\n } finally {\n seen.pop();\n }\n};\n\ninternals.getSharedType = function (obj, ref, checkPrototype) {\n if (checkPrototype) {\n if (Object.getPrototypeOf(obj) !== Object.getPrototypeOf(ref)) {\n return internals.mismatched;\n }\n\n return Types.getInternalProto(obj);\n }\n\n const type = Types.getInternalProto(obj);\n\n if (type !== Types.getInternalProto(ref)) {\n return internals.mismatched;\n }\n\n return type;\n};\n\ninternals.valueOf = function (obj) {\n const objValueOf = obj.valueOf;\n\n if (objValueOf === undefined) {\n return obj;\n }\n\n try {\n return objValueOf.call(obj);\n } catch (err) {\n return err;\n }\n};\n\ninternals.hasOwnEnumerableProperty = function (obj, key) {\n return Object.prototype.propertyIsEnumerable.call(obj, key);\n};\n\ninternals.isSetSimpleEqual = function (obj, ref) {\n for (const entry of obj) {\n if (!ref.has(entry)) {\n return false;\n }\n }\n\n return true;\n};\n\ninternals.isDeepEqualObj = function (instanceType, obj, ref, options, seen) {\n const {\n isDeepEqual,\n valueOf,\n hasOwnEnumerableProperty\n } = internals;\n const {\n keys,\n getOwnPropertySymbols\n } = Object;\n\n if (instanceType === Types.array) {\n if (options.part) {\n // Check if any index match any other index\n for (let i = 0; i < obj.length; ++i) {\n const objValue = obj[i];\n\n for (let j = 0; j < ref.length; ++j) {\n if (isDeepEqual(objValue, ref[j], options, seen)) {\n return true;\n }\n }\n }\n } else {\n if (obj.length !== ref.length) {\n return false;\n }\n\n for (let i = 0; i < obj.length; ++i) {\n if (!isDeepEqual(obj[i], ref[i], options, seen)) {\n return false;\n }\n }\n\n return true;\n }\n } else if (instanceType === Types.set) {\n if (obj.size !== ref.size) {\n return false;\n }\n\n if (!internals.isSetSimpleEqual(obj, ref)) {\n // Check for deep equality\n const ref2 = new Set(ref);\n\n for (const objEntry of obj) {\n if (ref2.delete(objEntry)) {\n continue;\n }\n\n let found = false;\n\n for (const refEntry of ref2) {\n if (isDeepEqual(objEntry, refEntry, options, seen)) {\n ref2.delete(refEntry);\n found = true;\n break;\n }\n }\n\n if (!found) {\n return false;\n }\n }\n }\n } else if (instanceType === Types.map) {\n if (obj.size !== ref.size) {\n return false;\n }\n\n for (const [key, value] of obj) {\n if (value === undefined && !ref.has(key)) {\n return false;\n }\n\n if (!isDeepEqual(value, ref.get(key), options, seen)) {\n return false;\n }\n }\n } else if (instanceType === Types.error) {\n // Always check name and message\n if (obj.name !== ref.name || obj.message !== ref.message) {\n return false;\n }\n } // Check .valueOf()\n\n\n const valueOfObj = valueOf(obj);\n const valueOfRef = valueOf(ref);\n\n if (!(obj === valueOfObj && ref === valueOfRef) && !isDeepEqual(valueOfObj, valueOfRef, options, seen)) {\n return false;\n } // Check properties\n\n\n const objKeys = keys(obj);\n\n if (!options.part && objKeys.length !== keys(ref).length) {\n return false;\n }\n\n for (let i = 0; i < objKeys.length; ++i) {\n const key = objKeys[i];\n\n if (!hasOwnEnumerableProperty(ref, key)) {\n return false;\n }\n\n if (options.skip && options.skip.includes(key)) {\n continue;\n }\n\n if (!isDeepEqual(obj[key], ref[key], options, seen)) {\n return false;\n }\n } // Check symbols\n\n\n if (options.symbols !== false) {\n // Defaults to true\n const objSymbols = getOwnPropertySymbols(obj);\n const refSymbols = new Set(getOwnPropertySymbols(ref));\n\n for (let i = 0; i < objSymbols.length; ++i) {\n const key = objSymbols[i];\n\n if (hasOwnEnumerableProperty(obj, key)) {\n if (!hasOwnEnumerableProperty(ref, key)) {\n return false;\n }\n\n if (!(options.skip && options.skip.includes(key)) && !isDeepEqual(obj[key], ref[key], options, seen)) {\n return false;\n }\n } else if (hasOwnEnumerableProperty(ref, key)) {\n return false;\n }\n\n refSymbols.delete(key);\n }\n\n for (const key of refSymbols) {\n if (hasOwnEnumerableProperty(ref, key)) {\n return false;\n }\n }\n }\n\n return true;\n};\n\ninternals.SeenEntry = class {\n constructor(obj, ref) {\n this.obj = obj;\n this.ref = ref;\n }\n\n isSame(obj, ref) {\n return this.obj === obj && this.ref === ref;\n }\n\n};" }, { "id": 13, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/escapeRegex.js", "name": "../node_modules/@hapi/hoek/lib/escapeRegex.js", - "index": 48, - "index2": 46, - "size": 188, + "index": 47, + "index2": 45, + "size": 190, "cacheable": true, "built": true, "optional": false, @@ -1768,7 +1768,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", - "issuerId": 43, + "issuerId": 42, "issuerName": "../lib/types/string/index.js", "issuerPath": [ { @@ -1776,25 +1776,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 }, "failed": false, "errors": 0, @@ -1802,31 +1802,31 @@ "assets": [], "reasons": [ { - "moduleId": 25, + "moduleId": 24, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/uri.js", "module": "../lib/types/string/uri.js", "moduleName": "../lib/types/string/uri.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/escapeRegex", - "loc": "5:18-55" + "loc": "5:20-57" }, { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/escapeRegex", - "loc": "15:18-55" + "loc": "13:20-57" }, { - "moduleId": 50, + "moduleId": 49, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/contain.js", "module": "../node_modules/@hapi/hoek/lib/contain.js", "moduleName": "../node_modules/@hapi/hoek/lib/contain.js", "type": "cjs require", "userRequest": "./escapeRegex", - "loc": "17:18-42" + "loc": "7:20-44" } ], "usedExports": true, @@ -1835,15 +1835,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nvar internals = {};\n\nmodule.exports = function (string) {\n // Escape ^$.*+-?=!:|\\/()[]{},\n return string.replace(/[\\^\\$\\.\\*\\+\\-\\?\\=\\!\\:\\|\\\\\\/\\(\\)\\[\\]\\{\\}\\,]/g, '\\\\$&');\n};" + "source": "'use strict';\n\nconst internals = {};\n\nmodule.exports = function (string) {\n // Escape ^$.*+-?=!:|\\/()[]{},\n return string.replace(/[\\^\\$\\.\\*\\+\\-\\?\\=\\!\\:\\|\\\\\\/\\(\\)\\[\\]\\{\\}\\,]/g, '\\\\$&');\n};" }, { "id": 14, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "index": 0, - "index2": 53, - "size": 8203, + "index2": 52, + "size": 5044, "cacheable": true, "built": true, "optional": false, @@ -1856,8 +1856,8 @@ "issuerName": null, "issuerPath": null, "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 }, "failed": false, "errors": 0, @@ -1871,7 +1871,7 @@ "moduleName": "../lib/schemas.js", "type": "cjs require", "userRequest": "./index", - "loc": "3:10-28" + "loc": "3:12-30" }, { "moduleId": null, @@ -1889,7 +1889,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 0, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Cache = require('./cache');\n\nvar Common = require('./common');\n\nvar Compile = require('./compile');\n\nvar Errors = require('./errors');\n\nvar Manifest = require('./manifest');\n\nvar Ref = require('./ref');\n\nvar Template = require('./template');\n\nvar Pkg = require('../package.json');\n\nvar Schemas;\nvar internals = {\n types: {\n alternatives: require('./types/alternatives'),\n any: require('./types/any'),\n array: require('./types/array'),\n boolean: require('./types/boolean'),\n date: require('./types/date'),\n function: require('./types/function'),\n link: require('./types/link'),\n number: require('./types/number'),\n object: require('./types/object'),\n string: require('./types/string'),\n symbol: require('./types/symbol')\n }\n};\n\nif (Buffer) {\n // $lab:coverage:ignore$\n internals.types.binary = require('./types/binary');\n}\n\ninternals.root = function () {\n var root = {\n _types: new Set(Object.keys(internals.types))\n }; // Types\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n var _loop = function _loop() {\n var type = _step.value;\n\n root[type] = function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n Assert(!args.length || ['alternatives', 'link', 'object'].includes(type), 'The', type, 'type does not allow arguments');\n return internals.generate(this, internals.types[type], args);\n };\n };\n\n for (var _iterator = root._types[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n _loop();\n } // Shortcuts\n\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n var _loop2 = function _loop2() {\n var method = _arr[_i];\n\n root[method] = function () {\n var _this$any;\n\n return (_this$any = this.any())[method].apply(_this$any, arguments);\n };\n };\n\n for (var _i = 0, _arr = ['allow', 'disallow', 'equal', 'exist', 'forbidden', 'invalid', 'not', 'optional', 'options', 'prefs', 'preferences', 'required', 'valid', 'when']; _i < _arr.length; _i++) {\n _loop2();\n } // Methods\n\n\n Object.assign(root, internals.methods); // Aliases\n\n root.alt = root.alternatives;\n root.attempt = root.assert;\n root.bool = root.boolean;\n root.func = root.function;\n root.x = root.expression;\n return root;\n};\n\ninternals.methods = {\n ValidationError: Errors.ValidationError,\n version: Pkg.version,\n cache: Cache.provider,\n assert: function assert(value, schema)\n /* [message], [options]*/\n {\n var first = arguments.length <= 2 ? undefined : arguments[2];\n var message = first instanceof Error || typeof first === 'string' ? first : null;\n var options = message ? arguments.length <= 3 ? undefined : arguments[3] : arguments.length <= 2 ? undefined : arguments[2];\n var result = schema.validate(value, options);\n var error = result.error;\n\n if (!error) {\n return result.value;\n }\n\n if (message instanceof Error) {\n throw message;\n }\n\n if (typeof error.annotate === 'function') {\n error.message = message ? \"\".concat(message, \" \").concat(error.annotate()) : error.annotate();\n }\n\n throw error;\n },\n build: function build(desc) {\n return Manifest.build(this, desc);\n },\n checkPreferences: function checkPreferences(prefs) {\n Common.checkPreferences(prefs);\n },\n compile: function compile(schema, options) {\n return Compile.compile(this, schema, options);\n },\n expression: function expression() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n return _construct(Template, args);\n },\n extend: function extend() {\n var _this = this;\n\n for (var _len3 = arguments.length, extensions = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n extensions[_key3] = arguments[_key3];\n }\n\n Common.verifyFlat(extensions, 'extend');\n Schemas = Schemas || require('./schemas');\n Assert(extensions.length, 'You need to provide at least one extension');\n this.assert(extensions, Schemas.extensions);\n var joi = Object.assign({}, this);\n joi._types = new Set(joi._types);\n\n var _loop3 = function _loop3() {\n var extension = _extensions[_i2];\n\n if (typeof extension === 'function') {\n extension = extension(joi);\n }\n\n _this.assert(extension, Schemas.extension);\n\n var base = extension.base || _this.any();\n\n var schema = base.extend(extension);\n\n joi._types.add(extension.type);\n\n joi[extension.type] = function () {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n\n return internals.generate(this, schema, args);\n };\n };\n\n for (var _i2 = 0, _extensions = extensions; _i2 < _extensions.length; _i2++) {\n _loop3();\n }\n\n return joi;\n },\n isExpression: Template.isTemplate,\n isRef: Ref.isRef,\n isSchema: Common.isSchema,\n ref: function ref() {\n return Ref.create.apply(Ref, arguments);\n },\n types: function types() {\n var types = {};\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = this._types[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var type = _step2.value;\n types[type] = this[type]();\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return types;\n }\n}; // Helpers\n\ninternals.generate = function (root, schema, args) {\n var _schema$_definition;\n\n Assert(root, 'Must be invoked on a Joi instance.');\n schema._root = root;\n\n if (!schema._definition.args || !args.length) {\n return schema;\n }\n\n return (_schema$_definition = schema._definition).args.apply(_schema$_definition, [schema].concat(_toConsumableArray(args)));\n};\n\nmodule.exports = internals.root();" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Cache = require('./cache');\n\nconst Common = require('./common');\n\nconst Compile = require('./compile');\n\nconst Errors = require('./errors');\n\nconst Manifest = require('./manifest');\n\nconst Ref = require('./ref');\n\nconst Template = require('./template');\n\nconst Pkg = require('../package.json');\n\nlet Schemas;\nconst internals = {\n types: {\n alternatives: require('./types/alternatives'),\n any: require('./types/any'),\n array: require('./types/array'),\n boolean: require('./types/boolean'),\n date: require('./types/date'),\n function: require('./types/function'),\n link: require('./types/link'),\n number: require('./types/number'),\n object: require('./types/object'),\n string: require('./types/string'),\n symbol: require('./types/symbol')\n }\n};\n\nif (Buffer) {\n // $lab:coverage:ignore$\n internals.types.binary = require('./types/binary');\n}\n\ninternals.root = function () {\n const root = {\n _types: new Set(Object.keys(internals.types))\n }; // Types\n\n for (const type of root._types) {\n root[type] = function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n Assert(!args.length || ['alternatives', 'link', 'object'].includes(type), 'The', type, 'type does not allow arguments');\n return internals.generate(this, internals.types[type], args);\n };\n } // Shortcuts\n\n\n for (const method of ['allow', 'disallow', 'equal', 'exist', 'forbidden', 'invalid', 'not', 'optional', 'options', 'prefs', 'preferences', 'required', 'valid', 'when']) {\n root[method] = function () {\n return this.any()[method](...arguments);\n };\n } // Methods\n\n\n Object.assign(root, internals.methods); // Aliases\n\n root.alt = root.alternatives;\n root.attempt = root.assert;\n root.bool = root.boolean;\n root.func = root.function;\n root.x = root.expression;\n return root;\n};\n\ninternals.methods = {\n ValidationError: Errors.ValidationError,\n version: Pkg.version,\n cache: Cache.provider,\n assert: function assert(value, schema)\n /* [message], [options]*/\n {\n const first = arguments.length <= 2 ? undefined : arguments[2];\n const message = first instanceof Error || typeof first === 'string' ? first : null;\n const options = message ? arguments.length <= 3 ? undefined : arguments[3] : arguments.length <= 2 ? undefined : arguments[2];\n const result = schema.validate(value, options);\n const error = result.error;\n\n if (!error) {\n return result.value;\n }\n\n if (message instanceof Error) {\n throw message;\n }\n\n if (typeof error.annotate === 'function') {\n error.message = message ? \"\".concat(message, \" \").concat(error.annotate()) : error.annotate();\n }\n\n throw error;\n },\n build: function build(desc) {\n return Manifest.build(this, desc);\n },\n checkPreferences: function checkPreferences(prefs) {\n Common.checkPreferences(prefs);\n },\n compile: function compile(schema, options) {\n return Compile.compile(this, schema, options);\n },\n expression: function expression() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n return new Template(...args);\n },\n extend: function extend() {\n for (var _len3 = arguments.length, extensions = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n extensions[_key3] = arguments[_key3];\n }\n\n Common.verifyFlat(extensions, 'extend');\n Schemas = Schemas || require('./schemas');\n Assert(extensions.length, 'You need to provide at least one extension');\n this.assert(extensions, Schemas.extensions);\n const joi = Object.assign({}, this);\n joi._types = new Set(joi._types);\n\n for (let extension of extensions) {\n if (typeof extension === 'function') {\n extension = extension(joi);\n }\n\n this.assert(extension, Schemas.extension);\n const base = extension.base || this.any();\n const schema = base.extend(extension);\n\n joi._types.add(extension.type);\n\n joi[extension.type] = function () {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n\n return internals.generate(this, schema, args);\n };\n }\n\n return joi;\n },\n isExpression: Template.isTemplate,\n isRef: Ref.isRef,\n isSchema: Common.isSchema,\n ref: function ref() {\n return Ref.create(...arguments);\n },\n types: function types() {\n const types = {};\n\n for (const type of this._types) {\n types[type] = this[type]();\n }\n\n return types;\n }\n}; // Helpers\n\ninternals.generate = function (root, schema, args) {\n Assert(root, 'Must be invoked on a Joi instance.');\n schema._root = root;\n\n if (!schema._definition.args || !args.length) {\n return schema;\n }\n\n return schema._definition.args(schema, ...args);\n};\n\nmodule.exports = internals.root();" }, { "id": 15, @@ -1897,7 +1897,7 @@ "name": "../node_modules/@hapi/hoek/lib/error.js", "index": 2, "index2": 1, - "size": 3928, + "size": 412, "cacheable": true, "built": true, "optional": false, @@ -1914,8 +1914,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -1923,16 +1923,16 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/common.js", "name": "../lib/common.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1398, - "building": 8, - "dependencies": 1 + "factory": 890, + "building": 9, + "dependencies": 0 }, "failed": false, "errors": 0, @@ -1946,7 +1946,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/assert.js", "type": "cjs require", "userRequest": "./error", - "loc": "3:18-36" + "loc": "3:20-38" }, { "moduleId": 1, @@ -1955,7 +1955,7 @@ "moduleName": "../lib/common.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/error", - "loc": "21:18-49" + "loc": "5:20-51" } ], "usedExports": true, @@ -1964,7 +1964,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nvar Stringify = require('./stringify');\n\nvar internals = {};\n\nmodule.exports =\n/*#__PURE__*/\nfunction (_Error) {\n _inherits(_class, _Error);\n\n function _class(args) {\n var _this;\n\n _classCallCheck(this, _class);\n\n var msgs = args.filter(function (arg) {\n return arg !== '';\n }).map(function (arg) {\n return typeof arg === 'string' ? arg : arg instanceof Error ? arg.message : Stringify(arg);\n });\n _this = _possibleConstructorReturn(this, _getPrototypeOf(_class).call(this, msgs.join(' ') || 'Unknown error'));\n Error.captureStackTrace(_assertThisInitialized(_this), exports.assert);\n return _this;\n }\n\n return _class;\n}(_wrapNativeSuper(Error));" + "source": "'use strict';\n\nconst Stringify = require('./stringify');\n\nconst internals = {};\nmodule.exports = class extends Error {\n constructor(args) {\n const msgs = args.filter(arg => arg !== '').map(arg => {\n return typeof arg === 'string' ? arg : arg instanceof Error ? arg.message : Stringify(arg);\n });\n super(msgs.join(' ') || 'Unknown error');\n Error.captureStackTrace(this, exports.assert);\n }\n\n};" }, { "id": 16, @@ -1972,7 +1972,7 @@ "name": "../lib/cache.js", "index": 4, "index2": 16, - "size": 4047, + "size": 2329, "cacheable": true, "built": true, "optional": false, @@ -1989,15 +1989,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -2011,16 +2011,16 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./cache", - "loc": "19:12-30" + "loc": "5:14-32" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./cache", - "loc": "29:12-30" + "loc": "11:14-32" } ], "usedExports": true, @@ -2029,7 +2029,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Common = require('./common');\n\nvar internals = {\n max: 1000,\n supported: new Set(['undefined', 'boolean', 'number', 'string'])\n};\nexports.provider = {\n provision: function provision(options) {\n return new internals.Cache(options);\n }\n}; // Least Recently Used (LRU) Cache\n\ninternals.Cache =\n/*#__PURE__*/\nfunction () {\n function _class() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n _classCallCheck(this, _class);\n\n Common.assertOptions(options, ['max']);\n Assert(options.max === undefined || options.max && options.max > 0 && isFinite(options.max), 'Invalid max cache size');\n this._max = options.max || internals.max;\n this._map = new Map(); // Map of nodes by key\n\n this._list = new internals.List(); // List of nodes (most recently used in head)\n }\n\n _createClass(_class, [{\n key: \"set\",\n value: function set(key, value) {\n if (key !== null && !internals.supported.has(_typeof(key))) {\n return;\n }\n\n var node = this._map.get(key);\n\n if (node) {\n node.value = value;\n\n this._list.first(node);\n\n return;\n }\n\n node = this._list.unshift({\n key: key,\n value: value\n });\n\n this._map.set(key, node);\n\n this._compact();\n }\n }, {\n key: \"get\",\n value: function get(key) {\n var node = this._map.get(key);\n\n if (node) {\n this._list.first(node);\n\n return Clone(node.value);\n }\n }\n }, {\n key: \"_compact\",\n value: function _compact() {\n if (this._map.size > this._max) {\n var node = this._list.pop();\n\n this._map.delete(node.key);\n }\n }\n }, {\n key: \"length\",\n get: function get() {\n return this._map.size;\n }\n }]);\n\n return _class;\n}();\n\ninternals.List =\n/*#__PURE__*/\nfunction () {\n function _class2() {\n _classCallCheck(this, _class2);\n\n this.tail = null;\n this.head = null;\n }\n\n _createClass(_class2, [{\n key: \"unshift\",\n value: function unshift(node) {\n node.next = null;\n node.prev = this.head;\n\n if (this.head) {\n this.head.next = node;\n }\n\n this.head = node;\n\n if (!this.tail) {\n this.tail = node;\n }\n\n return node;\n }\n }, {\n key: \"first\",\n value: function first(node) {\n if (node === this.head) {\n return;\n }\n\n this._remove(node);\n\n this.unshift(node);\n }\n }, {\n key: \"pop\",\n value: function pop() {\n return this._remove(this.tail);\n }\n }, {\n key: \"_remove\",\n value: function _remove(node) {\n var next = node.next,\n prev = node.prev;\n next.prev = prev;\n\n if (prev) {\n prev.next = next;\n }\n\n if (node === this.tail) {\n this.tail = next;\n }\n\n node.prev = null;\n node.next = null;\n return node;\n }\n }]);\n\n return _class2;\n}();" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Common = require('./common');\n\nconst internals = {\n max: 1000,\n supported: new Set(['undefined', 'boolean', 'number', 'string'])\n};\nexports.provider = {\n provision: function provision(options) {\n return new internals.Cache(options);\n }\n}; // Least Recently Used (LRU) Cache\n\ninternals.Cache = class {\n constructor() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['max']);\n Assert(options.max === undefined || options.max && options.max > 0 && isFinite(options.max), 'Invalid max cache size');\n this._max = options.max || internals.max;\n this._map = new Map(); // Map of nodes by key\n\n this._list = new internals.List(); // List of nodes (most recently used in head)\n }\n\n get length() {\n return this._map.size;\n }\n\n set(key, value) {\n if (key !== null && !internals.supported.has(typeof key)) {\n return;\n }\n\n let node = this._map.get(key);\n\n if (node) {\n node.value = value;\n\n this._list.first(node);\n\n return;\n }\n\n node = this._list.unshift({\n key,\n value\n });\n\n this._map.set(key, node);\n\n this._compact();\n }\n\n get(key) {\n const node = this._map.get(key);\n\n if (node) {\n this._list.first(node);\n\n return Clone(node.value);\n }\n }\n\n _compact() {\n if (this._map.size > this._max) {\n const node = this._list.pop();\n\n this._map.delete(node.key);\n }\n }\n\n};\ninternals.List = class {\n constructor() {\n this.tail = null;\n this.head = null;\n }\n\n unshift(node) {\n node.next = null;\n node.prev = this.head;\n\n if (this.head) {\n this.head.next = node;\n }\n\n this.head = node;\n\n if (!this.tail) {\n this.tail = node;\n }\n\n return node;\n }\n\n first(node) {\n if (node === this.head) {\n return;\n }\n\n this._remove(node);\n\n this.unshift(node);\n }\n\n pop() {\n return this._remove(this.tail);\n }\n\n _remove(node) {\n const {\n next,\n prev\n } = node;\n next.prev = prev;\n\n if (prev) {\n prev.next = next;\n }\n\n if (node === this.tail) {\n this.tail = next;\n }\n\n node.prev = null;\n node.next = null;\n return node;\n }\n\n};" }, { "id": 17, @@ -2037,7 +2037,7 @@ "name": "../node_modules/@hapi/hoek/lib/types.js", "index": 6, "index2": 3, - "size": 1084, + "size": 1088, "cacheable": true, "built": true, "optional": false, @@ -2054,8 +2054,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -2063,9 +2063,9 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/cache.js", "name": "../lib/cache.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { @@ -2073,14 +2073,14 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/clone.js", "name": "../node_modules/@hapi/hoek/lib/clone.js", "profile": { - "factory": 1052, - "building": 123 + "factory": 614, + "building": 142 } } ], "profile": { - "factory": 368, - "building": 118, + "factory": 185, + "building": 102, "dependencies": 0 }, "failed": false, @@ -2095,7 +2095,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/clone.js", "type": "cjs require", "userRequest": "./types", - "loc": "13:12-30" + "loc": "3:14-32" }, { "moduleId": 12, @@ -2104,7 +2104,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/deepEqual.js", "type": "cjs require", "userRequest": "./types", - "loc": "19:12-30" + "loc": "3:14-32" } ], "usedExports": true, @@ -2113,7 +2113,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nvar internals = {};\nexports = module.exports = {\n array: Array.prototype,\n buffer: Buffer && Buffer.prototype,\n // $lab:coverage:ignore$\n date: Date.prototype,\n error: Error.prototype,\n generic: Object.prototype,\n map: Map.prototype,\n promise: Promise.prototype,\n regex: RegExp.prototype,\n set: Set.prototype,\n weakMap: WeakMap.prototype,\n weakSet: WeakSet.prototype\n};\ninternals.typeMap = new Map([['[object Error]', exports.error], ['[object Map]', exports.map], ['[object Promise]', exports.promise], ['[object Set]', exports.set], ['[object WeakMap]', exports.weakMap], ['[object WeakSet]', exports.weakSet]]);\n\nexports.getInternalProto = function (obj) {\n if (Array.isArray(obj)) {\n return exports.array;\n }\n\n if (Buffer && obj instanceof Buffer) {\n // $lab:coverage:ignore$\n return exports.buffer;\n }\n\n if (obj instanceof Date) {\n return exports.date;\n }\n\n if (obj instanceof RegExp) {\n return exports.regex;\n }\n\n var objName = Object.prototype.toString.call(obj);\n return internals.typeMap.get(objName) || exports.generic;\n};" + "source": "'use strict';\n\nconst internals = {};\nexports = module.exports = {\n array: Array.prototype,\n buffer: Buffer && Buffer.prototype,\n // $lab:coverage:ignore$\n date: Date.prototype,\n error: Error.prototype,\n generic: Object.prototype,\n map: Map.prototype,\n promise: Promise.prototype,\n regex: RegExp.prototype,\n set: Set.prototype,\n weakMap: WeakMap.prototype,\n weakSet: WeakSet.prototype\n};\ninternals.typeMap = new Map([['[object Error]', exports.error], ['[object Map]', exports.map], ['[object Promise]', exports.promise], ['[object Set]', exports.set], ['[object WeakMap]', exports.weakMap], ['[object WeakSet]', exports.weakSet]]);\n\nexports.getInternalProto = function (obj) {\n if (Array.isArray(obj)) {\n return exports.array;\n }\n\n if (Buffer && obj instanceof Buffer) {\n // $lab:coverage:ignore$\n return exports.buffer;\n }\n\n if (obj instanceof Date) {\n return exports.date;\n }\n\n if (obj instanceof RegExp) {\n return exports.regex;\n }\n\n const objName = Object.prototype.toString.call(obj);\n return internals.typeMap.get(objName) || exports.generic;\n};" }, { "id": 18, @@ -2138,15 +2138,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -2160,7 +2160,7 @@ "moduleName": "../lib/common.js", "type": "cjs require", "userRequest": "../package.json", - "loc": "25:10-36" + "loc": "9:12-38" }, { "moduleId": 14, @@ -2169,7 +2169,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "../package.json", - "loc": "33:10-36" + "loc": "19:12-38" } ], "usedExports": true, @@ -2199,7 +2199,7 @@ "name": "../lib/manifest.js", "index": 20, "index2": 19, - "size": 17706, + "size": 10323, "cacheable": true, "built": true, "optional": false, @@ -2216,15 +2216,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -2238,16 +2238,16 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./manifest", - "loc": "27:15-36" + "loc": "13:17-38" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./manifest", - "loc": "39:15-36" + "loc": "21:17-38" } ], "usedExports": true, @@ -2256,7 +2256,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Common = require('./common');\n\nvar Messages = require('./messages');\n\nvar Ref = require('./ref');\n\nvar Template = require('./template');\n\nvar Schemas;\nvar internals = {};\n\nexports.describe = function (schema) {\n // Type\n var desc = {\n type: schema.type,\n flags: {},\n rules: []\n }; // Flags\n\n for (var flag in schema._flags) {\n if (flag[0] !== '_' && schema._flags[flag] !== internals.flagDefaults(desc.type, flag)) {\n desc.flags[flag] = internals.describe(schema._flags[flag]);\n }\n }\n\n if (!Object.keys(desc.flags).length) {\n delete desc.flags;\n } // Preferences\n\n\n if (schema._preferences) {\n desc.preferences = Clone(schema._preferences, {\n shallow: ['messages']\n });\n delete desc.preferences[Common.symbols.prefs];\n\n if (desc.preferences.messages) {\n desc.preferences.messages = Messages.decompile(desc.preferences.messages);\n }\n } // Allow / Invalid\n\n\n if (schema._valids) {\n desc.allow = schema._valids.describe();\n }\n\n if (schema._invalids) {\n desc.invalid = schema._invalids.describe();\n } // Rules\n\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = schema._rules[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var rule = _step.value;\n\n if (rule.name === 'items') {\n continue;\n }\n\n var _item2 = {\n name: rule.name\n };\n\n for (var _i2 = 0, _arr = ['keep', 'message', 'warn']; _i2 < _arr.length; _i2++) {\n var custom = _arr[_i2];\n\n if (rule[custom] !== undefined) {\n _item2[custom] = internals.describe(rule[custom]);\n }\n }\n\n if (rule.args) {\n _item2.args = {};\n\n for (var key in rule.args) {\n var arg = rule.args[key];\n\n if (key === 'options' && !Object.keys(arg).length) {\n continue;\n }\n\n _item2.args[key] = internals.describe(arg, {\n assign: key\n });\n }\n\n if (!Object.keys(_item2.args).length) {\n delete _item2.args;\n }\n }\n\n desc.rules.push(_item2);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n if (!desc.rules.length) {\n delete desc.rules;\n } // Terms\n\n\n for (var term in schema.$_terms) {\n if (term[0] === '_') {\n continue;\n }\n\n Assert(!desc[term], 'Cannot describe schema due to internal name conflict with', term);\n var items = schema.$_terms[term];\n\n if (!items) {\n continue;\n }\n\n if (items instanceof Map) {\n if (items.size) {\n desc[term] = _toConsumableArray(items.entries());\n }\n\n continue;\n }\n\n if (Common.isValues(items)) {\n if (items.length) {\n desc[term] = items.describe();\n }\n\n continue;\n }\n\n if (!items.length && term !== 'keys') {\n continue;\n }\n\n var normalized = [];\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = items[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var _item = _step2.value;\n normalized.push(internals.describe(_item));\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (term === 'keys') {\n var mapped = {};\n\n for (var _i = 0, _normalized = normalized; _i < _normalized.length; _i++) {\n var item = _normalized[_i];\n mapped[item.key] = item.schema;\n }\n\n normalized = mapped;\n }\n\n desc[term] = term === 'link' ? normalized[0] : normalized;\n }\n\n internals.validate(schema._root, desc);\n return desc;\n};\n\ninternals.describe = function (item) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (item === Common.symbols.deepDefault) {\n return {\n special: 'deep'\n };\n }\n\n if (_typeof(item) !== 'object') {\n return item;\n }\n\n if (options.assign === 'options' || Array.isArray(item)) {\n return Clone(item);\n }\n\n if (Buffer && Buffer.isBuffer(item)) {\n // $lab:coverage:ignore$\n return {\n buffer: item.toString('binary')\n };\n }\n\n if (item instanceof Date) {\n return item.toISOString();\n }\n\n if (item instanceof RegExp) {\n if (options.assign === 'regex') {\n return item.toString();\n }\n\n return {\n regex: item.toString()\n };\n }\n\n if (item[Common.symbols.literal]) {\n return {\n function: item.literal,\n options: {\n literal: true\n }\n };\n }\n\n if (typeof item.describe === 'function') {\n if (options.assign === 'ref') {\n return item.describe().ref;\n }\n\n return item.describe();\n }\n\n var normalized = {};\n\n for (var key in item) {\n var value = item[key];\n\n if (value === undefined || value === null) {\n continue;\n }\n\n normalized[key] = internals.describe(value, {\n assign: key\n });\n }\n\n return normalized;\n};\n\nexports.build = function (joi, desc) {\n var builder = new internals.Builder(joi);\n return builder.parse(desc);\n};\n\ninternals.Builder =\n/*#__PURE__*/\nfunction () {\n function _class(joi) {\n _classCallCheck(this, _class);\n\n this.joi = joi;\n }\n\n _createClass(_class, [{\n key: \"parse\",\n value: function parse(desc) {\n var _this = this;\n\n internals.validate(this.joi, desc); // Type\n\n var schema = this.joi[desc.type]();\n var def = schema._definition; // Flags\n\n if (desc.flags) {\n for (var flag in desc.flags) {\n schema = schema[flag](this.build(desc.flags[flag]));\n }\n } // Preferences\n\n\n if (desc.preferences) {\n schema = schema.preferences(this.structure(desc.preferences));\n } // Allow / Invalid\n\n\n if (desc.allow) {\n var _schema;\n\n schema = (_schema = schema).allow.apply(_schema, _toConsumableArray(this.build(desc.allow)));\n }\n\n if (desc.invalid) {\n var _schema2;\n\n schema = (_schema2 = schema).invalid.apply(_schema2, _toConsumableArray(this.build(desc.invalid)));\n } // Rules\n\n\n if (desc.rules) {\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = desc.rules[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var _schema3;\n\n var rule = _step3.value;\n Assert(typeof schema[rule.name] === 'function', 'Invalid rule', rule.name, 'for type', desc.type);\n var args = [];\n\n if (rule.args) {\n var built = {};\n\n for (var key in rule.args) {\n built[key] = this.build(rule.args[key], {\n assign: key\n });\n }\n\n var keys = Object.keys(built);\n var definition = def.rules[rule.name].args;\n\n if (definition) {\n Assert(keys.length <= definition.length, 'Invalid number of arguments for', desc.type, rule.name, '(expected up to', definition.length, ', found', keys.length, ')');\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = definition[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var name = _step4.value.name;\n args.push(built[name]);\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n } else {\n Assert(keys.length === 1, 'Invalid number of arguments for', desc.type, rule.name, '(expected up to 1, found', keys.length, ')');\n args.push(built[keys[0]]);\n }\n } // Apply\n\n\n schema = (_schema3 = schema)[rule.name].apply(_schema3, args); // Ruleset\n\n var options = {};\n\n for (var _i3 = 0, _arr2 = ['keep', 'message', 'warn']; _i3 < _arr2.length; _i3++) {\n var custom = _arr2[_i3];\n\n if (rule[custom] !== undefined) {\n options[custom] = this.build(rule[custom]);\n }\n }\n\n if (Object.keys(options).length) {\n schema = schema.rule(options);\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n } // Terms\n\n\n var terms = {};\n\n for (var _key in desc) {\n if (['allow', 'flags', 'invalid', 'keys', 'preferences', 'rules', 'type'].includes(_key)) {\n continue;\n }\n\n if (['items', 'ordered'].includes(_key)) {\n terms[_key] = desc[_key].map(function (item) {\n return _this.parse(item);\n });\n continue;\n }\n\n if (['falsy', 'truthy'].includes(_key)) {\n terms[_key] = desc[_key].map(function (item) {\n return _this.build(item);\n });\n continue;\n }\n\n if (_key === 'link') {\n terms.link = this.build(desc.link);\n continue;\n }\n\n var values = this.structure(desc[_key]);\n\n if (['examples', 'externals', 'metas', 'notes', 'tags'].includes(_key)) {\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = values[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var value = _step5.value;\n schema = schema[_key.slice(0, -1)](value);\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n } else if (_key === 'alterations') {\n var alter = {};\n var _iteratorNormalCompletion6 = true;\n var _didIteratorError6 = false;\n var _iteratorError6 = undefined;\n\n try {\n for (var _iterator6 = values[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {\n var _step6$value = _step6.value,\n target = _step6$value.target,\n adjuster = _step6$value.adjuster;\n alter[target] = adjuster;\n }\n } catch (err) {\n _didIteratorError6 = true;\n _iteratorError6 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion6 && _iterator6.return != null) {\n _iterator6.return();\n }\n } finally {\n if (_didIteratorError6) {\n throw _iteratorError6;\n }\n }\n }\n\n schema = schema.alter(alter);\n } else {\n terms[_key] = values;\n }\n }\n\n if (desc.keys) {\n terms.keys = {};\n\n for (var _key2 in desc.keys) {\n terms.keys[_key2] = this.parse(desc.keys[_key2]);\n }\n }\n\n if (def.build && Object.keys(terms).length) {\n schema = def.build(schema, terms);\n }\n\n return schema;\n }\n }, {\n key: \"build\",\n value: function build(desc) {\n var _this2 = this;\n\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (desc === null) {\n return null;\n }\n\n if (Array.isArray(desc)) {\n return desc.map(function (item) {\n return _this2.build(item);\n });\n }\n\n if (options.assign === 'options') {\n return Clone(desc);\n }\n\n if (options.assign === 'regex') {\n return internals.regex(desc);\n }\n\n if (_typeof(desc) !== 'object') {\n return desc;\n }\n\n if (desc.buffer) {\n Assert(Buffer, 'Buffers are not supported');\n return Buffer && Buffer.from(desc.buffer, 'binary'); // $lab:coverage:ignore$\n }\n\n if (desc.function) {\n var _ref;\n\n return _ref = {}, _defineProperty(_ref, Common.symbols.literal, true), _defineProperty(_ref, \"literal\", desc.function), _ref;\n }\n\n if (options.assign === 'ref') {\n return Ref.build(desc);\n }\n\n if (desc.ref) {\n return Ref.build(desc.ref);\n }\n\n if (desc.regex) {\n return internals.regex(desc.regex);\n }\n\n if (desc.special) {\n Assert(['deep'].includes(desc.special), 'Unknown special value', desc.special);\n return Common.symbols.deepDefault;\n }\n\n if (desc.type) {\n return this.parse(desc);\n }\n\n if (desc.value) {\n return Clone(desc.value);\n }\n\n if (desc.template) {\n return Template.build(desc);\n }\n }\n }, {\n key: \"structure\",\n value: function structure(desc) {\n var _this3 = this;\n\n if (_typeof(desc) !== 'object') {\n return desc;\n }\n\n if (Array.isArray(desc)) {\n return desc.map(function (item) {\n return _this3.structure(item);\n });\n }\n\n var normalized = {};\n\n for (var key in desc) {\n var value = this.build(desc[key], {\n assign: key\n });\n\n if (value === undefined) {\n value = this.structure(desc[key]);\n }\n\n normalized[key] = value;\n }\n\n return normalized;\n }\n }]);\n\n return _class;\n}();\n\ninternals.regex = function (string) {\n var end = string.lastIndexOf('/');\n var exp = string.slice(1, end);\n var flags = string.slice(end + 1);\n return new RegExp(exp, flags);\n};\n\ninternals.validate = function (joi, desc) {\n Schemas = Schemas || require('./schemas');\n joi.assert(desc, Schemas.description);\n};\n\ninternals.flagDefaults = function (type, flag) {\n if (type === 'boolean' && flag === 'insensitive') {\n return true;\n }\n\n if (['insensitive', 'only', 'single', 'sparse', 'strip', 'truncate', 'unknown', 'unsafe'].includes(flag)) {\n return false;\n }\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Common = require('./common');\n\nconst Messages = require('./messages');\n\nconst Ref = require('./ref');\n\nconst Template = require('./template');\n\nlet Schemas;\nconst internals = {};\n\nexports.describe = function (schema) {\n // Type\n const desc = {\n type: schema.type,\n flags: {},\n rules: []\n }; // Flags\n\n for (const flag in schema._flags) {\n if (flag[0] !== '_' && schema._flags[flag] !== internals.flagDefaults(desc.type, flag)) {\n desc.flags[flag] = internals.describe(schema._flags[flag]);\n }\n }\n\n if (!Object.keys(desc.flags).length) {\n delete desc.flags;\n } // Preferences\n\n\n if (schema._preferences) {\n desc.preferences = Clone(schema._preferences, {\n shallow: ['messages']\n });\n delete desc.preferences[Common.symbols.prefs];\n\n if (desc.preferences.messages) {\n desc.preferences.messages = Messages.decompile(desc.preferences.messages);\n }\n } // Allow / Invalid\n\n\n if (schema._valids) {\n desc.allow = schema._valids.describe();\n }\n\n if (schema._invalids) {\n desc.invalid = schema._invalids.describe();\n } // Rules\n\n\n for (const rule of schema._rules) {\n if (rule.name === 'items') {\n continue;\n }\n\n const item = {\n name: rule.name\n };\n\n for (const custom of ['keep', 'message', 'warn']) {\n if (rule[custom] !== undefined) {\n item[custom] = internals.describe(rule[custom]);\n }\n }\n\n if (rule.args) {\n item.args = {};\n\n for (const key in rule.args) {\n const arg = rule.args[key];\n\n if (key === 'options' && !Object.keys(arg).length) {\n continue;\n }\n\n item.args[key] = internals.describe(arg, {\n assign: key\n });\n }\n\n if (!Object.keys(item.args).length) {\n delete item.args;\n }\n }\n\n desc.rules.push(item);\n }\n\n if (!desc.rules.length) {\n delete desc.rules;\n } // Terms\n\n\n for (const term in schema.$_terms) {\n if (term[0] === '_') {\n continue;\n }\n\n Assert(!desc[term], 'Cannot describe schema due to internal name conflict with', term);\n const items = schema.$_terms[term];\n\n if (!items) {\n continue;\n }\n\n if (items instanceof Map) {\n if (items.size) {\n desc[term] = [...items.entries()];\n }\n\n continue;\n }\n\n if (Common.isValues(items)) {\n if (items.length) {\n desc[term] = items.describe();\n }\n\n continue;\n }\n\n if (!items.length && term !== 'keys') {\n continue;\n }\n\n let normalized = [];\n\n for (const item of items) {\n normalized.push(internals.describe(item));\n }\n\n if (term === 'keys') {\n const mapped = {};\n\n for (const item of normalized) {\n mapped[item.key] = item.schema;\n }\n\n normalized = mapped;\n }\n\n desc[term] = term === 'link' ? normalized[0] : normalized;\n }\n\n internals.validate(schema._root, desc);\n return desc;\n};\n\ninternals.describe = function (item) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (item === Common.symbols.deepDefault) {\n return {\n special: 'deep'\n };\n }\n\n if (typeof item !== 'object') {\n return item;\n }\n\n if (options.assign === 'options' || Array.isArray(item)) {\n return Clone(item);\n }\n\n if (Buffer && Buffer.isBuffer(item)) {\n // $lab:coverage:ignore$\n return {\n buffer: item.toString('binary')\n };\n }\n\n if (item instanceof Date) {\n return item.toISOString();\n }\n\n if (item instanceof RegExp) {\n if (options.assign === 'regex') {\n return item.toString();\n }\n\n return {\n regex: item.toString()\n };\n }\n\n if (item[Common.symbols.literal]) {\n return {\n function: item.literal,\n options: {\n literal: true\n }\n };\n }\n\n if (typeof item.describe === 'function') {\n if (options.assign === 'ref') {\n return item.describe().ref;\n }\n\n return item.describe();\n }\n\n const normalized = {};\n\n for (const key in item) {\n const value = item[key];\n\n if (value === undefined || value === null) {\n continue;\n }\n\n normalized[key] = internals.describe(value, {\n assign: key\n });\n }\n\n return normalized;\n};\n\nexports.build = function (joi, desc) {\n const builder = new internals.Builder(joi);\n return builder.parse(desc);\n};\n\ninternals.Builder = class {\n constructor(joi) {\n this.joi = joi;\n }\n\n parse(desc) {\n internals.validate(this.joi, desc); // Type\n\n let schema = this.joi[desc.type]();\n const def = schema._definition; // Flags\n\n if (desc.flags) {\n for (const flag in desc.flags) {\n schema = schema[flag](this.build(desc.flags[flag]));\n }\n } // Preferences\n\n\n if (desc.preferences) {\n schema = schema.preferences(this.structure(desc.preferences));\n } // Allow / Invalid\n\n\n if (desc.allow) {\n schema = schema.allow(...this.build(desc.allow));\n }\n\n if (desc.invalid) {\n schema = schema.invalid(...this.build(desc.invalid));\n } // Rules\n\n\n if (desc.rules) {\n for (const rule of desc.rules) {\n Assert(typeof schema[rule.name] === 'function', 'Invalid rule', rule.name, 'for type', desc.type);\n const args = [];\n\n if (rule.args) {\n const built = {};\n\n for (const key in rule.args) {\n built[key] = this.build(rule.args[key], {\n assign: key\n });\n }\n\n const keys = Object.keys(built);\n const definition = def.rules[rule.name].args;\n\n if (definition) {\n Assert(keys.length <= definition.length, 'Invalid number of arguments for', desc.type, rule.name, '(expected up to', definition.length, ', found', keys.length, ')');\n\n for (const _ref of definition) {\n const {\n name\n } = _ref;\n args.push(built[name]);\n }\n } else {\n Assert(keys.length === 1, 'Invalid number of arguments for', desc.type, rule.name, '(expected up to 1, found', keys.length, ')');\n args.push(built[keys[0]]);\n }\n } // Apply\n\n\n schema = schema[rule.name](...args); // Ruleset\n\n const options = {};\n\n for (const custom of ['keep', 'message', 'warn']) {\n if (rule[custom] !== undefined) {\n options[custom] = this.build(rule[custom]);\n }\n }\n\n if (Object.keys(options).length) {\n schema = schema.rule(options);\n }\n }\n } // Terms\n\n\n const terms = {};\n\n for (const key in desc) {\n if (['allow', 'flags', 'invalid', 'keys', 'preferences', 'rules', 'type'].includes(key)) {\n continue;\n }\n\n if (['items', 'ordered'].includes(key)) {\n terms[key] = desc[key].map(item => this.parse(item));\n continue;\n }\n\n if (['falsy', 'truthy'].includes(key)) {\n terms[key] = desc[key].map(item => this.build(item));\n continue;\n }\n\n if (key === 'link') {\n terms.link = this.build(desc.link);\n continue;\n }\n\n const values = this.structure(desc[key]);\n\n if (['examples', 'externals', 'metas', 'notes', 'tags'].includes(key)) {\n for (const value of values) {\n schema = schema[key.slice(0, -1)](value);\n }\n } else if (key === 'alterations') {\n const alter = {};\n\n for (const _ref2 of values) {\n const {\n target,\n adjuster\n } = _ref2;\n alter[target] = adjuster;\n }\n\n schema = schema.alter(alter);\n } else {\n terms[key] = values;\n }\n }\n\n if (desc.keys) {\n terms.keys = {};\n\n for (const key in desc.keys) {\n terms.keys[key] = this.parse(desc.keys[key]);\n }\n }\n\n if (def.build && Object.keys(terms).length) {\n schema = def.build(schema, terms);\n }\n\n return schema;\n }\n\n build(desc) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (desc === null) {\n return null;\n }\n\n if (Array.isArray(desc)) {\n return desc.map(item => this.build(item));\n }\n\n if (options.assign === 'options') {\n return Clone(desc);\n }\n\n if (options.assign === 'regex') {\n return internals.regex(desc);\n }\n\n if (typeof desc !== 'object') {\n return desc;\n }\n\n if (desc.buffer) {\n Assert(Buffer, 'Buffers are not supported');\n return Buffer && Buffer.from(desc.buffer, 'binary'); // $lab:coverage:ignore$\n }\n\n if (desc.function) {\n return {\n [Common.symbols.literal]: true,\n literal: desc.function\n };\n }\n\n if (options.assign === 'ref') {\n return Ref.build(desc);\n }\n\n if (desc.ref) {\n return Ref.build(desc.ref);\n }\n\n if (desc.regex) {\n return internals.regex(desc.regex);\n }\n\n if (desc.special) {\n Assert(['deep'].includes(desc.special), 'Unknown special value', desc.special);\n return Common.symbols.deepDefault;\n }\n\n if (desc.type) {\n return this.parse(desc);\n }\n\n if (desc.value) {\n return Clone(desc.value);\n }\n\n if (desc.template) {\n return Template.build(desc);\n }\n }\n\n structure(desc) {\n if (typeof desc !== 'object') {\n return desc;\n }\n\n if (Array.isArray(desc)) {\n return desc.map(item => this.structure(item));\n }\n\n const normalized = {};\n\n for (const key in desc) {\n let value = this.build(desc[key], {\n assign: key\n });\n\n if (value === undefined) {\n value = this.structure(desc[key]);\n }\n\n normalized[key] = value;\n }\n\n return normalized;\n }\n\n};\n\ninternals.regex = function (string) {\n const end = string.lastIndexOf('/');\n const exp = string.slice(1, end);\n const flags = string.slice(end + 1);\n return new RegExp(exp, flags);\n};\n\ninternals.validate = function (joi, desc) {\n Schemas = Schemas || require('./schemas');\n joi.assert(desc, Schemas.description);\n};\n\ninternals.flagDefaults = function (type, flag) {\n if (type === 'boolean' && flag === 'insensitive') {\n return true;\n }\n\n if (['insensitive', 'only', 'single', 'sparse', 'strip', 'truncate', 'unknown', 'unsafe'].includes(flag)) {\n return false;\n }\n};" }, { "id": 20, @@ -2264,7 +2264,7 @@ "name": "../node_modules/@hapi/hoek/lib/merge.js", "index": 25, "index2": 21, - "size": 2246, + "size": 1895, "cacheable": true, "built": true, "optional": false, @@ -2273,7 +2273,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", - "issuerId": 31, + "issuerId": 30, "issuerName": "../lib/base.js", "issuerPath": [ { @@ -2281,8 +2281,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -2290,25 +2290,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/any.js", "name": "../lib/types/any.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 31, + "id": 30, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "name": "../lib/base.js", "profile": { - "factory": 767, - "building": 322, + "factory": 353, + "building": 264, "dependencies": 2 } } ], "profile": { - "factory": 169, - "building": 279, + "factory": 101, + "building": 141, "dependencies": 0 }, "failed": false, @@ -2317,22 +2317,22 @@ "assets": [], "reasons": [ { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/merge", - "loc": "27:12-43" + "loc": "9:14-45" }, { - "moduleId": 39, + "moduleId": 38, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/applyToDefaults.js", "module": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "moduleName": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "type": "cjs require", "userRequest": "./merge", - "loc": "9:12-30" + "loc": "7:14-32" } ], "usedExports": true, @@ -2341,7 +2341,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('./assert');\n\nvar Clone = require('./clone');\n\nvar Utils = require('./utils');\n\nvar internals = {};\n\nmodule.exports = internals.merge = function (target, source, options) {\n Assert(target && _typeof(target) === 'object', 'Invalid target value: must be an object');\n Assert(source === null || source === undefined || _typeof(source) === 'object', 'Invalid source value: must be null, undefined, or an object');\n\n if (!source) {\n return target;\n }\n\n options = Object.assign({\n nullOverride: true,\n mergeArrays: true\n }, options);\n\n if (Array.isArray(source)) {\n Assert(Array.isArray(target), 'Cannot merge array onto an object');\n\n if (!options.mergeArrays) {\n target.length = 0; // Must not change target assignment\n }\n\n for (var i = 0; i < source.length; ++i) {\n target.push(Clone(source[i], {\n symbols: options.symbols\n }));\n }\n\n return target;\n }\n\n var keys = Utils.keys(source, options);\n\n for (var _i = 0; _i < keys.length; ++_i) {\n var key = keys[_i];\n\n if (key === '__proto__' || !Object.prototype.propertyIsEnumerable.call(source, key)) {\n continue;\n }\n\n var value = source[key];\n\n if (value && _typeof(value) === 'object') {\n if (!target[key] || _typeof(target[key]) !== 'object' || Array.isArray(target[key]) !== Array.isArray(value) || value instanceof Date || Buffer && Buffer.isBuffer(value) || // $lab:coverage:ignore$\n value instanceof RegExp) {\n target[key] = Clone(value, {\n symbols: options.symbols\n });\n } else {\n internals.merge(target[key], value, options);\n }\n } else {\n if (value !== null && value !== undefined) {\n // Explicit to preserve empty strings\n target[key] = value;\n } else if (options.nullOverride) {\n target[key] = value;\n }\n }\n }\n\n return target;\n};" + "source": "'use strict';\n\nconst Assert = require('./assert');\n\nconst Clone = require('./clone');\n\nconst Utils = require('./utils');\n\nconst internals = {};\n\nmodule.exports = internals.merge = function (target, source, options) {\n Assert(target && typeof target === 'object', 'Invalid target value: must be an object');\n Assert(source === null || source === undefined || typeof source === 'object', 'Invalid source value: must be null, undefined, or an object');\n\n if (!source) {\n return target;\n }\n\n options = Object.assign({\n nullOverride: true,\n mergeArrays: true\n }, options);\n\n if (Array.isArray(source)) {\n Assert(Array.isArray(target), 'Cannot merge array onto an object');\n\n if (!options.mergeArrays) {\n target.length = 0; // Must not change target assignment\n }\n\n for (let i = 0; i < source.length; ++i) {\n target.push(Clone(source[i], {\n symbols: options.symbols\n }));\n }\n\n return target;\n }\n\n const keys = Utils.keys(source, options);\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n\n if (key === '__proto__' || !Object.prototype.propertyIsEnumerable.call(source, key)) {\n continue;\n }\n\n const value = source[key];\n\n if (value && typeof value === 'object') {\n if (!target[key] || typeof target[key] !== 'object' || Array.isArray(target[key]) !== Array.isArray(value) || value instanceof Date || Buffer && Buffer.isBuffer(value) || // $lab:coverage:ignore$\n value instanceof RegExp) {\n target[key] = Clone(value, {\n symbols: options.symbols\n });\n } else {\n internals.merge(target[key], value, options);\n }\n } else {\n if (value !== null && value !== undefined) {\n // Explicit to preserve empty strings\n target[key] = value;\n } else if (options.nullOverride) {\n target[key] = value;\n }\n }\n }\n\n return target;\n};" }, { "id": 21, @@ -2349,7 +2349,7 @@ "name": "../lib/values.js", "index": 29, "index2": 25, - "size": 11148, + "size": 4449, "cacheable": true, "built": true, "optional": false, @@ -2358,7 +2358,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", - "issuerId": 36, + "issuerId": 35, "issuerName": "../lib/types/boolean.js", "issuerPath": [ { @@ -2366,24 +2366,24 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 36, + "id": 35, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", "name": "../lib/types/boolean.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 496, - "building": 358, + "factory": 333, + "building": 276, "dependencies": 0 }, "failed": false, @@ -2392,22 +2392,22 @@ "assets": [], "reasons": [ { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./values", - "loc": "49:13-32" + "loc": "31:15-34" }, { - "moduleId": 36, + "moduleId": 35, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", "module": "../lib/types/boolean.js", "moduleName": "../lib/types/boolean.js", "type": "cjs require", "userRequest": "../values", - "loc": "17:13-33" + "loc": "9:15-35" } ], "usedExports": true, @@ -2416,7 +2416,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Common = require('./common');\n\nvar internals = {};\n\nmodule.exports = internals.Values =\n/*#__PURE__*/\nfunction () {\n function _class(from) {\n _classCallCheck(this, _class);\n\n this._set = new Set(from);\n this._resolve = false;\n }\n\n _createClass(_class, [{\n key: \"add\",\n value: function add(value, refs) {\n if (this.has(value, null, null, false)) {\n return;\n }\n\n if (refs !== undefined) {\n // If it's a merge, we don't have any refs\n refs.register(value);\n }\n\n this._set.add(value);\n\n if (Common.isResolvable(value)) {\n this._resolve = true;\n }\n }\n }, {\n key: \"remove\",\n value: function remove(value) {\n this._set.delete(value);\n }\n }, {\n key: \"has\",\n value: function has(value, state, prefs, insensitive) {\n return !!this.get(value, state, prefs, insensitive);\n }\n }, {\n key: \"get\",\n value: function get(value, state, prefs, insensitive) {\n if (!this._set.size) {\n return false;\n }\n\n var hasValue = this._set.has(value);\n\n if (hasValue) {\n return {\n value: value\n };\n }\n\n if (!this._resolve && !insensitive && _typeof(value) !== 'object') {\n return false;\n }\n\n var extendedCheck = internals.extendedCheckForValue(value, insensitive);\n\n if (!extendedCheck) {\n if (state && this._resolve) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = this._set[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var item = _step.value;\n\n if (Common.isResolvable(item)) {\n item = [].concat(item.resolve(value, state, prefs));\n var found = item.indexOf(value);\n\n if (found >= 0) {\n return {\n value: item[found]\n };\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n\n return false;\n }\n\n return this._has(value, state, prefs, extendedCheck);\n }\n }, {\n key: \"_has\",\n value: function _has(value, state, prefs, check) {\n var checkRef = !!(state && this._resolve);\n\n var isReallyEqual = function isReallyEqual(item) {\n if (value === item) {\n return true;\n }\n\n return check(item);\n };\n\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = this._set[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var item = _step2.value;\n\n if (checkRef && Common.isResolvable(item)) {\n // Only resolve references if there is a state, otherwise it's a merge\n item = item.resolve(value, state, prefs);\n\n if (Array.isArray(item)) {\n var found = item.findIndex(isReallyEqual);\n\n if (found >= 0) {\n return {\n value: item[found]\n };\n }\n\n continue;\n }\n }\n\n if (isReallyEqual(item)) {\n return {\n value: item\n };\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return false;\n }\n }, {\n key: \"values\",\n value: function values(options) {\n if (options && options.stripUndefined) {\n var values = [];\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = this._set[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var item = _step3.value;\n\n if (item !== undefined) {\n values.push(item);\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n return values;\n }\n\n return Array.from(this._set);\n }\n }, {\n key: \"clone\",\n value: function clone() {\n var set = new internals.Values(this._set);\n set._resolve = this._resolve;\n return set;\n }\n }, {\n key: \"concat\",\n value: function concat(source) {\n var set = new internals.Values([].concat(_toConsumableArray(this._set), _toConsumableArray(source._set)));\n set._resolve = this._resolve || source._resolve;\n return set;\n }\n }, {\n key: \"describe\",\n value: function describe() {\n var normalized = [];\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = this._set.values()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var value = _step4.value;\n normalized.push(Common.isResolvable(value) ? value.describe() : value && _typeof(value) === 'object' ? {\n value: value\n } : value);\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n\n return normalized;\n }\n }, {\n key: \"length\",\n get: function get() {\n return this._set.size;\n }\n }], [{\n key: \"merge\",\n value: function merge(target, add, remove) {\n target = target || new internals.Values();\n\n if (add) {\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = add._set[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var item = _step5.value;\n target.add(item);\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n }\n\n if (remove) {\n var _iteratorNormalCompletion6 = true;\n var _didIteratorError6 = false;\n var _iteratorError6 = undefined;\n\n try {\n for (var _iterator6 = remove._set[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {\n var _item = _step6.value;\n target.remove(_item);\n }\n } catch (err) {\n _didIteratorError6 = true;\n _iteratorError6 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion6 && _iterator6.return != null) {\n _iterator6.return();\n }\n } finally {\n if (_didIteratorError6) {\n throw _iteratorError6;\n }\n }\n }\n }\n\n return target.length ? target : null;\n }\n }]);\n\n return _class;\n}();\n\ninternals.Values.prototype[Common.symbols.values] = true; // Aliases\n\ninternals.Values.prototype.slice = internals.Values.prototype.clone;\n\ninternals.extendedCheckForValue = function (value, insensitive) {\n var valueType = _typeof(value);\n\n if (valueType === 'object') {\n if (value instanceof Date) {\n return function (item) {\n return item instanceof Date && value.getTime() === item.getTime();\n };\n }\n\n if (Buffer && Buffer.isBuffer(value)) {\n // $lab:coverage:ignore$\n return function (item) {\n return Buffer.isBuffer(item) && value.length === item.length && value.toString('binary') === item.toString('binary');\n };\n }\n } else if (insensitive && valueType === 'string') {\n var lowercaseValue = value.toLowerCase();\n return function (item) {\n return typeof item === 'string' && lowercaseValue === item.toLowerCase();\n };\n }\n\n return null;\n};" + "source": "'use strict';\n\nconst Common = require('./common');\n\nconst internals = {};\nmodule.exports = internals.Values = class {\n constructor(from) {\n this._set = new Set(from);\n this._resolve = false;\n }\n\n get length() {\n return this._set.size;\n }\n\n add(value, refs) {\n if (this.has(value, null, null, false)) {\n return;\n }\n\n if (refs !== undefined) {\n // If it's a merge, we don't have any refs\n refs.register(value);\n }\n\n this._set.add(value);\n\n if (Common.isResolvable(value)) {\n this._resolve = true;\n }\n }\n\n static merge(target, add, remove) {\n target = target || new internals.Values();\n\n if (add) {\n for (const item of add._set) {\n target.add(item);\n }\n }\n\n if (remove) {\n for (const item of remove._set) {\n target.remove(item);\n }\n }\n\n return target.length ? target : null;\n }\n\n remove(value) {\n this._set.delete(value);\n }\n\n has(value, state, prefs, insensitive) {\n return !!this.get(value, state, prefs, insensitive);\n }\n\n get(value, state, prefs, insensitive) {\n if (!this._set.size) {\n return false;\n }\n\n const hasValue = this._set.has(value);\n\n if (hasValue) {\n return {\n value\n };\n }\n\n if (!this._resolve && !insensitive && typeof value !== 'object') {\n return false;\n }\n\n const extendedCheck = internals.extendedCheckForValue(value, insensitive);\n\n if (!extendedCheck) {\n if (state && this._resolve) {\n for (let item of this._set) {\n if (Common.isResolvable(item)) {\n item = [].concat(item.resolve(value, state, prefs));\n const found = item.indexOf(value);\n\n if (found >= 0) {\n return {\n value: item[found]\n };\n }\n }\n }\n }\n\n return false;\n }\n\n return this._has(value, state, prefs, extendedCheck);\n }\n\n _has(value, state, prefs, check) {\n const checkRef = !!(state && this._resolve);\n\n const isReallyEqual = function isReallyEqual(item) {\n if (value === item) {\n return true;\n }\n\n return check(item);\n };\n\n for (let item of this._set) {\n if (checkRef && Common.isResolvable(item)) {\n // Only resolve references if there is a state, otherwise it's a merge\n item = item.resolve(value, state, prefs);\n\n if (Array.isArray(item)) {\n const found = item.findIndex(isReallyEqual);\n\n if (found >= 0) {\n return {\n value: item[found]\n };\n }\n\n continue;\n }\n }\n\n if (isReallyEqual(item)) {\n return {\n value: item\n };\n }\n }\n\n return false;\n }\n\n values(options) {\n if (options && options.stripUndefined) {\n const values = [];\n\n for (const item of this._set) {\n if (item !== undefined) {\n values.push(item);\n }\n }\n\n return values;\n }\n\n return Array.from(this._set);\n }\n\n clone() {\n const set = new internals.Values(this._set);\n set._resolve = this._resolve;\n return set;\n }\n\n concat(source) {\n const set = new internals.Values([...this._set, ...source._set]);\n set._resolve = this._resolve || source._resolve;\n return set;\n }\n\n describe() {\n const normalized = [];\n\n for (const value of this._set.values()) {\n normalized.push(Common.isResolvable(value) ? value.describe() : value && typeof value === 'object' ? {\n value\n } : value);\n }\n\n return normalized;\n }\n\n};\ninternals.Values.prototype[Common.symbols.values] = true; // Aliases\n\ninternals.Values.prototype.slice = internals.Values.prototype.clone;\n\ninternals.extendedCheckForValue = function (value, insensitive) {\n const valueType = typeof value;\n\n if (valueType === 'object') {\n if (value instanceof Date) {\n return item => {\n return item instanceof Date && value.getTime() === item.getTime();\n };\n }\n\n if (Buffer && Buffer.isBuffer(value)) {\n // $lab:coverage:ignore$\n return item => {\n return Buffer.isBuffer(item) && value.length === item.length && value.toString('binary') === item.toString('binary');\n };\n }\n } else if (insensitive && valueType === 'string') {\n const lowercaseValue = value.toLowerCase();\n return item => {\n return typeof item === 'string' && lowercaseValue === item.toLowerCase();\n };\n }\n\n return null;\n};" }, { "id": 22, @@ -2424,7 +2424,7 @@ "name": "../node_modules/@hapi/bourne/lib/index.js", "index": 31, "index2": 29, - "size": 2156, + "size": 1744, "cacheable": true, "built": true, "optional": false, @@ -2433,7 +2433,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", - "issuerId": 35, + "issuerId": 34, "issuerName": "../lib/types/array.js", "issuerPath": [ { @@ -2441,25 +2441,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 35, + "id": 34, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "name": "../lib/types/array.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1026, - "building": 91, - "dependencies": 298 + "factory": 574, + "building": 43, + "dependencies": 24 }, "failed": false, "errors": 0, @@ -2473,16 +2473,16 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "@hapi/bourne", - "loc": "43:13-36" + "loc": "7:15-38" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "@hapi/bourne", - "loc": "15:13-36" + "loc": "5:15-38" } ], "usedExports": true, @@ -2491,7 +2491,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar internals = {\n suspectRx: /\"(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])(?:p|\\\\u0070)(?:r|\\\\u0072)(?:o|\\\\u006[Ff])(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])\"\\s*\\:/\n};\n\nexports.parse = function (text, reviver, options) {\n // Normalize arguments\n if (!options) {\n if (reviver && _typeof(reviver) === 'object') {\n options = reviver;\n reviver = undefined;\n } else {\n options = {};\n }\n } // Parse normally, allowing exceptions\n\n\n var obj = JSON.parse(text, reviver); // options.protoAction: 'error' (default) / 'remove' / 'ignore'\n\n if (options.protoAction === 'ignore') {\n return obj;\n } // Ignore null and non-objects\n\n\n if (!obj || _typeof(obj) !== 'object') {\n return obj;\n } // Check original string for potential exploit\n\n\n if (!text.match(internals.suspectRx)) {\n return obj;\n } // Scan result for proto keys\n\n\n exports.scan(obj, options);\n return obj;\n};\n\nexports.scan = function (obj, options) {\n options = options || {};\n var next = [obj];\n\n while (next.length) {\n var nodes = next;\n next = [];\n\n for (var _i = 0, _nodes = nodes; _i < _nodes.length; _i++) {\n var node = _nodes[_i];\n\n if (Object.prototype.hasOwnProperty.call(node, '__proto__')) {\n // Avoid calling node.hasOwnProperty directly\n if (options.protoAction !== 'remove') {\n throw new SyntaxError('Object contains forbidden prototype property');\n }\n\n delete node.__proto__;\n }\n\n for (var key in node) {\n var value = node[key];\n\n if (value && _typeof(value) === 'object') {\n next.push(node[key]);\n }\n }\n }\n }\n};\n\nexports.safeParse = function (text, reviver) {\n try {\n return exports.parse(text, reviver);\n } catch (ignoreError) {\n return null;\n }\n};" + "source": "'use strict';\n\nconst internals = {\n suspectRx: /\"(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])(?:p|\\\\u0070)(?:r|\\\\u0072)(?:o|\\\\u006[Ff])(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])\"\\s*\\:/\n};\n\nexports.parse = function (text, reviver, options) {\n // Normalize arguments\n if (!options) {\n if (reviver && typeof reviver === 'object') {\n options = reviver;\n reviver = undefined;\n } else {\n options = {};\n }\n } // Parse normally, allowing exceptions\n\n\n const obj = JSON.parse(text, reviver); // options.protoAction: 'error' (default) / 'remove' / 'ignore'\n\n if (options.protoAction === 'ignore') {\n return obj;\n } // Ignore null and non-objects\n\n\n if (!obj || typeof obj !== 'object') {\n return obj;\n } // Check original string for potential exploit\n\n\n if (!text.match(internals.suspectRx)) {\n return obj;\n } // Scan result for proto keys\n\n\n exports.scan(obj, options);\n return obj;\n};\n\nexports.scan = function (obj, options) {\n options = options || {};\n let next = [obj];\n\n while (next.length) {\n const nodes = next;\n next = [];\n\n for (const node of nodes) {\n if (Object.prototype.hasOwnProperty.call(node, '__proto__')) {\n // Avoid calling node.hasOwnProperty directly\n if (options.protoAction !== 'remove') {\n throw new SyntaxError('Object contains forbidden prototype property');\n }\n\n delete node.__proto__;\n }\n\n for (const key in node) {\n const value = node[key];\n\n if (value && typeof value === 'object') {\n next.push(node[key]);\n }\n }\n }\n }\n};\n\nexports.safeParse = function (text, reviver) {\n try {\n return exports.parse(text, reviver);\n } catch (ignoreError) {\n return null;\n }\n};" }, { "id": 23, @@ -2499,7 +2499,7 @@ "name": "../lib/types/object.js", "index": 35, "index2": 35, - "size": 55029, + "size": 32847, "cacheable": true, "built": true, "optional": false, @@ -2516,15 +2516,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -2538,16 +2538,16 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/object", - "loc": "46:12-37" + "loc": "32:12-37" }, { - "moduleId": 38, + "moduleId": 37, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/function.js", "module": "../lib/types/function.js", "moduleName": "../lib/types/function.js", "type": "cjs require", "userRequest": "./object", - "loc": "5:17-36" + "loc": "5:19-38" } ], "usedExports": true, @@ -2556,108 +2556,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar ApplyToDefaults = require('@hapi/hoek/lib/applyToDefaults');\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Bourne = require('@hapi/bourne');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Topo = require('@hapi/topo');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar Compile = require('../compile');\n\nvar Errors = require('../errors');\n\nvar Ref = require('../ref');\n\nvar Template = require('../template');\n\nvar internals = {\n renameDefaults: {\n alias: false,\n // Keep old value in place\n multiple: false,\n // Allow renaming multiple keys into the same target\n override: false // Overrides an existing key\n\n }\n};\nmodule.exports = Any.extend({\n type: 'object',\n properties: {\n typeof: 'object'\n },\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.dependencies = null;\n schema.$_terms.keys = null;\n schema.$_terms.patterns = null;\n schema.$_terms.renames = null;\n },\n args: function args(schema, keys) {\n return schema.keys(keys);\n },\n // Coerce\n coerce: {\n from: 'string',\n method: function method(schema, value, helpers) {\n if (value[0] !== '{' && !/^\\s*\\{/.test(value)) {\n return;\n }\n\n try {\n return {\n value: Bourne.parse(value)\n };\n } catch (ignoreErr) {}\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n var error = _ref.error,\n state = _ref.state,\n prefs = _ref.prefs;\n\n if (!value || _typeof(value) !== schema.$_property('typeof') || Array.isArray(value)) {\n return {\n value: value,\n errors: error('object.base', {\n type: schema.$_property('typeof')\n })\n };\n } // Skip if there are no other rules to test\n\n\n if (!schema.$_terms.renames && !schema.$_terms.dependencies && !schema.$_terms.keys && // null allows any keys\n !schema.$_terms.patterns && !schema.$_terms.externals) {\n return;\n } // Shallow clone value\n\n\n value = internals.clone(value, prefs);\n var errors = []; // Rename keys\n\n if (schema.$_terms.renames && !internals.rename(schema, value, state, prefs, errors)) {\n return {\n value: value,\n errors: errors\n };\n } // Anything allowed\n\n\n if (!schema.$_terms.keys && // null allows any keys\n !schema.$_terms.patterns && !schema.$_terms.dependencies) {\n return {\n value: value,\n errors: errors\n };\n } // Defined keys\n\n\n var unprocessed = new Set(Object.keys(value));\n\n if (schema.$_terms.keys) {\n var ancestors = [value].concat(_toConsumableArray(state.ancestors));\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = schema.$_terms.keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var child = _step.value;\n var key = child.key;\n var item = value[key];\n unprocessed.delete(key);\n var localState = state.localize([].concat(_toConsumableArray(state.path), [key]), ancestors, child.schema);\n var result = child.schema.$_validate(item, localState, prefs);\n\n if (result.errors) {\n if (prefs.abortEarly) {\n return {\n value: value,\n errors: result.errors\n };\n }\n\n errors.push.apply(errors, _toConsumableArray(result.errors));\n } else if (child.schema._flags.result === 'strip' || result.value === undefined && item !== undefined) {\n delete value[key];\n } else if (result.value !== undefined) {\n value[key] = result.value;\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n } // Unknown keys\n\n\n if (unprocessed.size) {\n var early = internals.unknown(schema, value, unprocessed, errors, state, prefs);\n\n if (early) {\n return early;\n }\n } // Validate dependencies\n\n\n if (schema.$_terms.dependencies) {\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = schema.$_terms.dependencies[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var dep = _step2.value;\n\n if (dep.key && dep.key.resolve(value, state, prefs, null, {\n shadow: false\n }) === undefined) {\n continue;\n }\n\n var failed = internals.dependencies[dep.type](schema, dep, value, state, prefs);\n\n if (failed) {\n var report = schema.$_createError(failed.code, value, failed.context, state, prefs);\n\n if (prefs.abortEarly) {\n return {\n value: value,\n errors: report\n };\n }\n\n errors.push(report);\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n\n return {\n value: value,\n errors: errors\n };\n },\n // Rules\n rules: {\n and: {\n method: function method()\n /*, [options] */\n {\n for (var _len = arguments.length, peers = new Array(_len), _key = 0; _key < _len; _key++) {\n peers[_key] = arguments[_key];\n }\n\n Common.verifyFlat(peers, 'and');\n return internals.dependency(this, 'and', null, peers);\n }\n },\n append: {\n method: function method(schema) {\n if (schema === null || schema === undefined || Object.keys(schema).length === 0) {\n return this;\n }\n\n return this.keys(schema);\n }\n },\n assert: {\n method: function method(ref, schema, message) {\n ref = Compile.ref(ref);\n Assert(ref.type === 'global' || ref.depth > 1, 'Cannot use assertions for root level references - use direct key rules instead');\n message = message || 'pass the assertion test';\n Assert(typeof message === 'string', 'Message must be a string');\n schema = this.$_compile(schema, {\n appendPath: true\n });\n var path = ref.path.join('.');\n var obj = this.$_addRule({\n name: 'assert',\n args: {\n ref: ref,\n schema: schema,\n message: message\n },\n path: path\n });\n obj.$_mutateRegister(schema);\n return obj;\n },\n validate: function validate(value, _ref2, _ref3, _ref4) {\n var error = _ref2.error,\n prefs = _ref2.prefs,\n state = _ref2.state;\n var ref = _ref3.ref,\n schema = _ref3.schema,\n message = _ref3.message;\n var path = _ref4.path;\n var entryState = state.entry(schema, value);\n\n if (schema.$_match(ref.resolve(null, {\n ancestors: [value].concat(_toConsumableArray(state.ancestors))\n }), entryState, prefs)) {\n return value;\n }\n\n return error('object.assert', {\n ref: path,\n message: message\n });\n },\n args: ['ref', 'schema', 'message'],\n multi: true\n },\n instance: {\n method: function method(constructor, name) {\n Assert(typeof constructor === 'function', 'constructor must be a function');\n name = name || constructor.name;\n return this.$_addRule({\n name: 'instance',\n args: {\n constructor: constructor,\n name: name\n }\n });\n },\n validate: function validate(value, helpers, _ref5) {\n var constructor = _ref5.constructor,\n name = _ref5.name;\n\n if (value instanceof constructor) {\n return value;\n }\n\n return helpers.error('object.instance', {\n type: name,\n value: value\n });\n },\n args: ['constructor', 'name']\n },\n keys: {\n method: function method(schema) {\n var _this = this;\n\n Assert(schema === undefined || _typeof(schema) === 'object', 'Object schema must be a valid object');\n Assert(!Common.isSchema(schema), 'Object schema cannot be a joi schema');\n var obj = this.clone();\n\n if (!schema) {\n // Allow all\n obj.$_terms.keys = null;\n } else if (!Object.keys(schema).length) {\n // Allow none\n obj.$_terms.keys = [];\n } else {\n obj.$_terms.keys = obj.$_terms.keys ? obj.$_terms.keys.filter(function (child) {\n return !schema.hasOwnProperty(child.key);\n }) : [];\n\n var _loop = function _loop(key) {\n Common.tryWithPath(function () {\n return obj.$_terms.keys.push({\n key: key,\n schema: _this.$_compile(schema[key])\n });\n }, key);\n };\n\n for (var key in schema) {\n _loop(key);\n }\n }\n\n return obj.$_mutateRebuild();\n }\n },\n length: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'length',\n args: {\n limit: limit\n },\n operator: '='\n });\n },\n validate: function validate(value, helpers, _ref6, _ref7) {\n var limit = _ref6.limit;\n var name = _ref7.name,\n operator = _ref7.operator,\n args = _ref7.args;\n\n if (Common.compare(Object.keys(value).length, limit, operator)) {\n return value;\n }\n\n return helpers.error('object.' + name, {\n limit: args.limit,\n value: value\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.limit,\n message: 'must be a positive integer'\n }]\n },\n max: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'max',\n method: 'length',\n args: {\n limit: limit\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'min',\n method: 'length',\n args: {\n limit: limit\n },\n operator: '>='\n });\n }\n },\n nand: {\n method: function method()\n /*, [options] */\n {\n for (var _len2 = arguments.length, peers = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n peers[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(peers, 'nand');\n return internals.dependency(this, 'nand', null, peers);\n }\n },\n or: {\n method: function method()\n /*, [options] */\n {\n for (var _len3 = arguments.length, peers = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n peers[_key3] = arguments[_key3];\n }\n\n Common.verifyFlat(peers, 'or');\n return internals.dependency(this, 'or', null, peers);\n }\n },\n oxor: {\n method: function method()\n /*, [options] */\n {\n for (var _len4 = arguments.length, peers = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n peers[_key4] = arguments[_key4];\n }\n\n return internals.dependency(this, 'oxor', null, peers);\n }\n },\n pattern: {\n method: function method(pattern, schema) {\n var _config;\n\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var isRegExp = pattern instanceof RegExp;\n Assert(isRegExp || Common.isSchema(pattern), 'pattern must be a regex or schema');\n Assert(schema !== undefined, 'Invalid rule');\n Common.assertOptions(options, ['exclusive', 'matches']);\n\n if (isRegExp) {\n Assert(!pattern.flags.includes('g') && !pattern.flags.includes('y'), 'pattern should not use global or sticky mode');\n }\n\n schema = this.$_compile(schema, {\n appendPath: true\n });\n var obj = this.clone();\n obj.$_terms.patterns = obj.$_terms.patterns || [];\n var config = (_config = {}, _defineProperty(_config, isRegExp ? 'regex' : 'schema', pattern), _defineProperty(_config, \"rule\", schema), _config);\n\n if (options.matches) {\n config.matches = this.$_compile(options.matches);\n obj.$_mutateRegister(config.matches);\n }\n\n if (options.exclusive) {\n config.exclusive = true;\n }\n\n obj.$_terms.patterns.push(config);\n obj.$_mutateRegister(schema);\n return obj;\n }\n },\n ref: {\n method: function method() {\n return this.$_addRule('ref');\n },\n validate: function validate(value, helpers) {\n if (Ref.isRef(value)) {\n return value;\n }\n\n return helpers.error('object.refType', {\n value: value\n });\n }\n },\n rename: {\n method: function method(from, to) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(typeof from === 'string' || from instanceof RegExp, 'Rename missing the from argument');\n Assert(typeof to === 'string' || to instanceof Template, 'Invalid rename to argument');\n Assert(to !== from, 'Cannot rename key to same name:', from);\n Common.assertOptions(options, ['alias', 'ignoreUndefined', 'override', 'multiple']);\n var obj = this.clone();\n obj.$_terms.renames = obj.$_terms.renames || [];\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = obj.$_terms.renames[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var rename = _step3.value;\n Assert(rename.from !== from, 'Cannot rename the same key multiple times');\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n if (to instanceof Template) {\n obj.$_mutateRegister(to);\n }\n\n obj.$_terms.renames.push({\n from: from,\n to: to,\n options: ApplyToDefaults(internals.renameDefaults, options)\n });\n return obj;\n }\n },\n schema: {\n method: function method() {\n var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'any';\n return this.$_addRule({\n name: 'schema',\n args: {\n type: type\n }\n });\n },\n validate: function validate(value, helpers, _ref8) {\n var type = _ref8.type;\n\n if (Common.isSchema(value) && (type === 'any' || value.type === type)) {\n return value;\n }\n\n return helpers.error('object.schema', {\n type: type\n });\n }\n },\n unknown: {\n method: function method(allow) {\n return this.$_setFlag('unknown', allow !== false);\n }\n },\n with: {\n method: function method(key, peers) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return internals.dependency(this, 'with', key, peers, options);\n }\n },\n without: {\n method: function method(key, peers) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return internals.dependency(this, 'without', key, peers, options);\n }\n },\n xor: {\n method: function method()\n /*, [options] */\n {\n for (var _len5 = arguments.length, peers = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {\n peers[_key5] = arguments[_key5];\n }\n\n Common.verifyFlat(peers, 'xor');\n return internals.dependency(this, 'xor', null, peers);\n }\n }\n },\n // Overrides\n overrides: {\n default: function _default(value, options) {\n if (value === undefined) {\n value = Common.symbols.deepDefault;\n }\n\n return this.super.default(value, options);\n },\n tailor: function tailor(targets) {\n var obj = this.super.tailor(targets);\n\n if (obj === this) {\n obj = this.clone();\n }\n\n if (obj.$_terms.keys) {\n for (var i = 0; i < obj.$_terms.keys.length; ++i) {\n var child = obj.$_terms.keys[i];\n obj.$_terms.keys[i] = Object.assign({}, child, {\n schema: child.schema.tailor(targets)\n });\n }\n }\n\n if (obj.$_terms.patterns) {\n for (var _i = 0; _i < obj.$_terms.patterns.length; ++_i) {\n var pattern = obj.$_terms.patterns[_i];\n\n for (var _i2 = 0, _arr = ['schema', 'rule', 'matches']; _i2 < _arr.length; _i2++) {\n var key = _arr[_i2];\n\n if (pattern[key]) {\n obj.$_terms.patterns[_i] = Object.assign({}, pattern, _defineProperty({}, key, pattern[key].tailor(targets)));\n }\n }\n }\n }\n\n obj = obj.$_replaceRules('assert', function (rule) {\n var clone = Clone(rule);\n clone.options.args.schema = clone.options.args.schema.tailor(targets);\n return clone;\n });\n return obj.$_mutateRebuild();\n }\n },\n // Cast\n cast: {\n map: {\n from: function from(value) {\n return value && _typeof(value) === 'object';\n },\n to: function to(value, helpers) {\n return new Map(Object.entries(value));\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n if (desc.keys) {\n obj = obj.keys(desc.keys);\n }\n\n if (desc.dependencies) {\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = desc.dependencies[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var _step4$value = _step4.value,\n type = _step4$value.type,\n _step4$value$key = _step4$value.key,\n key = _step4$value$key === void 0 ? null : _step4$value$key,\n peers = _step4$value.peers,\n options = _step4$value.options;\n obj = internals.dependency(obj, type, key, peers, options);\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n }\n\n if (desc.patterns) {\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = desc.patterns[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var _step5$value = _step5.value,\n regex = _step5$value.regex,\n schema = _step5$value.schema,\n rule = _step5$value.rule,\n exclusive = _step5$value.exclusive,\n matches = _step5$value.matches;\n obj = obj.pattern(regex || schema, rule, {\n exclusive: exclusive,\n matches: matches\n });\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n }\n\n if (desc.renames) {\n var _iteratorNormalCompletion6 = true;\n var _didIteratorError6 = false;\n var _iteratorError6 = undefined;\n\n try {\n for (var _iterator6 = desc.renames[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {\n var _step6$value = _step6.value,\n from = _step6$value.from,\n to = _step6$value.to,\n options = _step6$value.options;\n obj = obj.rename(from, to, options);\n }\n } catch (err) {\n _didIteratorError6 = true;\n _iteratorError6 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion6 && _iterator6.return != null) {\n _iterator6.return();\n }\n } finally {\n if (_didIteratorError6) {\n throw _iteratorError6;\n }\n }\n }\n }\n\n return obj;\n },\n // Modify\n modify: function modify(schema, id, replacement) {\n if (schema.$_terms.keys) {\n var _iteratorNormalCompletion7 = true;\n var _didIteratorError7 = false;\n var _iteratorError7 = undefined;\n\n try {\n for (var _iterator7 = schema.$_terms.keys[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {\n var child = _step7.value;\n var childId = child.schema._flags.id || child.key;\n\n if (id === childId) {\n return schema.keys(_defineProperty({}, child.key, replacement));\n }\n }\n } catch (err) {\n _didIteratorError7 = true;\n _iteratorError7 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion7 && _iterator7.return != null) {\n _iterator7.return();\n }\n } finally {\n if (_didIteratorError7) {\n throw _iteratorError7;\n }\n }\n }\n }\n\n if (schema.$_terms.patterns) {\n for (var i = 0; i < schema.$_terms.patterns.length; ++i) {\n var pattern = schema.$_terms.patterns[i];\n\n for (var _i3 = 0, _arr2 = ['schema', 'rule', 'matches']; _i3 < _arr2.length; _i3++) {\n var key = _arr2[_i3];\n\n if (pattern[key] && id === pattern[key]._flags.id) {\n var obj = schema.clone();\n obj.$_terms.patterns[i] = Object.assign({}, pattern, _defineProperty({}, key, replacement));\n return obj.$_mutateRebuild();\n }\n }\n }\n }\n\n var modified = schema.$_replaceRules('assert', function (rule) {\n if (id === rule.options.args.schema._flags.id) {\n var clone = Clone(rule);\n clone.options.args.schema = replacement;\n clone.args = clone.options.args;\n return clone;\n }\n });\n\n if (modified !== schema) {\n return modified;\n }\n },\n rebuild: function rebuild(schema) {\n if (schema.$_terms.keys) {\n (function () {\n var topo = new Topo();\n var _iteratorNormalCompletion8 = true;\n var _didIteratorError8 = false;\n var _iteratorError8 = undefined;\n\n try {\n var _loop2 = function _loop2() {\n var child = _step8.value;\n Common.tryWithPath(function () {\n return topo.add(child, {\n after: child.schema.$_rootReferences(),\n group: child.key\n });\n }, child.key);\n schema.$_mutateRegister(child.schema, {\n key: child.key\n });\n };\n\n for (var _iterator8 = schema.$_terms.keys[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {\n _loop2();\n }\n } catch (err) {\n _didIteratorError8 = true;\n _iteratorError8 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion8 && _iterator8.return != null) {\n _iterator8.return();\n }\n } finally {\n if (_didIteratorError8) {\n throw _iteratorError8;\n }\n }\n }\n\n schema.$_terms.keys = _construct(internals.Keys, _toConsumableArray(topo.nodes));\n })();\n }\n\n if (schema.$_terms.patterns) {\n var _iteratorNormalCompletion9 = true;\n var _didIteratorError9 = false;\n var _iteratorError9 = undefined;\n\n try {\n for (var _iterator9 = schema.$_terms.patterns[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {\n var pattern = _step9.value;\n\n for (var _i4 = 0, _arr3 = ['schema', 'rule', 'matches']; _i4 < _arr3.length; _i4++) {\n var key = _arr3[_i4];\n schema.$_mutateRegister(pattern[key]);\n }\n }\n } catch (err) {\n _didIteratorError9 = true;\n _iteratorError9 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion9 && _iterator9.return != null) {\n _iterator9.return();\n }\n } finally {\n if (_didIteratorError9) {\n throw _iteratorError9;\n }\n }\n }\n }\n\n var assertions = schema.$_getRules('assert');\n var _iteratorNormalCompletion10 = true;\n var _didIteratorError10 = false;\n var _iteratorError10 = undefined;\n\n try {\n for (var _iterator10 = assertions[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {\n var assertion = _step10.value;\n schema.$_mutateRegister(assertion.args.schema);\n }\n } catch (err) {\n _didIteratorError10 = true;\n _iteratorError10 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion10 && _iterator10.return != null) {\n _iterator10.return();\n }\n } finally {\n if (_didIteratorError10) {\n throw _iteratorError10;\n }\n }\n }\n\n return schema;\n },\n // Errors\n messages: {\n 'object.and': '\"{{#label}}\" contains {{#presentWithLabels}} without its required peers {{#missingWithLabels}}',\n 'object.assert': '\"{{#label}}\" is invalid because \"{{#ref}}\" failed to {{#message}}',\n 'object.base': '\"{{#label}}\" must be of type {{#type}}',\n 'object.instance': '\"{{#label}}\" must be an instance of \"{{#type}}\"',\n 'object.length': '\"{{#label}}\" must have {{#limit}} keys',\n 'object.max': '\"{{#label}}\" must have less than or equal to {{#limit}} keys',\n 'object.min': '\"{{#label}}\" must have at least {{#limit}} keys',\n 'object.missing': '\"{{#label}}\" must contain at least one of {{#peersWithLabels}}',\n 'object.nand': '\"{{#mainWithLabel}}\" must not exist simultaneously with {{#peersWithLabels}}',\n 'object.oxor': '\"{{#label}}\" contains a conflict between optional exclusive peers {{#peersWithLabels}}',\n 'object.pattern.match': '\"{{#label}}\" keys failed to match pattern requirements',\n 'object.refType': '\"{{#label}}\" must be a Joi reference',\n 'object.rename.multiple': '\"{{#label}}\" cannot rename \"{{#from}}\" because multiple renames are disabled and another key was already renamed to \"{{#to}}\"',\n 'object.rename.override': '\"{{#label}}\" cannot rename \"{{#from}}\" because override is disabled and target \"{{#to}}\" exists',\n 'object.schema': '\"{{#label}}\" must be a Joi schema of {{#type}} type',\n 'object.unknown': '\"{{#label}}\" is not allowed',\n 'object.with': '\"{{#mainWithLabel}}\" missing required peer \"{{#peerWithLabel}}\"',\n 'object.without': '\"{{#mainWithLabel}}\" conflict with forbidden peer \"{{#peerWithLabel}}\"',\n 'object.xor': '\"{{#label}}\" contains a conflict between exclusive peers {{#peersWithLabels}}'\n }\n}); // Helpers\n\ninternals.clone = function (value, prefs) {\n // Object\n if (_typeof(value) === 'object') {\n if (prefs.nonEnumerables) {\n return Clone(value, {\n shallow: true\n });\n }\n\n var _clone = Object.create(Object.getPrototypeOf(value));\n\n Object.assign(_clone, value);\n return _clone;\n } // Function\n\n\n var clone = function clone() {\n for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {\n args[_key6] = arguments[_key6];\n }\n\n return value.apply(this, args);\n };\n\n clone.prototype = Clone(value.prototype);\n Object.defineProperty(clone, 'name', {\n value: value.name,\n writable: false\n });\n Object.defineProperty(clone, 'length', {\n value: value.length,\n writable: false\n });\n Object.assign(clone, value);\n return clone;\n};\n\ninternals.dependency = function (schema, type, key, peers, options) {\n Assert(key === null || typeof key === 'string', type, 'key must be a strings'); // Extract options from peers array\n\n if (!options) {\n options = peers.length > 1 && _typeof(peers[peers.length - 1]) === 'object' ? peers.pop() : {};\n }\n\n Common.assertOptions(options, ['separator']);\n peers = [].concat(peers); // Cast peer paths\n\n var separator = Common.default(options.separator, '.');\n var paths = [];\n var _iteratorNormalCompletion11 = true;\n var _didIteratorError11 = false;\n var _iteratorError11 = undefined;\n\n try {\n for (var _iterator11 = peers[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {\n var peer = _step11.value;\n Assert(typeof peer === 'string', type, 'peers must be a string or a reference');\n paths.push(Compile.ref(peer, {\n separator: separator,\n ancestor: 0\n }));\n } // Cast key\n\n } catch (err) {\n _didIteratorError11 = true;\n _iteratorError11 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion11 && _iterator11.return != null) {\n _iterator11.return();\n }\n } finally {\n if (_didIteratorError11) {\n throw _iteratorError11;\n }\n }\n }\n\n if (key !== null) {\n key = Compile.ref(key, {\n separator: separator,\n ancestor: 0\n });\n } // Add rule\n\n\n var obj = schema.clone();\n obj.$_terms.dependencies = obj.$_terms.dependencies || [];\n obj.$_terms.dependencies.push(new internals.Dependency(type, key, paths, peers));\n return obj;\n};\n\ninternals.dependencies = {\n and: function and(schema, dep, value, state, prefs) {\n var missing = [];\n var present = [];\n var count = dep.peers.length;\n var _iteratorNormalCompletion12 = true;\n var _didIteratorError12 = false;\n var _iteratorError12 = undefined;\n\n try {\n for (var _iterator12 = dep.peers[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {\n var peer = _step12.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) === undefined) {\n missing.push(peer.key);\n } else {\n present.push(peer.key);\n }\n }\n } catch (err) {\n _didIteratorError12 = true;\n _iteratorError12 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion12 && _iterator12.return != null) {\n _iterator12.return();\n }\n } finally {\n if (_didIteratorError12) {\n throw _iteratorError12;\n }\n }\n }\n\n if (missing.length !== count && present.length !== count) {\n return {\n code: 'object.and',\n context: {\n present: present,\n presentWithLabels: internals.keysToLabels(schema, present),\n missing: missing,\n missingWithLabels: internals.keysToLabels(schema, missing)\n }\n };\n }\n },\n nand: function nand(schema, dep, value, state, prefs) {\n var present = [];\n var _iteratorNormalCompletion13 = true;\n var _didIteratorError13 = false;\n var _iteratorError13 = undefined;\n\n try {\n for (var _iterator13 = dep.peers[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {\n var peer = _step13.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n present.push(peer.key);\n }\n }\n } catch (err) {\n _didIteratorError13 = true;\n _iteratorError13 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion13 && _iterator13.return != null) {\n _iterator13.return();\n }\n } finally {\n if (_didIteratorError13) {\n throw _iteratorError13;\n }\n }\n }\n\n if (present.length !== dep.peers.length) {\n return;\n }\n\n var main = dep.paths[0];\n var values = dep.paths.slice(1);\n return {\n code: 'object.nand',\n context: {\n main: main,\n mainWithLabel: internals.keysToLabels(schema, main),\n peers: values,\n peersWithLabels: internals.keysToLabels(schema, values)\n }\n };\n },\n or: function or(schema, dep, value, state, prefs) {\n var _iteratorNormalCompletion14 = true;\n var _didIteratorError14 = false;\n var _iteratorError14 = undefined;\n\n try {\n for (var _iterator14 = dep.peers[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {\n var peer = _step14.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n return;\n }\n }\n } catch (err) {\n _didIteratorError14 = true;\n _iteratorError14 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion14 && _iterator14.return != null) {\n _iterator14.return();\n }\n } finally {\n if (_didIteratorError14) {\n throw _iteratorError14;\n }\n }\n }\n\n return {\n code: 'object.missing',\n context: {\n peers: dep.paths,\n peersWithLabels: internals.keysToLabels(schema, dep.paths)\n }\n };\n },\n oxor: function oxor(schema, dep, value, state, prefs) {\n var present = [];\n var _iteratorNormalCompletion15 = true;\n var _didIteratorError15 = false;\n var _iteratorError15 = undefined;\n\n try {\n for (var _iterator15 = dep.peers[Symbol.iterator](), _step15; !(_iteratorNormalCompletion15 = (_step15 = _iterator15.next()).done); _iteratorNormalCompletion15 = true) {\n var peer = _step15.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n present.push(peer.key);\n }\n }\n } catch (err) {\n _didIteratorError15 = true;\n _iteratorError15 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion15 && _iterator15.return != null) {\n _iterator15.return();\n }\n } finally {\n if (_didIteratorError15) {\n throw _iteratorError15;\n }\n }\n }\n\n if (!present.length || present.length === 1) {\n return;\n }\n\n var context = {\n peers: dep.paths,\n peersWithLabels: internals.keysToLabels(schema, dep.paths)\n };\n context.present = present;\n context.presentWithLabels = internals.keysToLabels(schema, present);\n return {\n code: 'object.oxor',\n context: context\n };\n },\n with: function _with(schema, dep, value, state, prefs) {\n var _iteratorNormalCompletion16 = true;\n var _didIteratorError16 = false;\n var _iteratorError16 = undefined;\n\n try {\n for (var _iterator16 = dep.peers[Symbol.iterator](), _step16; !(_iteratorNormalCompletion16 = (_step16 = _iterator16.next()).done); _iteratorNormalCompletion16 = true) {\n var peer = _step16.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) === undefined) {\n return {\n code: 'object.with',\n context: {\n main: dep.key.key,\n mainWithLabel: internals.keysToLabels(schema, dep.key.key),\n peer: peer.key,\n peerWithLabel: internals.keysToLabels(schema, peer.key)\n }\n };\n }\n }\n } catch (err) {\n _didIteratorError16 = true;\n _iteratorError16 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion16 && _iterator16.return != null) {\n _iterator16.return();\n }\n } finally {\n if (_didIteratorError16) {\n throw _iteratorError16;\n }\n }\n }\n },\n without: function without(schema, dep, value, state, prefs) {\n var _iteratorNormalCompletion17 = true;\n var _didIteratorError17 = false;\n var _iteratorError17 = undefined;\n\n try {\n for (var _iterator17 = dep.peers[Symbol.iterator](), _step17; !(_iteratorNormalCompletion17 = (_step17 = _iterator17.next()).done); _iteratorNormalCompletion17 = true) {\n var peer = _step17.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n return {\n code: 'object.without',\n context: {\n main: dep.key.key,\n mainWithLabel: internals.keysToLabels(schema, dep.key.key),\n peer: peer.key,\n peerWithLabel: internals.keysToLabels(schema, peer.key)\n }\n };\n }\n }\n } catch (err) {\n _didIteratorError17 = true;\n _iteratorError17 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion17 && _iterator17.return != null) {\n _iterator17.return();\n }\n } finally {\n if (_didIteratorError17) {\n throw _iteratorError17;\n }\n }\n }\n },\n xor: function xor(schema, dep, value, state, prefs) {\n var present = [];\n var _iteratorNormalCompletion18 = true;\n var _didIteratorError18 = false;\n var _iteratorError18 = undefined;\n\n try {\n for (var _iterator18 = dep.peers[Symbol.iterator](), _step18; !(_iteratorNormalCompletion18 = (_step18 = _iterator18.next()).done); _iteratorNormalCompletion18 = true) {\n var peer = _step18.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n present.push(peer.key);\n }\n }\n } catch (err) {\n _didIteratorError18 = true;\n _iteratorError18 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion18 && _iterator18.return != null) {\n _iterator18.return();\n }\n } finally {\n if (_didIteratorError18) {\n throw _iteratorError18;\n }\n }\n }\n\n if (present.length === 1) {\n return;\n }\n\n var context = {\n peers: dep.paths,\n peersWithLabels: internals.keysToLabels(schema, dep.paths)\n };\n\n if (present.length === 0) {\n return {\n code: 'object.missing',\n context: context\n };\n }\n\n context.present = present;\n context.presentWithLabels = internals.keysToLabels(schema, present);\n return {\n code: 'object.xor',\n context: context\n };\n }\n};\n\ninternals.keysToLabels = function (schema, keys) {\n if (Array.isArray(keys)) {\n return keys.map(function (key) {\n return schema.$_mapLabels(key);\n });\n }\n\n return schema.$_mapLabels(keys);\n};\n\ninternals.rename = function (schema, value, state, prefs, errors) {\n var renamed = {};\n var _iteratorNormalCompletion19 = true;\n var _didIteratorError19 = false;\n var _iteratorError19 = undefined;\n\n try {\n for (var _iterator19 = schema.$_terms.renames[Symbol.iterator](), _step19; !(_iteratorNormalCompletion19 = (_step19 = _iterator19.next()).done); _iteratorNormalCompletion19 = true) {\n var rename = _step19.value;\n var matches = [];\n var pattern = typeof rename.from !== 'string';\n\n if (!pattern) {\n if (Object.prototype.hasOwnProperty.call(value, rename.from) && (value[rename.from] !== undefined || !rename.options.ignoreUndefined)) {\n matches.push(rename);\n }\n } else {\n for (var from in value) {\n if (value[from] === undefined && rename.options.ignoreUndefined) {\n continue;\n }\n\n if (from === rename.to) {\n continue;\n }\n\n var match = rename.from.exec(from);\n\n if (!match) {\n continue;\n }\n\n matches.push({\n from: from,\n to: rename.to,\n match: match\n });\n }\n }\n\n for (var _i5 = 0, _matches = matches; _i5 < _matches.length; _i5++) {\n var _match = _matches[_i5];\n var _from = _match.from;\n var to = _match.to;\n\n if (to instanceof Template) {\n to = to.render(value, state, prefs, _match.match);\n }\n\n if (_from === to) {\n continue;\n }\n\n if (!rename.options.multiple && renamed[to]) {\n errors.push(schema.$_createError('object.rename.multiple', value, {\n from: _from,\n to: to,\n pattern: pattern\n }, state, prefs));\n\n if (prefs.abortEarly) {\n return false;\n }\n }\n\n if (Object.prototype.hasOwnProperty.call(value, to) && !rename.options.override && !renamed[to]) {\n errors.push(schema.$_createError('object.rename.override', value, {\n from: _from,\n to: to,\n pattern: pattern\n }, state, prefs));\n\n if (prefs.abortEarly) {\n return false;\n }\n }\n\n if (value[_from] === undefined) {\n delete value[to];\n } else {\n value[to] = value[_from];\n }\n\n renamed[to] = true;\n\n if (!rename.options.alias) {\n delete value[_from];\n }\n }\n }\n } catch (err) {\n _didIteratorError19 = true;\n _iteratorError19 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion19 && _iterator19.return != null) {\n _iterator19.return();\n }\n } finally {\n if (_didIteratorError19) {\n throw _iteratorError19;\n }\n }\n }\n\n return true;\n};\n\ninternals.unknown = function (schema, value, unprocessed, errors, state, prefs) {\n if (schema.$_terms.patterns) {\n var hasMatches = false;\n var matches = schema.$_terms.patterns.map(function (pattern) {\n if (pattern.matches) {\n hasMatches = true;\n return [];\n }\n });\n var ancestors = [value];\n var _iteratorNormalCompletion20 = true;\n var _didIteratorError20 = false;\n var _iteratorError20 = undefined;\n\n try {\n for (var _iterator20 = unprocessed[Symbol.iterator](), _step20; !(_iteratorNormalCompletion20 = (_step20 = _iterator20.next()).done); _iteratorNormalCompletion20 = true) {\n var key = _step20.value;\n var item = value[key];\n var path = [].concat(_toConsumableArray(state.path), [key]);\n\n for (var _i6 = 0; _i6 < schema.$_terms.patterns.length; ++_i6) {\n var pattern = schema.$_terms.patterns[_i6];\n\n var _match2 = pattern.regex ? pattern.regex.test(key) : pattern.schema.$_match(key, state.nest(pattern.schema), prefs);\n\n if (!_match2) {\n continue;\n }\n\n unprocessed.delete(key);\n\n var _localState = state.localize(path, ancestors, pattern.rule);\n\n var _result = pattern.rule.$_validate(item, _localState, prefs);\n\n if (_result.errors) {\n if (prefs.abortEarly) {\n return {\n value: value,\n errors: _result.errors\n };\n }\n\n errors.push.apply(errors, _toConsumableArray(_result.errors));\n }\n\n if (pattern.matches) {\n matches[_i6].push(key);\n }\n\n value[key] = _result.value;\n\n if (pattern.exclusive) {\n break;\n }\n }\n } // Validate pattern matches rules\n\n } catch (err) {\n _didIteratorError20 = true;\n _iteratorError20 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion20 && _iterator20.return != null) {\n _iterator20.return();\n }\n } finally {\n if (_didIteratorError20) {\n throw _iteratorError20;\n }\n }\n }\n\n if (hasMatches) {\n for (var i = 0; i < matches.length; ++i) {\n var match = matches[i];\n\n if (!match) {\n continue;\n }\n\n var localState = state.localize(state.path, ancestors, schema.$_terms.patterns[i].matches);\n var result = schema.$_terms.patterns[i].matches.$_validate(match, localState, prefs);\n\n if (result.errors) {\n var details = Errors.details(result.errors, {\n override: false\n });\n details.matches = match;\n var report = schema.$_createError('object.pattern.match', value, details, state, prefs);\n\n if (prefs.abortEarly) {\n return {\n value: value,\n errors: report\n };\n }\n\n errors.push(report);\n }\n }\n }\n }\n\n if (!unprocessed.size || !schema.$_terms.keys && !schema.$_terms.patterns) {\n // If no keys or patterns specified, unknown keys allowed\n return;\n }\n\n if (prefs.stripUnknown && !schema._flags.unknown || prefs.skipFunctions) {\n var stripUnknown = prefs.stripUnknown ? prefs.stripUnknown === true ? true : !!prefs.stripUnknown.objects : false;\n var _iteratorNormalCompletion21 = true;\n var _didIteratorError21 = false;\n var _iteratorError21 = undefined;\n\n try {\n for (var _iterator21 = unprocessed[Symbol.iterator](), _step21; !(_iteratorNormalCompletion21 = (_step21 = _iterator21.next()).done); _iteratorNormalCompletion21 = true) {\n var _key7 = _step21.value;\n\n if (stripUnknown) {\n delete value[_key7];\n unprocessed.delete(_key7);\n } else if (typeof value[_key7] === 'function') {\n unprocessed.delete(_key7);\n }\n }\n } catch (err) {\n _didIteratorError21 = true;\n _iteratorError21 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion21 && _iterator21.return != null) {\n _iterator21.return();\n }\n } finally {\n if (_didIteratorError21) {\n throw _iteratorError21;\n }\n }\n }\n }\n\n var forbidUnknown = !Common.default(schema._flags.unknown, prefs.allowUnknown);\n\n if (forbidUnknown) {\n var _iteratorNormalCompletion22 = true;\n var _didIteratorError22 = false;\n var _iteratorError22 = undefined;\n\n try {\n for (var _iterator22 = unprocessed[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {\n var unprocessedKey = _step22.value;\n\n var _localState2 = state.localize([].concat(_toConsumableArray(state.path), [unprocessedKey]), []);\n\n var _report = schema.$_createError('object.unknown', value[unprocessedKey], {\n child: unprocessedKey\n }, _localState2, prefs, {\n flags: false\n });\n\n if (prefs.abortEarly) {\n return {\n value: value,\n errors: _report\n };\n }\n\n errors.push(_report);\n }\n } catch (err) {\n _didIteratorError22 = true;\n _iteratorError22 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion22 && _iterator22.return != null) {\n _iterator22.return();\n }\n } finally {\n if (_didIteratorError22) {\n throw _iteratorError22;\n }\n }\n }\n }\n};\n\ninternals.Dependency =\n/*#__PURE__*/\nfunction () {\n function _class(type, key, peers, paths) {\n _classCallCheck(this, _class);\n\n this.type = type;\n this.key = key;\n this.peers = peers;\n this.paths = paths;\n }\n\n _createClass(_class, [{\n key: \"describe\",\n value: function describe() {\n var desc = {\n type: this.type,\n peers: this.paths\n };\n\n if (this.key !== null) {\n desc.key = this.key.key;\n }\n\n if (this.peers[0].separator !== '.') {\n desc.options = {\n separator: this.peers[0].separator\n };\n }\n\n return desc;\n }\n }]);\n\n return _class;\n}();\n\ninternals.Keys =\n/*#__PURE__*/\nfunction (_Array) {\n _inherits(_class2, _Array);\n\n function _class2() {\n _classCallCheck(this, _class2);\n\n return _possibleConstructorReturn(this, _getPrototypeOf(_class2).apply(this, arguments));\n }\n\n _createClass(_class2, [{\n key: \"concat\",\n value: function concat(source) {\n var result = this.slice();\n var keys = new Map();\n\n for (var i = 0; i < result.length; ++i) {\n keys.set(result[i].key, i);\n }\n\n var _iteratorNormalCompletion23 = true;\n var _didIteratorError23 = false;\n var _iteratorError23 = undefined;\n\n try {\n for (var _iterator23 = source[Symbol.iterator](), _step23; !(_iteratorNormalCompletion23 = (_step23 = _iterator23.next()).done); _iteratorNormalCompletion23 = true) {\n var item = _step23.value;\n var key = item.key;\n var pos = keys.get(key);\n\n if (pos >= 0) {\n result[pos] = {\n key: key,\n schema: result[pos].schema.concat(item.schema)\n };\n } else {\n result.push(item);\n }\n }\n } catch (err) {\n _didIteratorError23 = true;\n _iteratorError23 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion23 && _iterator23.return != null) {\n _iterator23.return();\n }\n } finally {\n if (_didIteratorError23) {\n throw _iteratorError23;\n }\n }\n }\n\n return result;\n }\n }]);\n\n return _class2;\n}(_wrapNativeSuper(Array));" + "source": "'use strict';\n\nconst ApplyToDefaults = require('@hapi/hoek/lib/applyToDefaults');\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Bourne = require('@hapi/bourne');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Topo = require('@hapi/topo');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst Compile = require('../compile');\n\nconst Errors = require('../errors');\n\nconst Ref = require('../ref');\n\nconst Template = require('../template');\n\nconst internals = {\n renameDefaults: {\n alias: false,\n // Keep old value in place\n multiple: false,\n // Allow renaming multiple keys into the same target\n override: false // Overrides an existing key\n\n }\n};\nmodule.exports = Any.extend({\n type: 'object',\n properties: {\n typeof: 'object'\n },\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.dependencies = null;\n schema.$_terms.keys = null;\n schema.$_terms.patterns = null;\n schema.$_terms.renames = null;\n },\n args: function args(schema, keys) {\n return schema.keys(keys);\n },\n // Coerce\n coerce: {\n from: 'string',\n method: function method(schema, value, helpers) {\n if (value[0] !== '{' && !/^\\s*\\{/.test(value)) {\n return;\n }\n\n try {\n return {\n value: Bourne.parse(value)\n };\n } catch (ignoreErr) {}\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n let {\n error,\n state,\n prefs\n } = _ref;\n\n if (!value || typeof value !== schema.$_property('typeof') || Array.isArray(value)) {\n return {\n value,\n errors: error('object.base', {\n type: schema.$_property('typeof')\n })\n };\n } // Skip if there are no other rules to test\n\n\n if (!schema.$_terms.renames && !schema.$_terms.dependencies && !schema.$_terms.keys && // null allows any keys\n !schema.$_terms.patterns && !schema.$_terms.externals) {\n return;\n } // Shallow clone value\n\n\n value = internals.clone(value, prefs);\n const errors = []; // Rename keys\n\n if (schema.$_terms.renames && !internals.rename(schema, value, state, prefs, errors)) {\n return {\n value,\n errors\n };\n } // Anything allowed\n\n\n if (!schema.$_terms.keys && // null allows any keys\n !schema.$_terms.patterns && !schema.$_terms.dependencies) {\n return {\n value,\n errors\n };\n } // Defined keys\n\n\n const unprocessed = new Set(Object.keys(value));\n\n if (schema.$_terms.keys) {\n const ancestors = [value, ...state.ancestors];\n\n for (const child of schema.$_terms.keys) {\n const key = child.key;\n const item = value[key];\n unprocessed.delete(key);\n const localState = state.localize([...state.path, key], ancestors, child.schema);\n const result = child.schema.$_validate(item, localState, prefs);\n\n if (result.errors) {\n if (prefs.abortEarly) {\n return {\n value,\n errors: result.errors\n };\n }\n\n errors.push(...result.errors);\n } else if (child.schema._flags.result === 'strip' || result.value === undefined && item !== undefined) {\n delete value[key];\n } else if (result.value !== undefined) {\n value[key] = result.value;\n }\n }\n } // Unknown keys\n\n\n if (unprocessed.size) {\n const early = internals.unknown(schema, value, unprocessed, errors, state, prefs);\n\n if (early) {\n return early;\n }\n } // Validate dependencies\n\n\n if (schema.$_terms.dependencies) {\n for (const dep of schema.$_terms.dependencies) {\n if (dep.key && dep.key.resolve(value, state, prefs, null, {\n shadow: false\n }) === undefined) {\n continue;\n }\n\n const failed = internals.dependencies[dep.type](schema, dep, value, state, prefs);\n\n if (failed) {\n const report = schema.$_createError(failed.code, value, failed.context, state, prefs);\n\n if (prefs.abortEarly) {\n return {\n value,\n errors: report\n };\n }\n\n errors.push(report);\n }\n }\n }\n\n return {\n value,\n errors\n };\n },\n // Rules\n rules: {\n and: {\n method: function method()\n /*, [options] */\n {\n for (var _len = arguments.length, peers = new Array(_len), _key = 0; _key < _len; _key++) {\n peers[_key] = arguments[_key];\n }\n\n Common.verifyFlat(peers, 'and');\n return internals.dependency(this, 'and', null, peers);\n }\n },\n append: {\n method: function method(schema) {\n if (schema === null || schema === undefined || Object.keys(schema).length === 0) {\n return this;\n }\n\n return this.keys(schema);\n }\n },\n assert: {\n method: function method(ref, schema, message) {\n ref = Compile.ref(ref);\n Assert(ref.type === 'global' || ref.depth > 1, 'Cannot use assertions for root level references - use direct key rules instead');\n message = message || 'pass the assertion test';\n Assert(typeof message === 'string', 'Message must be a string');\n schema = this.$_compile(schema, {\n appendPath: true\n });\n const path = ref.path.join('.');\n const obj = this.$_addRule({\n name: 'assert',\n args: {\n ref,\n schema,\n message\n },\n path\n });\n obj.$_mutateRegister(schema);\n return obj;\n },\n validate: function validate(value, _ref2, _ref3, _ref4) {\n let {\n error,\n prefs,\n state\n } = _ref2;\n let {\n ref,\n schema,\n message\n } = _ref3;\n let {\n path\n } = _ref4;\n const entryState = state.entry(schema, value);\n\n if (schema.$_match(ref.resolve(null, {\n ancestors: [value, ...state.ancestors]\n }), entryState, prefs)) {\n return value;\n }\n\n return error('object.assert', {\n ref: path,\n message\n });\n },\n args: ['ref', 'schema', 'message'],\n multi: true\n },\n instance: {\n method: function method(constructor, name) {\n Assert(typeof constructor === 'function', 'constructor must be a function');\n name = name || constructor.name;\n return this.$_addRule({\n name: 'instance',\n args: {\n constructor,\n name\n }\n });\n },\n validate: function validate(value, helpers, _ref5) {\n let {\n constructor,\n name\n } = _ref5;\n\n if (value instanceof constructor) {\n return value;\n }\n\n return helpers.error('object.instance', {\n type: name,\n value\n });\n },\n args: ['constructor', 'name']\n },\n keys: {\n method: function method(schema) {\n Assert(schema === undefined || typeof schema === 'object', 'Object schema must be a valid object');\n Assert(!Common.isSchema(schema), 'Object schema cannot be a joi schema');\n const obj = this.clone();\n\n if (!schema) {\n // Allow all\n obj.$_terms.keys = null;\n } else if (!Object.keys(schema).length) {\n // Allow none\n obj.$_terms.keys = [];\n } else {\n obj.$_terms.keys = obj.$_terms.keys ? obj.$_terms.keys.filter(child => !schema.hasOwnProperty(child.key)) : [];\n\n for (const key in schema) {\n Common.tryWithPath(() => obj.$_terms.keys.push({\n key,\n schema: this.$_compile(schema[key])\n }), key);\n }\n }\n\n return obj.$_mutateRebuild();\n }\n },\n length: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'length',\n args: {\n limit\n },\n operator: '='\n });\n },\n validate: function validate(value, helpers, _ref6, _ref7) {\n let {\n limit\n } = _ref6;\n let {\n name,\n operator,\n args\n } = _ref7;\n\n if (Common.compare(Object.keys(value).length, limit, operator)) {\n return value;\n }\n\n return helpers.error('object.' + name, {\n limit: args.limit,\n value\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.limit,\n message: 'must be a positive integer'\n }]\n },\n max: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'max',\n method: 'length',\n args: {\n limit\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'min',\n method: 'length',\n args: {\n limit\n },\n operator: '>='\n });\n }\n },\n nand: {\n method: function method()\n /*, [options] */\n {\n for (var _len2 = arguments.length, peers = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n peers[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(peers, 'nand');\n return internals.dependency(this, 'nand', null, peers);\n }\n },\n or: {\n method: function method()\n /*, [options] */\n {\n for (var _len3 = arguments.length, peers = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n peers[_key3] = arguments[_key3];\n }\n\n Common.verifyFlat(peers, 'or');\n return internals.dependency(this, 'or', null, peers);\n }\n },\n oxor: {\n method: function method()\n /*, [options] */\n {\n for (var _len4 = arguments.length, peers = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n peers[_key4] = arguments[_key4];\n }\n\n return internals.dependency(this, 'oxor', null, peers);\n }\n },\n pattern: {\n method: function method(pattern, schema) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n const isRegExp = pattern instanceof RegExp;\n Assert(isRegExp || Common.isSchema(pattern), 'pattern must be a regex or schema');\n Assert(schema !== undefined, 'Invalid rule');\n Common.assertOptions(options, ['exclusive', 'matches']);\n\n if (isRegExp) {\n Assert(!pattern.flags.includes('g') && !pattern.flags.includes('y'), 'pattern should not use global or sticky mode');\n }\n\n schema = this.$_compile(schema, {\n appendPath: true\n });\n const obj = this.clone();\n obj.$_terms.patterns = obj.$_terms.patterns || [];\n const config = {\n [isRegExp ? 'regex' : 'schema']: pattern,\n rule: schema\n };\n\n if (options.matches) {\n config.matches = this.$_compile(options.matches);\n obj.$_mutateRegister(config.matches);\n }\n\n if (options.exclusive) {\n config.exclusive = true;\n }\n\n obj.$_terms.patterns.push(config);\n obj.$_mutateRegister(schema);\n return obj;\n }\n },\n ref: {\n method: function method() {\n return this.$_addRule('ref');\n },\n validate: function validate(value, helpers) {\n if (Ref.isRef(value)) {\n return value;\n }\n\n return helpers.error('object.refType', {\n value\n });\n }\n },\n rename: {\n method: function method(from, to) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(typeof from === 'string' || from instanceof RegExp, 'Rename missing the from argument');\n Assert(typeof to === 'string' || to instanceof Template, 'Invalid rename to argument');\n Assert(to !== from, 'Cannot rename key to same name:', from);\n Common.assertOptions(options, ['alias', 'ignoreUndefined', 'override', 'multiple']);\n const obj = this.clone();\n obj.$_terms.renames = obj.$_terms.renames || [];\n\n for (const rename of obj.$_terms.renames) {\n Assert(rename.from !== from, 'Cannot rename the same key multiple times');\n }\n\n if (to instanceof Template) {\n obj.$_mutateRegister(to);\n }\n\n obj.$_terms.renames.push({\n from,\n to,\n options: ApplyToDefaults(internals.renameDefaults, options)\n });\n return obj;\n }\n },\n schema: {\n method: function method() {\n let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'any';\n return this.$_addRule({\n name: 'schema',\n args: {\n type\n }\n });\n },\n validate: function validate(value, helpers, _ref8) {\n let {\n type\n } = _ref8;\n\n if (Common.isSchema(value) && (type === 'any' || value.type === type)) {\n return value;\n }\n\n return helpers.error('object.schema', {\n type\n });\n }\n },\n unknown: {\n method: function method(allow) {\n return this.$_setFlag('unknown', allow !== false);\n }\n },\n with: {\n method: function method(key, peers) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return internals.dependency(this, 'with', key, peers, options);\n }\n },\n without: {\n method: function method(key, peers) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return internals.dependency(this, 'without', key, peers, options);\n }\n },\n xor: {\n method: function method()\n /*, [options] */\n {\n for (var _len5 = arguments.length, peers = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {\n peers[_key5] = arguments[_key5];\n }\n\n Common.verifyFlat(peers, 'xor');\n return internals.dependency(this, 'xor', null, peers);\n }\n }\n },\n // Overrides\n overrides: {\n default: function _default(value, options) {\n if (value === undefined) {\n value = Common.symbols.deepDefault;\n }\n\n return this.super.default(value, options);\n },\n tailor: function tailor(targets) {\n let obj = this.super.tailor(targets);\n\n if (obj === this) {\n obj = this.clone();\n }\n\n if (obj.$_terms.keys) {\n for (let i = 0; i < obj.$_terms.keys.length; ++i) {\n const child = obj.$_terms.keys[i];\n obj.$_terms.keys[i] = Object.assign({}, child, {\n schema: child.schema.tailor(targets)\n });\n }\n }\n\n if (obj.$_terms.patterns) {\n for (let i = 0; i < obj.$_terms.patterns.length; ++i) {\n const pattern = obj.$_terms.patterns[i];\n\n for (const key of ['schema', 'rule', 'matches']) {\n if (pattern[key]) {\n obj.$_terms.patterns[i] = Object.assign({}, pattern, {\n [key]: pattern[key].tailor(targets)\n });\n }\n }\n }\n }\n\n obj = obj.$_replaceRules('assert', rule => {\n const clone = Clone(rule);\n clone.options.args.schema = clone.options.args.schema.tailor(targets);\n return clone;\n });\n return obj.$_mutateRebuild();\n }\n },\n // Cast\n cast: {\n map: {\n from: value => value && typeof value === 'object',\n to: function to(value, helpers) {\n return new Map(Object.entries(value));\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n if (desc.keys) {\n obj = obj.keys(desc.keys);\n }\n\n if (desc.dependencies) {\n for (const _ref9 of desc.dependencies) {\n const {\n type,\n key = null,\n peers,\n options\n } = _ref9;\n obj = internals.dependency(obj, type, key, peers, options);\n }\n }\n\n if (desc.patterns) {\n for (const _ref10 of desc.patterns) {\n const {\n regex,\n schema,\n rule,\n exclusive,\n matches\n } = _ref10;\n obj = obj.pattern(regex || schema, rule, {\n exclusive,\n matches\n });\n }\n }\n\n if (desc.renames) {\n for (const _ref11 of desc.renames) {\n const {\n from,\n to,\n options\n } = _ref11;\n obj = obj.rename(from, to, options);\n }\n }\n\n return obj;\n },\n // Modify\n modify: function modify(schema, id, replacement) {\n if (schema.$_terms.keys) {\n for (const child of schema.$_terms.keys) {\n const childId = child.schema._flags.id || child.key;\n\n if (id === childId) {\n return schema.keys({\n [child.key]: replacement\n });\n }\n }\n }\n\n if (schema.$_terms.patterns) {\n for (let i = 0; i < schema.$_terms.patterns.length; ++i) {\n const pattern = schema.$_terms.patterns[i];\n\n for (const key of ['schema', 'rule', 'matches']) {\n if (pattern[key] && id === pattern[key]._flags.id) {\n const obj = schema.clone();\n obj.$_terms.patterns[i] = Object.assign({}, pattern, {\n [key]: replacement\n });\n return obj.$_mutateRebuild();\n }\n }\n }\n }\n\n const modified = schema.$_replaceRules('assert', rule => {\n if (id === rule.options.args.schema._flags.id) {\n const clone = Clone(rule);\n clone.options.args.schema = replacement;\n clone.args = clone.options.args;\n return clone;\n }\n });\n\n if (modified !== schema) {\n return modified;\n }\n },\n rebuild: function rebuild(schema) {\n if (schema.$_terms.keys) {\n const topo = new Topo();\n\n for (const child of schema.$_terms.keys) {\n Common.tryWithPath(() => topo.add(child, {\n after: child.schema.$_rootReferences(),\n group: child.key\n }), child.key);\n schema.$_mutateRegister(child.schema, {\n key: child.key\n });\n }\n\n schema.$_terms.keys = new internals.Keys(...topo.nodes);\n }\n\n if (schema.$_terms.patterns) {\n for (const pattern of schema.$_terms.patterns) {\n for (const key of ['schema', 'rule', 'matches']) {\n schema.$_mutateRegister(pattern[key]);\n }\n }\n }\n\n const assertions = schema.$_getRules('assert');\n\n for (const assertion of assertions) {\n schema.$_mutateRegister(assertion.args.schema);\n }\n\n return schema;\n },\n // Errors\n messages: {\n 'object.and': '\"{{#label}}\" contains {{#presentWithLabels}} without its required peers {{#missingWithLabels}}',\n 'object.assert': '\"{{#label}}\" is invalid because \"{{#ref}}\" failed to {{#message}}',\n 'object.base': '\"{{#label}}\" must be of type {{#type}}',\n 'object.instance': '\"{{#label}}\" must be an instance of \"{{#type}}\"',\n 'object.length': '\"{{#label}}\" must have {{#limit}} keys',\n 'object.max': '\"{{#label}}\" must have less than or equal to {{#limit}} keys',\n 'object.min': '\"{{#label}}\" must have at least {{#limit}} keys',\n 'object.missing': '\"{{#label}}\" must contain at least one of {{#peersWithLabels}}',\n 'object.nand': '\"{{#mainWithLabel}}\" must not exist simultaneously with {{#peersWithLabels}}',\n 'object.oxor': '\"{{#label}}\" contains a conflict between optional exclusive peers {{#peersWithLabels}}',\n 'object.pattern.match': '\"{{#label}}\" keys failed to match pattern requirements',\n 'object.refType': '\"{{#label}}\" must be a Joi reference',\n 'object.rename.multiple': '\"{{#label}}\" cannot rename \"{{#from}}\" because multiple renames are disabled and another key was already renamed to \"{{#to}}\"',\n 'object.rename.override': '\"{{#label}}\" cannot rename \"{{#from}}\" because override is disabled and target \"{{#to}}\" exists',\n 'object.schema': '\"{{#label}}\" must be a Joi schema of {{#type}} type',\n 'object.unknown': '\"{{#label}}\" is not allowed',\n 'object.with': '\"{{#mainWithLabel}}\" missing required peer \"{{#peerWithLabel}}\"',\n 'object.without': '\"{{#mainWithLabel}}\" conflict with forbidden peer \"{{#peerWithLabel}}\"',\n 'object.xor': '\"{{#label}}\" contains a conflict between exclusive peers {{#peersWithLabels}}'\n }\n}); // Helpers\n\ninternals.clone = function (value, prefs) {\n // Object\n if (typeof value === 'object') {\n if (prefs.nonEnumerables) {\n return Clone(value, {\n shallow: true\n });\n }\n\n const clone = Object.create(Object.getPrototypeOf(value));\n Object.assign(clone, value);\n return clone;\n } // Function\n\n\n const clone = function clone() {\n for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {\n args[_key6] = arguments[_key6];\n }\n\n return value.apply(this, args);\n };\n\n clone.prototype = Clone(value.prototype);\n Object.defineProperty(clone, 'name', {\n value: value.name,\n writable: false\n });\n Object.defineProperty(clone, 'length', {\n value: value.length,\n writable: false\n });\n Object.assign(clone, value);\n return clone;\n};\n\ninternals.dependency = function (schema, type, key, peers, options) {\n Assert(key === null || typeof key === 'string', type, 'key must be a strings'); // Extract options from peers array\n\n if (!options) {\n options = peers.length > 1 && typeof peers[peers.length - 1] === 'object' ? peers.pop() : {};\n }\n\n Common.assertOptions(options, ['separator']);\n peers = [].concat(peers); // Cast peer paths\n\n const separator = Common.default(options.separator, '.');\n const paths = [];\n\n for (const peer of peers) {\n Assert(typeof peer === 'string', type, 'peers must be a string or a reference');\n paths.push(Compile.ref(peer, {\n separator,\n ancestor: 0\n }));\n } // Cast key\n\n\n if (key !== null) {\n key = Compile.ref(key, {\n separator,\n ancestor: 0\n });\n } // Add rule\n\n\n const obj = schema.clone();\n obj.$_terms.dependencies = obj.$_terms.dependencies || [];\n obj.$_terms.dependencies.push(new internals.Dependency(type, key, paths, peers));\n return obj;\n};\n\ninternals.dependencies = {\n and: function and(schema, dep, value, state, prefs) {\n const missing = [];\n const present = [];\n const count = dep.peers.length;\n\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) === undefined) {\n missing.push(peer.key);\n } else {\n present.push(peer.key);\n }\n }\n\n if (missing.length !== count && present.length !== count) {\n return {\n code: 'object.and',\n context: {\n present,\n presentWithLabels: internals.keysToLabels(schema, present),\n missing,\n missingWithLabels: internals.keysToLabels(schema, missing)\n }\n };\n }\n },\n nand: function nand(schema, dep, value, state, prefs) {\n const present = [];\n\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n present.push(peer.key);\n }\n }\n\n if (present.length !== dep.peers.length) {\n return;\n }\n\n const main = dep.paths[0];\n const values = dep.paths.slice(1);\n return {\n code: 'object.nand',\n context: {\n main,\n mainWithLabel: internals.keysToLabels(schema, main),\n peers: values,\n peersWithLabels: internals.keysToLabels(schema, values)\n }\n };\n },\n or: function or(schema, dep, value, state, prefs) {\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n return;\n }\n }\n\n return {\n code: 'object.missing',\n context: {\n peers: dep.paths,\n peersWithLabels: internals.keysToLabels(schema, dep.paths)\n }\n };\n },\n oxor: function oxor(schema, dep, value, state, prefs) {\n const present = [];\n\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n present.push(peer.key);\n }\n }\n\n if (!present.length || present.length === 1) {\n return;\n }\n\n const context = {\n peers: dep.paths,\n peersWithLabels: internals.keysToLabels(schema, dep.paths)\n };\n context.present = present;\n context.presentWithLabels = internals.keysToLabels(schema, present);\n return {\n code: 'object.oxor',\n context\n };\n },\n with: function _with(schema, dep, value, state, prefs) {\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) === undefined) {\n return {\n code: 'object.with',\n context: {\n main: dep.key.key,\n mainWithLabel: internals.keysToLabels(schema, dep.key.key),\n peer: peer.key,\n peerWithLabel: internals.keysToLabels(schema, peer.key)\n }\n };\n }\n }\n },\n without: function without(schema, dep, value, state, prefs) {\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n return {\n code: 'object.without',\n context: {\n main: dep.key.key,\n mainWithLabel: internals.keysToLabels(schema, dep.key.key),\n peer: peer.key,\n peerWithLabel: internals.keysToLabels(schema, peer.key)\n }\n };\n }\n }\n },\n xor: function xor(schema, dep, value, state, prefs) {\n const present = [];\n\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n present.push(peer.key);\n }\n }\n\n if (present.length === 1) {\n return;\n }\n\n const context = {\n peers: dep.paths,\n peersWithLabels: internals.keysToLabels(schema, dep.paths)\n };\n\n if (present.length === 0) {\n return {\n code: 'object.missing',\n context\n };\n }\n\n context.present = present;\n context.presentWithLabels = internals.keysToLabels(schema, present);\n return {\n code: 'object.xor',\n context\n };\n }\n};\n\ninternals.keysToLabels = function (schema, keys) {\n if (Array.isArray(keys)) {\n return keys.map(key => schema.$_mapLabels(key));\n }\n\n return schema.$_mapLabels(keys);\n};\n\ninternals.rename = function (schema, value, state, prefs, errors) {\n const renamed = {};\n\n for (const rename of schema.$_terms.renames) {\n const matches = [];\n const pattern = typeof rename.from !== 'string';\n\n if (!pattern) {\n if (Object.prototype.hasOwnProperty.call(value, rename.from) && (value[rename.from] !== undefined || !rename.options.ignoreUndefined)) {\n matches.push(rename);\n }\n } else {\n for (const from in value) {\n if (value[from] === undefined && rename.options.ignoreUndefined) {\n continue;\n }\n\n if (from === rename.to) {\n continue;\n }\n\n const match = rename.from.exec(from);\n\n if (!match) {\n continue;\n }\n\n matches.push({\n from,\n to: rename.to,\n match\n });\n }\n }\n\n for (const match of matches) {\n const from = match.from;\n let to = match.to;\n\n if (to instanceof Template) {\n to = to.render(value, state, prefs, match.match);\n }\n\n if (from === to) {\n continue;\n }\n\n if (!rename.options.multiple && renamed[to]) {\n errors.push(schema.$_createError('object.rename.multiple', value, {\n from,\n to,\n pattern\n }, state, prefs));\n\n if (prefs.abortEarly) {\n return false;\n }\n }\n\n if (Object.prototype.hasOwnProperty.call(value, to) && !rename.options.override && !renamed[to]) {\n errors.push(schema.$_createError('object.rename.override', value, {\n from,\n to,\n pattern\n }, state, prefs));\n\n if (prefs.abortEarly) {\n return false;\n }\n }\n\n if (value[from] === undefined) {\n delete value[to];\n } else {\n value[to] = value[from];\n }\n\n renamed[to] = true;\n\n if (!rename.options.alias) {\n delete value[from];\n }\n }\n }\n\n return true;\n};\n\ninternals.unknown = function (schema, value, unprocessed, errors, state, prefs) {\n if (schema.$_terms.patterns) {\n let hasMatches = false;\n const matches = schema.$_terms.patterns.map(pattern => {\n if (pattern.matches) {\n hasMatches = true;\n return [];\n }\n });\n const ancestors = [value];\n\n for (const key of unprocessed) {\n const item = value[key];\n const path = [...state.path, key];\n\n for (let i = 0; i < schema.$_terms.patterns.length; ++i) {\n const pattern = schema.$_terms.patterns[i];\n const match = pattern.regex ? pattern.regex.test(key) : pattern.schema.$_match(key, state.nest(pattern.schema), prefs);\n\n if (!match) {\n continue;\n }\n\n unprocessed.delete(key);\n const localState = state.localize(path, ancestors, pattern.rule);\n const result = pattern.rule.$_validate(item, localState, prefs);\n\n if (result.errors) {\n if (prefs.abortEarly) {\n return {\n value,\n errors: result.errors\n };\n }\n\n errors.push(...result.errors);\n }\n\n if (pattern.matches) {\n matches[i].push(key);\n }\n\n value[key] = result.value;\n\n if (pattern.exclusive) {\n break;\n }\n }\n } // Validate pattern matches rules\n\n\n if (hasMatches) {\n for (let i = 0; i < matches.length; ++i) {\n const match = matches[i];\n\n if (!match) {\n continue;\n }\n\n const localState = state.localize(state.path, ancestors, schema.$_terms.patterns[i].matches);\n const result = schema.$_terms.patterns[i].matches.$_validate(match, localState, prefs);\n\n if (result.errors) {\n const details = Errors.details(result.errors, {\n override: false\n });\n details.matches = match;\n const report = schema.$_createError('object.pattern.match', value, details, state, prefs);\n\n if (prefs.abortEarly) {\n return {\n value,\n errors: report\n };\n }\n\n errors.push(report);\n }\n }\n }\n }\n\n if (!unprocessed.size || !schema.$_terms.keys && !schema.$_terms.patterns) {\n // If no keys or patterns specified, unknown keys allowed\n return;\n }\n\n if (prefs.stripUnknown && !schema._flags.unknown || prefs.skipFunctions) {\n const stripUnknown = prefs.stripUnknown ? prefs.stripUnknown === true ? true : !!prefs.stripUnknown.objects : false;\n\n for (const key of unprocessed) {\n if (stripUnknown) {\n delete value[key];\n unprocessed.delete(key);\n } else if (typeof value[key] === 'function') {\n unprocessed.delete(key);\n }\n }\n }\n\n const forbidUnknown = !Common.default(schema._flags.unknown, prefs.allowUnknown);\n\n if (forbidUnknown) {\n for (const unprocessedKey of unprocessed) {\n const localState = state.localize([...state.path, unprocessedKey], []);\n const report = schema.$_createError('object.unknown', value[unprocessedKey], {\n child: unprocessedKey\n }, localState, prefs, {\n flags: false\n });\n\n if (prefs.abortEarly) {\n return {\n value,\n errors: report\n };\n }\n\n errors.push(report);\n }\n }\n};\n\ninternals.Dependency = class {\n constructor(type, key, peers, paths) {\n this.type = type;\n this.key = key;\n this.peers = peers;\n this.paths = paths;\n }\n\n describe() {\n const desc = {\n type: this.type,\n peers: this.paths\n };\n\n if (this.key !== null) {\n desc.key = this.key.key;\n }\n\n if (this.peers[0].separator !== '.') {\n desc.options = {\n separator: this.peers[0].separator\n };\n }\n\n return desc;\n }\n\n};\ninternals.Keys = class extends Array {\n concat(source) {\n const result = this.slice();\n const keys = new Map();\n\n for (let i = 0; i < result.length; ++i) {\n keys.set(result[i].key, i);\n }\n\n for (const item of source) {\n const key = item.key;\n const pos = keys.get(key);\n\n if (pos >= 0) {\n result[pos] = {\n key,\n schema: result[pos].schema.concat(item.schema)\n };\n } else {\n result.push(item);\n }\n }\n\n return result;\n }\n\n};" }, { "id": 24, - "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/webpack/buildin/amd-options.js", - "name": "(webpack)/buildin/amd-options.js", - "index": 45, - "index2": 41, - "size": 80, - "cacheable": true, - "built": true, - "optional": false, - "prefetched": false, - "chunks": [ - 0 - ], - "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "issuerId": 45, - "issuerName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "issuerPath": [ - { - "id": 14, - "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", - "name": "../lib/index.js", - "profile": { - "factory": 32, - "building": 526 - } - }, - { - "id": 43, - "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", - "name": "../lib/types/string/index.js", - "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 - } - }, - { - "id": 44, - "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", - "name": "../node_modules/@hapi/address/lib/index.js", - "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 - } - }, - { - "id": 45, - "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "name": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "profile": { - "factory": 4, - "building": 95 - } - } - ], - "profile": { - "factory": 56, - "building": 8 - }, - "failed": false, - "errors": 0, - "warnings": 0, - "assets": [], - "reasons": [ - { - "moduleId": 45, - "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "module": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "moduleName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "type": "amd require", - "userRequest": "define.amd", - "loc": "540:45-55" - }, - { - "moduleId": 45, - "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "module": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "moduleName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "type": "amd require", - "userRequest": "define.amd", - "loc": "540:72-82" - } - ], - "usedExports": true, - "providedExports": null, - "optimizationBailout": [ - "ModuleConcatenation bailout: Module is not an ECMAScript module" - ], - "depth": 4, - "source": "/* globals __webpack_amd_options__ */\nmodule.exports = __webpack_amd_options__;\n" - }, - { - "id": 25, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/uri.js", "name": "../lib/types/string/uri.js", - "index": 51, - "index2": 48, - "size": 8404, + "index": 50, + "index2": 47, + "size": 8495, "cacheable": true, "built": true, "optional": false, @@ -2666,7 +2573,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", - "issuerId": 43, + "issuerId": 42, "issuerName": "../lib/types/string/index.js", "issuerPath": [ { @@ -2674,25 +2581,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 }, "failed": false, "errors": 0, @@ -2700,22 +2607,22 @@ "assets": [], "reasons": [ { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "./uri", - "loc": "25:10-26" + "loc": "23:12-28" }, { - "moduleId": 51, + "moduleId": 50, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/ip.js", "module": "../lib/types/string/ip.js", "moduleName": "../lib/types/string/ip.js", "type": "cjs require", "userRequest": "./uri", - "loc": "3:10-26" + "loc": "3:12-28" } ], "usedExports": true, @@ -2724,15 +2631,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar EscapeRegex = require('@hapi/hoek/lib/escapeRegex');\n\nvar internals = {};\n\ninternals.generate = function () {\n var rfc3986 = {};\n var hexDigit = '\\\\dA-Fa-f'; // HEXDIG = DIGIT / \"A\" / \"B\" / \"C\" / \"D\" / \"E\" / \"F\"\n\n var hexDigitOnly = '[' + hexDigit + ']';\n var unreserved = '\\\\w-\\\\.~'; // unreserved = ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\"\n\n var subDelims = '!\\\\$&\\'\\\\(\\\\)\\\\*\\\\+,;='; // sub-delims = \"!\" / \"$\" / \"&\" / \"'\" / \"(\" / \")\" / \"*\" / \"+\" / \",\" / \";\" / \"=\"\n\n var pctEncoded = '%' + hexDigit; // pct-encoded = \"%\" HEXDIG HEXDIG\n\n var pchar = unreserved + pctEncoded + subDelims + ':@'; // pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"\n\n var pcharOnly = '[' + pchar + ']';\n var decOctect = '(?:0{0,2}\\\\d|0?[1-9]\\\\d|1\\\\d\\\\d|2[0-4]\\\\d|25[0-5])'; // dec-octet = DIGIT / %x31-39 DIGIT / \"1\" 2DIGIT / \"2\" %x30-34 DIGIT / \"25\" %x30-35 ; 0-9 / 10-99 / 100-199 / 200-249 / 250-255\n\n rfc3986.ipv4address = '(?:' + decOctect + '\\\\.){3}' + decOctect; // IPv4address = dec-octet \".\" dec-octet \".\" dec-octet \".\" dec-octet\n\n /*\r\n h16 = 1*4HEXDIG ; 16 bits of address represented in hexadecimal\r\n ls32 = ( h16 \":\" h16 ) / IPv4address ; least-significant 32 bits of address\r\n IPv6address = 6( h16 \":\" ) ls32\r\n / \"::\" 5( h16 \":\" ) ls32\r\n / [ h16 ] \"::\" 4( h16 \":\" ) ls32\r\n / [ *1( h16 \":\" ) h16 ] \"::\" 3( h16 \":\" ) ls32\r\n / [ *2( h16 \":\" ) h16 ] \"::\" 2( h16 \":\" ) ls32\r\n / [ *3( h16 \":\" ) h16 ] \"::\" h16 \":\" ls32\r\n / [ *4( h16 \":\" ) h16 ] \"::\" ls32\r\n / [ *5( h16 \":\" ) h16 ] \"::\" h16\r\n / [ *6( h16 \":\" ) h16 ] \"::\"\r\n */\n\n var h16 = hexDigitOnly + '{1,4}';\n var ls32 = '(?:' + h16 + ':' + h16 + '|' + rfc3986.ipv4address + ')';\n var IPv6SixHex = '(?:' + h16 + ':){6}' + ls32;\n var IPv6FiveHex = '::(?:' + h16 + ':){5}' + ls32;\n var IPv6FourHex = '(?:' + h16 + ')?::(?:' + h16 + ':){4}' + ls32;\n var IPv6ThreeHex = '(?:(?:' + h16 + ':){0,1}' + h16 + ')?::(?:' + h16 + ':){3}' + ls32;\n var IPv6TwoHex = '(?:(?:' + h16 + ':){0,2}' + h16 + ')?::(?:' + h16 + ':){2}' + ls32;\n var IPv6OneHex = '(?:(?:' + h16 + ':){0,3}' + h16 + ')?::' + h16 + ':' + ls32;\n var IPv6NoneHex = '(?:(?:' + h16 + ':){0,4}' + h16 + ')?::' + ls32;\n var IPv6NoneHex2 = '(?:(?:' + h16 + ':){0,5}' + h16 + ')?::' + h16;\n var IPv6NoneHex3 = '(?:(?:' + h16 + ':){0,6}' + h16 + ')?::';\n rfc3986.ipv4Cidr = '\\\\d|[1-2]\\\\d|3[0-2]'; // IPv4 cidr = DIGIT / %x31-32 DIGIT / \"3\" %x30-32 ; 0-9 / 10-29 / 30-32\n\n rfc3986.ipv6Cidr = '(?:0{0,2}\\\\d|0?[1-9]\\\\d|1[01]\\\\d|12[0-8])'; // IPv6 cidr = DIGIT / %x31-39 DIGIT / \"1\" %x0-1 DIGIT / \"12\" %x0-8; 0-9 / 10-99 / 100-119 / 120-128\n\n rfc3986.ipv6address = '(?:' + IPv6SixHex + '|' + IPv6FiveHex + '|' + IPv6FourHex + '|' + IPv6ThreeHex + '|' + IPv6TwoHex + '|' + IPv6OneHex + '|' + IPv6NoneHex + '|' + IPv6NoneHex2 + '|' + IPv6NoneHex3 + ')';\n rfc3986.ipvFuture = 'v' + hexDigitOnly + '+\\\\.[' + unreserved + subDelims + ':]+'; // IPvFuture = \"v\" 1*HEXDIG \".\" 1*( unreserved / sub-delims / \":\" )\n\n rfc3986.scheme = '[a-zA-Z][a-zA-Z\\\\d+-\\\\.]*'; // scheme = ALPHA *( ALPHA / DIGIT / \"+\" / \"-\" / \".\" )\n\n rfc3986.schemeRegex = new RegExp(rfc3986.scheme);\n var userinfo = '[' + unreserved + pctEncoded + subDelims + ':]*'; // userinfo = *( unreserved / pct-encoded / sub-delims / \":\" )\n\n var IPLiteral = '\\\\[(?:' + rfc3986.ipv6address + '|' + rfc3986.ipvFuture + ')\\\\]'; // IP-literal = \"[\" ( IPv6address / IPvFuture ) \"]\"\n\n var regName = '[' + unreserved + pctEncoded + subDelims + ']{1,255}'; // reg-name = *( unreserved / pct-encoded / sub-delims )\n\n var host = '(?:' + IPLiteral + '|' + rfc3986.ipv4address + '|' + regName + ')'; // host = IP-literal / IPv4address / reg-name\n\n var port = '\\\\d*'; // port = *DIGIT\n\n var authority = '(?:' + userinfo + '@)?' + host + '(?::' + port + ')?'; // authority = [ userinfo \"@\" ] host [ \":\" port ]\n\n var authorityCapture = '(?:' + userinfo + '@)?(' + host + ')(?::' + port + ')?';\n /*\r\n segment = *pchar\r\n segment-nz = 1*pchar\r\n path = path-abempty ; begins with \"/\" '|' is empty\r\n / path-absolute ; begins with \"/\" but not \"//\"\r\n / path-noscheme ; begins with a non-colon segment\r\n / path-rootless ; begins with a segment\r\n / path-empty ; zero characters\r\n path-abempty = *( \"/\" segment )\r\n path-absolute = \"/\" [ segment-nz *( \"/\" segment ) ]\r\n path-rootless = segment-nz *( \"/\" segment )\r\n */\n\n var segment = pcharOnly + '*';\n var segmentNz = pcharOnly + '+';\n var segmentNzNc = '[' + unreserved + pctEncoded + subDelims + '@' + ']+';\n var pathEmpty = '';\n var pathAbEmpty = '(?:\\\\/' + segment + ')*';\n var pathAbsolute = '\\\\/(?:' + segmentNz + pathAbEmpty + ')?';\n var pathRootless = segmentNz + pathAbEmpty;\n var pathNoScheme = segmentNzNc + pathAbEmpty;\n var pathAbNoAuthority = '(?:\\\\/\\\\/\\\\/' + segment + pathAbEmpty + ')'; // Used by file:///\n // hier-part = \"//\" authority path\n\n rfc3986.hierPart = '(?:' + '(?:\\\\/\\\\/' + authority + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathRootless + '|' + pathAbNoAuthority + ')';\n rfc3986.hierPartCapture = '(?:' + '(?:\\\\/\\\\/' + authorityCapture + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathRootless + ')'; // relative-part = \"//\" authority path-abempty / path-absolute / path-noscheme / path-empty\n\n rfc3986.relativeRef = '(?:' + '(?:\\\\/\\\\/' + authority + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathNoScheme + '|' + pathEmpty + ')'; // query = *( pchar / \"/\" / \"?\" )\n // query = *( pchar / \"[\" / \"]\" / \"/\" / \"?\" )\n\n rfc3986.query = '[' + pchar + '\\\\/\\\\?]*(?=#|$)'; //Finish matching either at the fragment part '|' end of the line.\n\n rfc3986.queryWithSquareBrackets = '[' + pchar + '\\\\[\\\\]\\\\/\\\\?]*(?=#|$)'; // fragment = *( pchar / \"/\" / \"?\" )\n\n rfc3986.fragment = '[' + pchar + '\\\\/\\\\?]*';\n return rfc3986;\n};\n\nmodule.exports = exports = internals.rfc3986 = internals.generate();\n\ninternals.createRegex = function (options) {\n var rfc = internals.rfc3986; // Construct expression\n\n var query = options.allowQuerySquareBrackets ? rfc.queryWithSquareBrackets : rfc.query;\n var suffix = '(?:\\\\?' + query + ')?' + '(?:#' + rfc.fragment + ')?$'; // relative-ref = relative-part [ \"?\" query ] [ \"#\" fragment ]\n\n if (options.relativeOnly) {\n return new RegExp('^' + rfc.relativeRef + suffix);\n } // Custom schemes\n\n\n var customScheme = '';\n\n if (options.scheme) {\n Assert(options.scheme instanceof RegExp || typeof options.scheme === 'string' || Array.isArray(options.scheme), 'scheme must be a RegExp, String, or Array');\n var schemes = [].concat(options.scheme);\n Assert(schemes.length >= 1, 'scheme must have at least 1 scheme specified'); // Flatten the array into a string to be used to match the schemes\n\n var selections = [];\n\n for (var i = 0; i < schemes.length; ++i) {\n var _scheme = schemes[i];\n Assert(_scheme instanceof RegExp || typeof _scheme === 'string', 'scheme at position ' + i + ' must be a RegExp or String');\n\n if (_scheme instanceof RegExp) {\n selections.push(_scheme.source.toString());\n } else {\n Assert(rfc.schemeRegex.test(_scheme), 'scheme at position ' + i + ' must be a valid scheme');\n selections.push(EscapeRegex(_scheme));\n }\n }\n\n customScheme = selections.join('|');\n } // URI = scheme \":\" hier-part [ \"?\" query ] [ \"#\" fragment ]\n\n\n var scheme = customScheme ? '(?:' + customScheme + ')' : rfc.scheme;\n var absolute = '(?:' + scheme + ':' + (options.domain ? rfc.hierPartCapture : rfc.hierPart) + ')';\n var prefix = options.allowRelative ? '(?:' + absolute + '|' + rfc.relativeRef + ')' : absolute;\n var regex = new RegExp('^' + prefix + suffix);\n regex.scheme = customScheme;\n return regex;\n};\n\ninternals.uriRegex = internals.createRegex({});\n\nexports.createRegex = function () {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n if (options.scheme || options.allowRelative || options.relativeOnly || options.allowQuerySquareBrackets || options.domain) {\n return internals.createRegex(options);\n }\n\n return internals.uriRegex;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst EscapeRegex = require('@hapi/hoek/lib/escapeRegex');\n\nconst internals = {};\n\ninternals.generate = function () {\n const rfc3986 = {};\n const hexDigit = '\\\\dA-Fa-f'; // HEXDIG = DIGIT / \"A\" / \"B\" / \"C\" / \"D\" / \"E\" / \"F\"\n\n const hexDigitOnly = '[' + hexDigit + ']';\n const unreserved = '\\\\w-\\\\.~'; // unreserved = ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\"\n\n const subDelims = '!\\\\$&\\'\\\\(\\\\)\\\\*\\\\+,;='; // sub-delims = \"!\" / \"$\" / \"&\" / \"'\" / \"(\" / \")\" / \"*\" / \"+\" / \",\" / \";\" / \"=\"\n\n const pctEncoded = '%' + hexDigit; // pct-encoded = \"%\" HEXDIG HEXDIG\n\n const pchar = unreserved + pctEncoded + subDelims + ':@'; // pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"\n\n const pcharOnly = '[' + pchar + ']';\n const decOctect = '(?:0{0,2}\\\\d|0?[1-9]\\\\d|1\\\\d\\\\d|2[0-4]\\\\d|25[0-5])'; // dec-octet = DIGIT / %x31-39 DIGIT / \"1\" 2DIGIT / \"2\" %x30-34 DIGIT / \"25\" %x30-35 ; 0-9 / 10-99 / 100-199 / 200-249 / 250-255\n\n rfc3986.ipv4address = '(?:' + decOctect + '\\\\.){3}' + decOctect; // IPv4address = dec-octet \".\" dec-octet \".\" dec-octet \".\" dec-octet\n\n /*\r\n h16 = 1*4HEXDIG ; 16 bits of address represented in hexadecimal\r\n ls32 = ( h16 \":\" h16 ) / IPv4address ; least-significant 32 bits of address\r\n IPv6address = 6( h16 \":\" ) ls32\r\n / \"::\" 5( h16 \":\" ) ls32\r\n / [ h16 ] \"::\" 4( h16 \":\" ) ls32\r\n / [ *1( h16 \":\" ) h16 ] \"::\" 3( h16 \":\" ) ls32\r\n / [ *2( h16 \":\" ) h16 ] \"::\" 2( h16 \":\" ) ls32\r\n / [ *3( h16 \":\" ) h16 ] \"::\" h16 \":\" ls32\r\n / [ *4( h16 \":\" ) h16 ] \"::\" ls32\r\n / [ *5( h16 \":\" ) h16 ] \"::\" h16\r\n / [ *6( h16 \":\" ) h16 ] \"::\"\r\n */\n\n const h16 = hexDigitOnly + '{1,4}';\n const ls32 = '(?:' + h16 + ':' + h16 + '|' + rfc3986.ipv4address + ')';\n const IPv6SixHex = '(?:' + h16 + ':){6}' + ls32;\n const IPv6FiveHex = '::(?:' + h16 + ':){5}' + ls32;\n const IPv6FourHex = '(?:' + h16 + ')?::(?:' + h16 + ':){4}' + ls32;\n const IPv6ThreeHex = '(?:(?:' + h16 + ':){0,1}' + h16 + ')?::(?:' + h16 + ':){3}' + ls32;\n const IPv6TwoHex = '(?:(?:' + h16 + ':){0,2}' + h16 + ')?::(?:' + h16 + ':){2}' + ls32;\n const IPv6OneHex = '(?:(?:' + h16 + ':){0,3}' + h16 + ')?::' + h16 + ':' + ls32;\n const IPv6NoneHex = '(?:(?:' + h16 + ':){0,4}' + h16 + ')?::' + ls32;\n const IPv6NoneHex2 = '(?:(?:' + h16 + ':){0,5}' + h16 + ')?::' + h16;\n const IPv6NoneHex3 = '(?:(?:' + h16 + ':){0,6}' + h16 + ')?::';\n rfc3986.ipv4Cidr = '\\\\d|[1-2]\\\\d|3[0-2]'; // IPv4 cidr = DIGIT / %x31-32 DIGIT / \"3\" %x30-32 ; 0-9 / 10-29 / 30-32\n\n rfc3986.ipv6Cidr = '(?:0{0,2}\\\\d|0?[1-9]\\\\d|1[01]\\\\d|12[0-8])'; // IPv6 cidr = DIGIT / %x31-39 DIGIT / \"1\" %x0-1 DIGIT / \"12\" %x0-8; 0-9 / 10-99 / 100-119 / 120-128\n\n rfc3986.ipv6address = '(?:' + IPv6SixHex + '|' + IPv6FiveHex + '|' + IPv6FourHex + '|' + IPv6ThreeHex + '|' + IPv6TwoHex + '|' + IPv6OneHex + '|' + IPv6NoneHex + '|' + IPv6NoneHex2 + '|' + IPv6NoneHex3 + ')';\n rfc3986.ipvFuture = 'v' + hexDigitOnly + '+\\\\.[' + unreserved + subDelims + ':]+'; // IPvFuture = \"v\" 1*HEXDIG \".\" 1*( unreserved / sub-delims / \":\" )\n\n rfc3986.scheme = '[a-zA-Z][a-zA-Z\\\\d+-\\\\.]*'; // scheme = ALPHA *( ALPHA / DIGIT / \"+\" / \"-\" / \".\" )\n\n rfc3986.schemeRegex = new RegExp(rfc3986.scheme);\n const userinfo = '[' + unreserved + pctEncoded + subDelims + ':]*'; // userinfo = *( unreserved / pct-encoded / sub-delims / \":\" )\n\n const IPLiteral = '\\\\[(?:' + rfc3986.ipv6address + '|' + rfc3986.ipvFuture + ')\\\\]'; // IP-literal = \"[\" ( IPv6address / IPvFuture ) \"]\"\n\n const regName = '[' + unreserved + pctEncoded + subDelims + ']{1,255}'; // reg-name = *( unreserved / pct-encoded / sub-delims )\n\n const host = '(?:' + IPLiteral + '|' + rfc3986.ipv4address + '|' + regName + ')'; // host = IP-literal / IPv4address / reg-name\n\n const port = '\\\\d*'; // port = *DIGIT\n\n const authority = '(?:' + userinfo + '@)?' + host + '(?::' + port + ')?'; // authority = [ userinfo \"@\" ] host [ \":\" port ]\n\n const authorityCapture = '(?:' + userinfo + '@)?(' + host + ')(?::' + port + ')?';\n /*\r\n segment = *pchar\r\n segment-nz = 1*pchar\r\n path = path-abempty ; begins with \"/\" '|' is empty\r\n / path-absolute ; begins with \"/\" but not \"//\"\r\n / path-noscheme ; begins with a non-colon segment\r\n / path-rootless ; begins with a segment\r\n / path-empty ; zero characters\r\n path-abempty = *( \"/\" segment )\r\n path-absolute = \"/\" [ segment-nz *( \"/\" segment ) ]\r\n path-rootless = segment-nz *( \"/\" segment )\r\n */\n\n const segment = pcharOnly + '*';\n const segmentNz = pcharOnly + '+';\n const segmentNzNc = '[' + unreserved + pctEncoded + subDelims + '@' + ']+';\n const pathEmpty = '';\n const pathAbEmpty = '(?:\\\\/' + segment + ')*';\n const pathAbsolute = '\\\\/(?:' + segmentNz + pathAbEmpty + ')?';\n const pathRootless = segmentNz + pathAbEmpty;\n const pathNoScheme = segmentNzNc + pathAbEmpty;\n const pathAbNoAuthority = '(?:\\\\/\\\\/\\\\/' + segment + pathAbEmpty + ')'; // Used by file:///\n // hier-part = \"//\" authority path\n\n rfc3986.hierPart = '(?:' + '(?:\\\\/\\\\/' + authority + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathRootless + '|' + pathAbNoAuthority + ')';\n rfc3986.hierPartCapture = '(?:' + '(?:\\\\/\\\\/' + authorityCapture + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathRootless + ')'; // relative-part = \"//\" authority path-abempty / path-absolute / path-noscheme / path-empty\n\n rfc3986.relativeRef = '(?:' + '(?:\\\\/\\\\/' + authority + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathNoScheme + '|' + pathEmpty + ')'; // query = *( pchar / \"/\" / \"?\" )\n // query = *( pchar / \"[\" / \"]\" / \"/\" / \"?\" )\n\n rfc3986.query = '[' + pchar + '\\\\/\\\\?]*(?=#|$)'; //Finish matching either at the fragment part '|' end of the line.\n\n rfc3986.queryWithSquareBrackets = '[' + pchar + '\\\\[\\\\]\\\\/\\\\?]*(?=#|$)'; // fragment = *( pchar / \"/\" / \"?\" )\n\n rfc3986.fragment = '[' + pchar + '\\\\/\\\\?]*';\n return rfc3986;\n};\n\nmodule.exports = exports = internals.rfc3986 = internals.generate();\n\ninternals.createRegex = function (options) {\n const rfc = internals.rfc3986; // Construct expression\n\n const query = options.allowQuerySquareBrackets ? rfc.queryWithSquareBrackets : rfc.query;\n const suffix = '(?:\\\\?' + query + ')?' + '(?:#' + rfc.fragment + ')?$'; // relative-ref = relative-part [ \"?\" query ] [ \"#\" fragment ]\n\n if (options.relativeOnly) {\n return new RegExp('^' + rfc.relativeRef + suffix);\n } // Custom schemes\n\n\n let customScheme = '';\n\n if (options.scheme) {\n Assert(options.scheme instanceof RegExp || typeof options.scheme === 'string' || Array.isArray(options.scheme), 'scheme must be a RegExp, String, or Array');\n const schemes = [].concat(options.scheme);\n Assert(schemes.length >= 1, 'scheme must have at least 1 scheme specified'); // Flatten the array into a string to be used to match the schemes\n\n const selections = [];\n\n for (let i = 0; i < schemes.length; ++i) {\n const scheme = schemes[i];\n Assert(scheme instanceof RegExp || typeof scheme === 'string', 'scheme at position ' + i + ' must be a RegExp or String');\n\n if (scheme instanceof RegExp) {\n selections.push(scheme.source.toString());\n } else {\n Assert(rfc.schemeRegex.test(scheme), 'scheme at position ' + i + ' must be a valid scheme');\n selections.push(EscapeRegex(scheme));\n }\n }\n\n customScheme = selections.join('|');\n } // URI = scheme \":\" hier-part [ \"?\" query ] [ \"#\" fragment ]\n\n\n const scheme = customScheme ? '(?:' + customScheme + ')' : rfc.scheme;\n const absolute = '(?:' + scheme + ':' + (options.domain ? rfc.hierPartCapture : rfc.hierPart) + ')';\n const prefix = options.allowRelative ? '(?:' + absolute + '|' + rfc.relativeRef + ')' : absolute;\n const regex = new RegExp('^' + prefix + suffix);\n regex.scheme = customScheme;\n return regex;\n};\n\ninternals.uriRegex = internals.createRegex({});\n\nexports.createRegex = function () {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n if (options.scheme || options.allowRelative || options.relativeOnly || options.allowQuerySquareBrackets || options.domain) {\n return internals.createRegex(options);\n }\n\n return internals.uriRegex;\n};" }, { - "id": 26, + "id": 25, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/stringify.js", "name": "../node_modules/@hapi/hoek/lib/stringify.js", "index": 3, "index2": 0, - "size": 341, + "size": 343, "cacheable": true, "built": true, "optional": false, @@ -2749,8 +2656,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -2758,9 +2665,9 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/common.js", "name": "../lib/common.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { @@ -2768,15 +2675,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/error.js", "name": "../node_modules/@hapi/hoek/lib/error.js", "profile": { - "factory": 1398, - "building": 8, - "dependencies": 1 + "factory": 890, + "building": 9, + "dependencies": 0 } } ], "profile": { - "factory": 340, - "building": 120 + "factory": 168, + "building": 105 }, "failed": false, "errors": 0, @@ -2790,7 +2697,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/error.js", "type": "cjs require", "userRequest": "./stringify", - "loc": "25:16-38" + "loc": "3:18-40" } ], "usedExports": true, @@ -2799,15 +2706,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nvar internals = {};\n\nmodule.exports = function () {\n try {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return JSON.stringify.apply(null, args);\n } catch (err) {\n return '[Cannot display object: ' + err.message + ']';\n }\n};" + "source": "'use strict';\n\nconst internals = {};\n\nmodule.exports = function () {\n try {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return JSON.stringify.apply(null, args);\n } catch (err) {\n return '[Cannot display object: ' + err.message + ']';\n }\n};" }, { - "id": 27, + "id": 26, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/marker/lib/index.js", "name": "../node_modules/@hapi/marker/lib/index.js", "index": 10, "index2": 7, - "size": 290, + "size": 292, "cacheable": true, "built": true, "optional": false, @@ -2824,8 +2731,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -2833,16 +2740,16 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/common.js", "name": "../lib/common.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1398, - "building": 8, - "dependencies": 1 + "factory": 890, + "building": 9, + "dependencies": 0 }, "failed": false, "errors": 0, @@ -2856,7 +2763,7 @@ "moduleName": "../lib/common.js", "type": "cjs require", "userRequest": "@hapi/marker", - "loc": "23:13-36" + "loc": "7:15-38" } ], "usedExports": true, @@ -2865,15 +2772,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nvar internals = {\n symbols: new Map()\n};\n\nmodule.exports = exports = function exports(subject) {\n var symbol = internals.symbols.get(subject);\n\n if (symbol) {\n return symbol;\n }\n\n symbol = Symbol(subject);\n internals.symbols.set(subject, symbol);\n return symbol;\n};" + "source": "'use strict';\n\nconst internals = {\n symbols: new Map()\n};\n\nmodule.exports = exports = function exports(subject) {\n let symbol = internals.symbols.get(subject);\n\n if (symbol) {\n return symbol;\n }\n\n symbol = Symbol(subject);\n internals.symbols.set(subject, symbol);\n return symbol;\n};" }, { - "id": 28, + "id": 27, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/escapeHtml.js", "name": "../node_modules/@hapi/hoek/lib/escapeHtml.js", "index": 15, "index2": 10, - "size": 1409, + "size": 1419, "cacheable": true, "built": true, "optional": false, @@ -2890,8 +2797,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -2899,15 +2806,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/template.js", "name": "../lib/template.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1211, - "building": 77 + "factory": 680, + "building": 39 }, "failed": false, "errors": 0, @@ -2921,7 +2828,7 @@ "moduleName": "../lib/template.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/escapeHtml", - "loc": "31:17-53" + "loc": "7:19-55" } ], "usedExports": true, @@ -2930,15 +2837,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nvar internals = {};\n\nmodule.exports = function (input) {\n if (!input) {\n return '';\n }\n\n var escaped = '';\n\n for (var i = 0; i < input.length; ++i) {\n var charCode = input.charCodeAt(i);\n\n if (internals.isSafe(charCode)) {\n escaped += input[i];\n } else {\n escaped += internals.escapeHtmlChar(charCode);\n }\n }\n\n return escaped;\n};\n\ninternals.escapeHtmlChar = function (charCode) {\n var namedEscape = internals.namedHtml[charCode];\n\n if (typeof namedEscape !== 'undefined') {\n return namedEscape;\n }\n\n if (charCode >= 256) {\n return '&#' + charCode + ';';\n }\n\n var hexValue = charCode.toString(16).padStart(2, '0');\n return \"&#x\".concat(hexValue, \";\");\n};\n\ninternals.isSafe = function (charCode) {\n return typeof internals.safeCharCodes[charCode] !== 'undefined';\n};\n\ninternals.namedHtml = {\n '38': '&',\n '60': '<',\n '62': '>',\n '34': '"',\n '160': ' ',\n '162': '¢',\n '163': '£',\n '164': '¤',\n '169': '©',\n '174': '®'\n};\n\ninternals.safeCharCodes = function () {\n var safe = {};\n\n for (var i = 32; i < 123; ++i) {\n if (i >= 97 || // a-z\n i >= 65 && i <= 90 || // A-Z\n i >= 48 && i <= 57 || // 0-9\n i === 32 || // space\n i === 46 || // .\n i === 44 || // ,\n i === 45 || // -\n i === 58 || // :\n i === 95) {\n // _\n safe[i] = null;\n }\n }\n\n return safe;\n}();" + "source": "'use strict';\n\nconst internals = {};\n\nmodule.exports = function (input) {\n if (!input) {\n return '';\n }\n\n let escaped = '';\n\n for (let i = 0; i < input.length; ++i) {\n const charCode = input.charCodeAt(i);\n\n if (internals.isSafe(charCode)) {\n escaped += input[i];\n } else {\n escaped += internals.escapeHtmlChar(charCode);\n }\n }\n\n return escaped;\n};\n\ninternals.escapeHtmlChar = function (charCode) {\n const namedEscape = internals.namedHtml[charCode];\n\n if (typeof namedEscape !== 'undefined') {\n return namedEscape;\n }\n\n if (charCode >= 256) {\n return '&#' + charCode + ';';\n }\n\n const hexValue = charCode.toString(16).padStart(2, '0');\n return \"&#x\".concat(hexValue, \";\");\n};\n\ninternals.isSafe = function (charCode) {\n return typeof internals.safeCharCodes[charCode] !== 'undefined';\n};\n\ninternals.namedHtml = {\n '38': '&',\n '60': '<',\n '62': '>',\n '34': '"',\n '160': ' ',\n '162': '¢',\n '163': '£',\n '164': '¤',\n '169': '©',\n '174': '®'\n};\n\ninternals.safeCharCodes = function () {\n const safe = {};\n\n for (let i = 32; i < 123; ++i) {\n if (i >= 97 || // a-z\n i >= 65 && i <= 90 || // A-Z\n i >= 48 && i <= 57 || // 0-9\n i === 32 || // space\n i === 46 || // .\n i === 44 || // ,\n i === 45 || // -\n i === 58 || // :\n i === 95) {\n // _\n safe[i] = null;\n }\n }\n\n return safe;\n}();" }, { - "id": 29, + "id": 28, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/formula/lib/index.js", "name": "../node_modules/@hapi/formula/lib/index.js", "index": 16, "index2": 11, - "size": 15073, + "size": 10711, "cacheable": true, "built": true, "optional": false, @@ -2955,8 +2862,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -2964,15 +2871,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/template.js", "name": "../lib/template.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1211, - "building": 77 + "factory": 680, + "building": 39 }, "failed": false, "errors": 0, @@ -2986,7 +2893,7 @@ "moduleName": "../lib/template.js", "type": "cjs require", "userRequest": "@hapi/formula", - "loc": "33:14-38" + "loc": "9:16-40" } ], "usedExports": true, @@ -2995,15 +2902,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar internals = {\n operators: ['!', '^', '*', '/', '%', '+', '-', '<', '<=', '>', '>=', '==', '!=', '&&', '||', '??'],\n operatorCharacters: ['!', '^', '*', '/', '%', '+', '-', '<', '=', '>', '&', '|', '?'],\n operatorsOrder: [['^'], ['*', '/', '%'], ['+', '-'], ['<', '<=', '>', '>='], ['==', '!='], ['&&'], ['||', '??']],\n operatorsPrefix: ['!', 'n'],\n literals: {\n '\"': '\"',\n '`': '`',\n '\\'': '\\'',\n '[': ']'\n },\n numberRx: /^(?:[0-9]*\\.?[0-9]*){1}$/,\n tokenRx: /^[\\w\\$\\#\\.\\@\\:\\{\\}]+$/,\n symbol: Symbol('formula'),\n settings: Symbol('settings')\n};\n\nexports = module.exports = internals.Formula =\n/*#__PURE__*/\nfunction () {\n function _class(string) {\n var _Object$assign;\n\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, _class);\n\n if (!options[internals.settings] && options.constants) {\n for (var constant in options.constants) {\n var value = options.constants[constant];\n\n if (value !== null && !['boolean', 'number', 'string'].includes(_typeof(value))) {\n throw new Error(\"Formula constant \".concat(constant, \" contains invalid \").concat(_typeof(value), \" value type\"));\n }\n }\n }\n\n this.settings = options[internals.settings] ? options : Object.assign((_Object$assign = {}, _defineProperty(_Object$assign, internals.settings, true), _defineProperty(_Object$assign, \"constants\", {}), _defineProperty(_Object$assign, \"functions\", {}), _Object$assign), options);\n this.single = null;\n this._parts = null;\n\n this._parse(string);\n }\n\n _createClass(_class, [{\n key: \"_parse\",\n value: function _parse(string) {\n var _this = this;\n\n var parts = [];\n var current = '';\n var parenthesis = 0;\n var literal = false;\n\n var flush = function flush(inner) {\n if (parenthesis) {\n throw new Error('Formula missing closing parenthesis');\n }\n\n var last = parts.length ? parts[parts.length - 1] : null;\n\n if (!literal && !current && !inner) {\n return;\n }\n\n if (last && last.type === 'reference' && inner === ')') {\n // Function\n last.type = 'function';\n last.value = _this._subFormula(current, last.value);\n current = '';\n return;\n }\n\n if (inner === ')') {\n // Segment\n var sub = new internals.Formula(current, _this.settings);\n parts.push({\n type: 'segment',\n value: sub\n });\n } else if (literal) {\n if (literal === ']') {\n // Reference\n parts.push({\n type: 'reference',\n value: current\n });\n current = '';\n return;\n }\n\n parts.push({\n type: 'literal',\n value: current\n }); // Literal\n } else if (internals.operatorCharacters.includes(current)) {\n // Operator\n if (last && last.type === 'operator' && internals.operators.includes(last.value + current)) {\n // 2 characters operator\n last.value += current;\n } else {\n parts.push({\n type: 'operator',\n value: current\n });\n }\n } else if (current.match(internals.numberRx)) {\n // Number\n parts.push({\n type: 'constant',\n value: parseFloat(current)\n });\n } else if (_this.settings.constants[current] !== undefined) {\n // Constant\n parts.push({\n type: 'constant',\n value: _this.settings.constants[current]\n });\n } else {\n // Reference\n if (!current.match(internals.tokenRx)) {\n throw new Error(\"Formula contains invalid token: \".concat(current));\n }\n\n parts.push({\n type: 'reference',\n value: current\n });\n }\n\n current = '';\n };\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = string[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var c = _step.value;\n\n if (literal) {\n if (c === literal) {\n flush();\n literal = false;\n } else {\n current += c;\n }\n } else if (parenthesis) {\n if (c === '(') {\n current += c;\n ++parenthesis;\n } else if (c === ')') {\n --parenthesis;\n\n if (!parenthesis) {\n flush(c);\n } else {\n current += c;\n }\n } else {\n current += c;\n }\n } else if (c in internals.literals) {\n literal = internals.literals[c];\n } else if (c === '(') {\n flush();\n ++parenthesis;\n } else if (internals.operatorCharacters.includes(c)) {\n flush();\n current = c;\n flush();\n } else if (c !== ' ') {\n current += c;\n } else {\n flush();\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n flush(); // Replace prefix - to internal negative operator\n\n parts = parts.map(function (part, i) {\n if (part.type !== 'operator' || part.value !== '-' || i && parts[i - 1].type !== 'operator') {\n return part;\n }\n\n return {\n type: 'operator',\n value: 'n'\n };\n }); // Validate tokens order\n\n var operator = false;\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = parts[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var part = _step2.value;\n\n if (part.type === 'operator') {\n if (internals.operatorsPrefix.includes(part.value)) {\n continue;\n }\n\n if (!operator) {\n throw new Error('Formula contains an operator in invalid position');\n }\n\n if (!internals.operators.includes(part.value)) {\n throw new Error(\"Formula contains an unknown operator \".concat(part.value));\n }\n } else if (operator) {\n throw new Error('Formula missing expected operator');\n }\n\n operator = !operator;\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (!operator) {\n throw new Error('Formula contains invalid trailing operator');\n } // Identify single part\n\n\n if (parts.length === 1 && ['reference', 'literal', 'constant'].includes(parts[0].type)) {\n this.single = {\n type: parts[0].type === 'reference' ? 'reference' : 'value',\n value: parts[0].value\n };\n } // Process parts\n\n\n this._parts = parts.map(function (part) {\n // Operators\n if (part.type === 'operator') {\n return internals.operatorsPrefix.includes(part.value) ? part : part.value;\n } // Literals, constants, segments\n\n\n if (part.type !== 'reference') {\n return part.value;\n } // References\n\n\n if (_this.settings.tokenRx && !_this.settings.tokenRx.test(part.value)) {\n throw new Error(\"Formula contains invalid reference \".concat(part.value));\n }\n\n if (_this.settings.reference) {\n return _this.settings.reference(part.value);\n }\n\n return internals.reference(part.value);\n });\n }\n }, {\n key: \"_subFormula\",\n value: function _subFormula(string, name) {\n var _this2 = this;\n\n var method = this.settings.functions[name];\n\n if (typeof method !== 'function') {\n throw new Error(\"Formula contains unknown function \".concat(name));\n }\n\n var args = [];\n\n if (string) {\n var current = '';\n var parenthesis = 0;\n var literal = false;\n\n var flush = function flush() {\n if (!current) {\n throw new Error(\"Formula contains function \".concat(name, \" with invalid arguments \").concat(string));\n }\n\n args.push(current);\n current = '';\n };\n\n for (var i = 0; i < string.length; ++i) {\n var c = string[i];\n\n if (literal) {\n current += c;\n\n if (c === literal) {\n literal = false;\n }\n } else if (c in internals.literals && !parenthesis) {\n current += c;\n literal = internals.literals[c];\n } else if (c === ',' && !parenthesis) {\n flush();\n } else {\n current += c;\n\n if (c === '(') {\n ++parenthesis;\n } else if (c === ')') {\n --parenthesis;\n }\n }\n }\n\n flush();\n }\n\n args = args.map(function (arg) {\n return new internals.Formula(arg, _this2.settings);\n });\n return function (context) {\n var innerValues = [];\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = args[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var arg = _step3.value;\n innerValues.push(arg.evaluate(context));\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n return method.apply(void 0, innerValues);\n };\n }\n }, {\n key: \"evaluate\",\n value: function evaluate(context) {\n var parts = this._parts.slice(); // Prefix operators\n\n\n for (var i = parts.length - 2; i >= 0; --i) {\n var part = parts[i];\n\n if (part && part.type === 'operator') {\n var current = parts[i + 1];\n parts.splice(i + 1, 1);\n var value = internals.evaluate(current, context);\n parts[i] = internals.single(part.value, value);\n }\n } // Left-right operators\n\n\n internals.operatorsOrder.forEach(function (set) {\n for (var _i = 1; _i < parts.length - 1;) {\n if (set.includes(parts[_i])) {\n var operator = parts[_i];\n var left = internals.evaluate(parts[_i - 1], context);\n var right = internals.evaluate(parts[_i + 1], context);\n parts.splice(_i, 2);\n var result = internals.calculate(operator, left, right);\n parts[_i - 1] = result === 0 ? 0 : result; // Convert -0\n } else {\n _i += 2;\n }\n }\n });\n return internals.evaluate(parts[0], context);\n }\n }]);\n\n return _class;\n}();\n\ninternals.Formula.prototype[internals.symbol] = true;\n\ninternals.reference = function (name) {\n return function (context) {\n return context && context[name] !== undefined ? context[name] : null;\n };\n};\n\ninternals.evaluate = function (part, context) {\n if (part === null) {\n return null;\n }\n\n if (typeof part === 'function') {\n return part(context);\n }\n\n if (part[internals.symbol]) {\n return part.evaluate(context);\n }\n\n return part;\n};\n\ninternals.single = function (operator, value) {\n if (operator === '!') {\n return value ? false : true;\n } // operator === 'n'\n\n\n var negative = -value;\n\n if (negative === 0) {\n // Override -0\n return 0;\n }\n\n return negative;\n};\n\ninternals.calculate = function (operator, left, right) {\n if (operator === '??') {\n return internals.exists(left) ? left : right;\n }\n\n if (typeof left === 'string' || typeof right === 'string') {\n if (operator === '+') {\n left = internals.exists(left) ? left : '';\n right = internals.exists(right) ? right : '';\n return left + right;\n }\n } else {\n switch (operator) {\n case '^':\n return Math.pow(left, right);\n\n case '*':\n return left * right;\n\n case '/':\n return left / right;\n\n case '%':\n return left % right;\n\n case '+':\n return left + right;\n\n case '-':\n return left - right;\n }\n }\n\n switch (operator) {\n case '<':\n return left < right;\n\n case '<=':\n return left <= right;\n\n case '>':\n return left > right;\n\n case '>=':\n return left >= right;\n\n case '==':\n return left === right;\n\n case '!=':\n return left !== right;\n\n case '&&':\n return left && right;\n\n case '||':\n return left || right;\n }\n\n return null;\n};\n\ninternals.exists = function (value) {\n return value !== null && value !== undefined;\n};" + "source": "'use strict';\n\nconst internals = {\n operators: ['!', '^', '*', '/', '%', '+', '-', '<', '<=', '>', '>=', '==', '!=', '&&', '||', '??'],\n operatorCharacters: ['!', '^', '*', '/', '%', '+', '-', '<', '=', '>', '&', '|', '?'],\n operatorsOrder: [['^'], ['*', '/', '%'], ['+', '-'], ['<', '<=', '>', '>='], ['==', '!='], ['&&'], ['||', '??']],\n operatorsPrefix: ['!', 'n'],\n literals: {\n '\"': '\"',\n '`': '`',\n '\\'': '\\'',\n '[': ']'\n },\n numberRx: /^(?:[0-9]*\\.?[0-9]*){1}$/,\n tokenRx: /^[\\w\\$\\#\\.\\@\\:\\{\\}]+$/,\n symbol: Symbol('formula'),\n settings: Symbol('settings')\n};\nexports = module.exports = internals.Formula = class {\n constructor(string) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!options[internals.settings] && options.constants) {\n for (const constant in options.constants) {\n const value = options.constants[constant];\n\n if (value !== null && !['boolean', 'number', 'string'].includes(typeof value)) {\n throw new Error(\"Formula constant \".concat(constant, \" contains invalid \").concat(typeof value, \" value type\"));\n }\n }\n }\n\n this.settings = options[internals.settings] ? options : Object.assign({\n [internals.settings]: true,\n constants: {},\n functions: {}\n }, options);\n this.single = null;\n this._parts = null;\n\n this._parse(string);\n }\n\n _parse(string) {\n let parts = [];\n let current = '';\n let parenthesis = 0;\n let literal = false;\n\n const flush = inner => {\n if (parenthesis) {\n throw new Error('Formula missing closing parenthesis');\n }\n\n const last = parts.length ? parts[parts.length - 1] : null;\n\n if (!literal && !current && !inner) {\n return;\n }\n\n if (last && last.type === 'reference' && inner === ')') {\n // Function\n last.type = 'function';\n last.value = this._subFormula(current, last.value);\n current = '';\n return;\n }\n\n if (inner === ')') {\n // Segment\n const sub = new internals.Formula(current, this.settings);\n parts.push({\n type: 'segment',\n value: sub\n });\n } else if (literal) {\n if (literal === ']') {\n // Reference\n parts.push({\n type: 'reference',\n value: current\n });\n current = '';\n return;\n }\n\n parts.push({\n type: 'literal',\n value: current\n }); // Literal\n } else if (internals.operatorCharacters.includes(current)) {\n // Operator\n if (last && last.type === 'operator' && internals.operators.includes(last.value + current)) {\n // 2 characters operator\n last.value += current;\n } else {\n parts.push({\n type: 'operator',\n value: current\n });\n }\n } else if (current.match(internals.numberRx)) {\n // Number\n parts.push({\n type: 'constant',\n value: parseFloat(current)\n });\n } else if (this.settings.constants[current] !== undefined) {\n // Constant\n parts.push({\n type: 'constant',\n value: this.settings.constants[current]\n });\n } else {\n // Reference\n if (!current.match(internals.tokenRx)) {\n throw new Error(\"Formula contains invalid token: \".concat(current));\n }\n\n parts.push({\n type: 'reference',\n value: current\n });\n }\n\n current = '';\n };\n\n for (const c of string) {\n if (literal) {\n if (c === literal) {\n flush();\n literal = false;\n } else {\n current += c;\n }\n } else if (parenthesis) {\n if (c === '(') {\n current += c;\n ++parenthesis;\n } else if (c === ')') {\n --parenthesis;\n\n if (!parenthesis) {\n flush(c);\n } else {\n current += c;\n }\n } else {\n current += c;\n }\n } else if (c in internals.literals) {\n literal = internals.literals[c];\n } else if (c === '(') {\n flush();\n ++parenthesis;\n } else if (internals.operatorCharacters.includes(c)) {\n flush();\n current = c;\n flush();\n } else if (c !== ' ') {\n current += c;\n } else {\n flush();\n }\n }\n\n flush(); // Replace prefix - to internal negative operator\n\n parts = parts.map((part, i) => {\n if (part.type !== 'operator' || part.value !== '-' || i && parts[i - 1].type !== 'operator') {\n return part;\n }\n\n return {\n type: 'operator',\n value: 'n'\n };\n }); // Validate tokens order\n\n let operator = false;\n\n for (const part of parts) {\n if (part.type === 'operator') {\n if (internals.operatorsPrefix.includes(part.value)) {\n continue;\n }\n\n if (!operator) {\n throw new Error('Formula contains an operator in invalid position');\n }\n\n if (!internals.operators.includes(part.value)) {\n throw new Error(\"Formula contains an unknown operator \".concat(part.value));\n }\n } else if (operator) {\n throw new Error('Formula missing expected operator');\n }\n\n operator = !operator;\n }\n\n if (!operator) {\n throw new Error('Formula contains invalid trailing operator');\n } // Identify single part\n\n\n if (parts.length === 1 && ['reference', 'literal', 'constant'].includes(parts[0].type)) {\n this.single = {\n type: parts[0].type === 'reference' ? 'reference' : 'value',\n value: parts[0].value\n };\n } // Process parts\n\n\n this._parts = parts.map(part => {\n // Operators\n if (part.type === 'operator') {\n return internals.operatorsPrefix.includes(part.value) ? part : part.value;\n } // Literals, constants, segments\n\n\n if (part.type !== 'reference') {\n return part.value;\n } // References\n\n\n if (this.settings.tokenRx && !this.settings.tokenRx.test(part.value)) {\n throw new Error(\"Formula contains invalid reference \".concat(part.value));\n }\n\n if (this.settings.reference) {\n return this.settings.reference(part.value);\n }\n\n return internals.reference(part.value);\n });\n }\n\n _subFormula(string, name) {\n const method = this.settings.functions[name];\n\n if (typeof method !== 'function') {\n throw new Error(\"Formula contains unknown function \".concat(name));\n }\n\n let args = [];\n\n if (string) {\n let current = '';\n let parenthesis = 0;\n let literal = false;\n\n const flush = () => {\n if (!current) {\n throw new Error(\"Formula contains function \".concat(name, \" with invalid arguments \").concat(string));\n }\n\n args.push(current);\n current = '';\n };\n\n for (let i = 0; i < string.length; ++i) {\n const c = string[i];\n\n if (literal) {\n current += c;\n\n if (c === literal) {\n literal = false;\n }\n } else if (c in internals.literals && !parenthesis) {\n current += c;\n literal = internals.literals[c];\n } else if (c === ',' && !parenthesis) {\n flush();\n } else {\n current += c;\n\n if (c === '(') {\n ++parenthesis;\n } else if (c === ')') {\n --parenthesis;\n }\n }\n }\n\n flush();\n }\n\n args = args.map(arg => new internals.Formula(arg, this.settings));\n return function (context) {\n const innerValues = [];\n\n for (const arg of args) {\n innerValues.push(arg.evaluate(context));\n }\n\n return method(...innerValues);\n };\n }\n\n evaluate(context) {\n const parts = this._parts.slice(); // Prefix operators\n\n\n for (let i = parts.length - 2; i >= 0; --i) {\n const part = parts[i];\n\n if (part && part.type === 'operator') {\n const current = parts[i + 1];\n parts.splice(i + 1, 1);\n const value = internals.evaluate(current, context);\n parts[i] = internals.single(part.value, value);\n }\n } // Left-right operators\n\n\n internals.operatorsOrder.forEach(set => {\n for (let i = 1; i < parts.length - 1;) {\n if (set.includes(parts[i])) {\n const operator = parts[i];\n const left = internals.evaluate(parts[i - 1], context);\n const right = internals.evaluate(parts[i + 1], context);\n parts.splice(i, 2);\n const result = internals.calculate(operator, left, right);\n parts[i - 1] = result === 0 ? 0 : result; // Convert -0\n } else {\n i += 2;\n }\n }\n });\n return internals.evaluate(parts[0], context);\n }\n\n};\ninternals.Formula.prototype[internals.symbol] = true;\n\ninternals.reference = function (name) {\n return function (context) {\n return context && context[name] !== undefined ? context[name] : null;\n };\n};\n\ninternals.evaluate = function (part, context) {\n if (part === null) {\n return null;\n }\n\n if (typeof part === 'function') {\n return part(context);\n }\n\n if (part[internals.symbol]) {\n return part.evaluate(context);\n }\n\n return part;\n};\n\ninternals.single = function (operator, value) {\n if (operator === '!') {\n return value ? false : true;\n } // operator === 'n'\n\n\n const negative = -value;\n\n if (negative === 0) {\n // Override -0\n return 0;\n }\n\n return negative;\n};\n\ninternals.calculate = function (operator, left, right) {\n if (operator === '??') {\n return internals.exists(left) ? left : right;\n }\n\n if (typeof left === 'string' || typeof right === 'string') {\n if (operator === '+') {\n left = internals.exists(left) ? left : '';\n right = internals.exists(right) ? right : '';\n return left + right;\n }\n } else {\n switch (operator) {\n case '^':\n return Math.pow(left, right);\n\n case '*':\n return left * right;\n\n case '/':\n return left / right;\n\n case '%':\n return left % right;\n\n case '+':\n return left + right;\n\n case '-':\n return left - right;\n }\n }\n\n switch (operator) {\n case '<':\n return left < right;\n\n case '<=':\n return left <= right;\n\n case '>':\n return left > right;\n\n case '>=':\n return left >= right;\n\n case '==':\n return left === right;\n\n case '!=':\n return left !== right;\n\n case '&&':\n return left && right;\n\n case '||':\n return left || right;\n }\n\n return null;\n};\n\ninternals.exists = function (value) {\n return value !== null && value !== undefined;\n};" }, { - "id": 30, + "id": 29, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "name": "../lib/types/alternatives.js", "index": 21, "index2": 28, - "size": 14536, + "size": 9018, "cacheable": true, "built": true, "optional": false, @@ -3020,15 +2927,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -3042,7 +2949,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/alternatives", - "loc": "38:18-49" + "loc": "24:18-49" } ], "usedExports": true, @@ -3051,15 +2958,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar Compile = require('../compile');\n\nvar Errors = require('../errors');\n\nvar Ref = require('../ref');\n\nvar internals = {};\nmodule.exports = Any.extend({\n type: 'alternatives',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.matches = [];\n },\n args: function args(schema, schemas) {\n return schema.try(schemas);\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n var error = _ref.error,\n state = _ref.state,\n prefs = _ref.prefs;\n var errors = [];\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = schema.$_terms.matches[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var item = _step.value;\n\n if (item.schema) {\n var result = item.schema.$_validate(value, state.nest(item.schema), prefs);\n\n if (!result.errors) {\n return result;\n }\n\n errors.push.apply(errors, _toConsumableArray(result.errors));\n continue;\n }\n\n var is = item.peek || item.is;\n var input = item.is ? item.ref.resolve(value, state, prefs) : value;\n\n if (!is.$_match(input, state.entry(is, state.ancestors[0]), prefs)) {\n if (item.otherwise) {\n return item.otherwise.$_validate(value, state.nest(item.otherwise), prefs);\n }\n } else if (item.then) {\n return item.then.$_validate(value, state.nest(item.then), prefs);\n }\n } // Nothing matched due to type criteria rules\n\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n if (!errors.length) {\n return {\n errors: error('alternatives.base')\n };\n } // Single error\n\n\n if (errors.length === 1) {\n return {\n errors: errors\n };\n } // All rules are base types\n\n\n var types = [];\n\n for (var _i = 0, _errors = errors; _i < _errors.length; _i++) {\n var report = _errors[_i];\n\n if (report instanceof Errors.Report === false) {\n return {\n errors: error('alternatives.match', Errors.details(errors, {\n override: false\n }))\n };\n }\n\n var _report$code$split = report.code.split('.'),\n _report$code$split2 = _slicedToArray(_report$code$split, 2),\n type = _report$code$split2[0],\n code = _report$code$split2[1];\n\n if (code !== 'base') {\n return {\n errors: error('alternatives.match', Errors.details(errors, {\n override: false\n }))\n };\n }\n\n types.push(type);\n } // Complex reasons\n\n\n return {\n errors: error('alternatives.types', {\n types: types\n })\n };\n },\n // Rules\n rules: {\n try: {\n method: function method(schemas) {\n Assert(schemas, 'Missing alternative schemas');\n Assert(!this._flags._endedSwitch, 'Unreachable condition');\n\n if (!Array.isArray(schemas)) {\n schemas = [schemas];\n }\n\n var obj = this.clone();\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = schemas[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var schema = _step2.value;\n obj.$_terms.matches.push({\n schema: obj.$_compile(schema)\n });\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return obj.$_mutateRebuild();\n }\n }\n },\n // Overrides\n overrides: {\n label: function label(name) {\n var obj = this.super.label(name);\n obj.$_terms.matches = obj.$_terms.matches.map(function (match) {\n if (match.schema) {\n return {\n schema: match.schema.label(name)\n };\n }\n\n match = Object.assign({}, match);\n\n if (match.then) {\n match.then = match.then.label(name);\n }\n\n if (match.otherwise) {\n match.otherwise = match.otherwise.label(name);\n }\n\n return match;\n });\n return obj;\n },\n tailor: function tailor(targets) {\n var obj = this.super.tailor(targets);\n\n if (obj === this) {\n obj = this.clone();\n }\n\n for (var i = 0; i < obj.$_terms.matches.length; ++i) {\n var match = Object.assign({}, obj.$_terms.matches[i]);\n obj.$_terms.matches[i] = match;\n\n for (var _i2 = 0, _arr2 = ['schema', 'peek', 'is', 'then', 'otherwise']; _i2 < _arr2.length; _i2++) {\n var key = _arr2[_i2];\n\n if (match[key]) {\n match[key] = match[key].tailor(targets);\n }\n }\n }\n\n return obj.$_mutateRebuild();\n },\n when: function when(condition, options) {\n if (Array.isArray(options)) {\n options = {\n switch: options\n };\n }\n\n Common.assertOptions(options, ['is', 'then', 'otherwise', 'switch']);\n var schemaCondition = Common.isSchema(condition);\n Assert(!this._flags._endedSwitch, 'Unreachable condition');\n Assert(Ref.isRef(condition) || typeof condition === 'string' || schemaCondition, 'Invalid condition:', condition);\n Assert(!options.switch || options.is === undefined, 'Cannot combine \"switch\" with \"is\"');\n Assert(!options.switch || options.then === undefined, 'Cannot combine \"switch\" with \"then\"');\n Assert(options.switch !== undefined || options.then !== undefined || options.otherwise !== undefined, 'options must have at least one of \"then\", \"otherwise\", or \"switch\"');\n Assert(!schemaCondition || options.is === undefined, '\"is\" can not be used with a schema condition');\n Assert(!schemaCondition || options.switch === undefined, '\"switch\" can not be used with a schema condition');\n Assert(schemaCondition || options.is !== undefined || options.switch !== undefined, 'Missing \"is\" or \"switch\" option');\n Assert(options.switch === undefined || Array.isArray(options.switch), '\"switch\" must be an array');\n var obj = this.clone();\n\n var normalize = function normalize(match, settings) {\n var isSchema = Common.isSchema(match);\n var item = {\n ref: !isSchema ? Compile.ref(match) : null,\n peek: isSchema ? match : null,\n then: settings.then !== undefined ? obj.$_compile(settings.then) : undefined,\n otherwise: settings.otherwise !== undefined ? obj.$_compile(settings.otherwise) : undefined\n };\n\n if (settings.is !== undefined) {\n item.is = obj.$_compile(settings.is);\n\n if (settings.is === null || !(Ref.isRef(settings.is) || Common.isSchema(settings.is))) {\n item.is = item.is.required(); // Only apply required if this wasn't already a schema or a ref\n }\n }\n\n if (item.then && item.otherwise) {\n obj.$_setFlag('_endedSwitch', true, {\n clone: false\n });\n }\n\n return item;\n }; // Single case\n\n\n if (options.switch === undefined) {\n obj.$_terms.matches.push(normalize(condition, options));\n return obj.$_mutateRebuild();\n } // Switch statement\n\n\n for (var i = 0; i < options.switch.length; ++i) {\n var test = options.switch[i];\n Assert(test.is !== undefined, 'Switch statement missing \"is\"');\n Assert(test.then !== undefined, 'Switch statement missing \"then\"');\n\n if (i + 1 !== options.switch.length) {\n Common.assertOptions(test, ['is', 'then']);\n obj.$_terms.matches.push(normalize(condition, test));\n } else {\n // Last\n Common.assertOptions(test, ['is', 'then', 'otherwise']);\n Assert(options.otherwise === undefined || test.otherwise === undefined, 'Cannot specify \"otherwise\" inside and outside a \"switch\"');\n var otherwise = options.otherwise !== undefined ? options.otherwise : test.otherwise;\n obj.$_terms.matches.push(normalize(condition, {\n is: test.is,\n then: test.then,\n otherwise: otherwise\n }));\n }\n }\n\n return obj.$_mutateRebuild();\n }\n },\n // Build\n build: function build(obj, desc) {\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = desc.matches[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var _step3$value = _step3.value,\n schema = _step3$value.schema,\n ref = _step3$value.ref,\n peek = _step3$value.peek,\n is = _step3$value.is,\n then = _step3$value.then,\n otherwise = _step3$value.otherwise;\n\n if (schema) {\n obj = obj.try(schema);\n } else {\n obj = obj.when(ref || peek, {\n is: is,\n then: then,\n otherwise: otherwise\n });\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n return obj;\n },\n // Modify\n modify: function modify(schema, id, replacement) {\n var i = 0;\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = schema.$_terms.matches[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var match = _step4.value;\n\n for (var _i3 = 0, _arr3 = ['schema', 'peek', 'is', 'then', 'otherwise']; _i3 < _arr3.length; _i3++) {\n var key = _arr3[_i3];\n\n if (match[key] && id === match[key]._flags.id) {\n var obj = schema.clone();\n obj.$_terms.matches[i] = Object.assign({}, match, _defineProperty({}, key, replacement));\n return obj.$_mutateRebuild();\n }\n }\n\n ++i;\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n },\n rebuild: function rebuild(schema) {\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = schema.$_terms.matches[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var match = _step5.value;\n\n for (var _i4 = 0, _arr4 = ['schema', 'ref', 'peek', 'is', 'then', 'otherwise']; _i4 < _arr4.length; _i4++) {\n var key = _arr4[_i4];\n schema.$_mutateRegister(match[key], {\n family: Ref.toSibling\n });\n } // Flag when an alternative type is an array\n\n\n for (var _i5 = 0, _arr5 = ['schema', 'then', 'otherwise']; _i5 < _arr5.length; _i5++) {\n var _key = _arr5[_i5];\n\n if (match[_key] && match[_key].type === 'array') {\n schema.$_setFlag('_arrayItems', true, {\n clone: false\n });\n break;\n }\n }\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n\n return schema;\n },\n // Errors\n messages: {\n 'alternatives.base': '\"{{#label}}\" does not match any of the allowed types',\n 'alternatives.match': '\"{{#label}}\" does not match any of the allowed types',\n 'alternatives.types': '\"{{#label}}\" must be one of {{#types}}'\n }\n});" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst Compile = require('../compile');\n\nconst Errors = require('../errors');\n\nconst Ref = require('../ref');\n\nconst internals = {};\nmodule.exports = Any.extend({\n type: 'alternatives',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.matches = [];\n },\n args: function args(schema, schemas) {\n return schema.try(schemas);\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n let {\n error,\n state,\n prefs\n } = _ref;\n const errors = [];\n\n for (const item of schema.$_terms.matches) {\n if (item.schema) {\n const result = item.schema.$_validate(value, state.nest(item.schema), prefs);\n\n if (!result.errors) {\n return result;\n }\n\n errors.push(...result.errors);\n continue;\n }\n\n const is = item.peek || item.is;\n const input = item.is ? item.ref.resolve(value, state, prefs) : value;\n\n if (!is.$_match(input, state.entry(is, state.ancestors[0]), prefs)) {\n if (item.otherwise) {\n return item.otherwise.$_validate(value, state.nest(item.otherwise), prefs);\n }\n } else if (item.then) {\n return item.then.$_validate(value, state.nest(item.then), prefs);\n }\n } // Nothing matched due to type criteria rules\n\n\n if (!errors.length) {\n return {\n errors: error('alternatives.base')\n };\n } // Single error\n\n\n if (errors.length === 1) {\n return {\n errors\n };\n } // All rules are base types\n\n\n const types = [];\n\n for (const report of errors) {\n if (report instanceof Errors.Report === false) {\n return {\n errors: error('alternatives.match', Errors.details(errors, {\n override: false\n }))\n };\n }\n\n const [type, code] = report.code.split('.');\n\n if (code !== 'base') {\n return {\n errors: error('alternatives.match', Errors.details(errors, {\n override: false\n }))\n };\n }\n\n types.push(type);\n } // Complex reasons\n\n\n return {\n errors: error('alternatives.types', {\n types\n })\n };\n },\n // Rules\n rules: {\n try: {\n method: function method(schemas) {\n Assert(schemas, 'Missing alternative schemas');\n Assert(!this._flags._endedSwitch, 'Unreachable condition');\n\n if (!Array.isArray(schemas)) {\n schemas = [schemas];\n }\n\n const obj = this.clone();\n\n for (const schema of schemas) {\n obj.$_terms.matches.push({\n schema: obj.$_compile(schema)\n });\n }\n\n return obj.$_mutateRebuild();\n }\n }\n },\n // Overrides\n overrides: {\n label(name) {\n const obj = this.super.label(name);\n obj.$_terms.matches = obj.$_terms.matches.map(match => {\n if (match.schema) {\n return {\n schema: match.schema.label(name)\n };\n }\n\n match = Object.assign({}, match);\n\n if (match.then) {\n match.then = match.then.label(name);\n }\n\n if (match.otherwise) {\n match.otherwise = match.otherwise.label(name);\n }\n\n return match;\n });\n return obj;\n },\n\n tailor(targets) {\n let obj = this.super.tailor(targets);\n\n if (obj === this) {\n obj = this.clone();\n }\n\n for (let i = 0; i < obj.$_terms.matches.length; ++i) {\n const match = Object.assign({}, obj.$_terms.matches[i]);\n obj.$_terms.matches[i] = match;\n\n for (const key of ['schema', 'peek', 'is', 'then', 'otherwise']) {\n if (match[key]) {\n match[key] = match[key].tailor(targets);\n }\n }\n }\n\n return obj.$_mutateRebuild();\n },\n\n when(condition, options) {\n if (Array.isArray(options)) {\n options = {\n switch: options\n };\n }\n\n Common.assertOptions(options, ['is', 'then', 'otherwise', 'switch']);\n const schemaCondition = Common.isSchema(condition);\n Assert(!this._flags._endedSwitch, 'Unreachable condition');\n Assert(Ref.isRef(condition) || typeof condition === 'string' || schemaCondition, 'Invalid condition:', condition);\n Assert(!options.switch || options.is === undefined, 'Cannot combine \"switch\" with \"is\"');\n Assert(!options.switch || options.then === undefined, 'Cannot combine \"switch\" with \"then\"');\n Assert(options.switch !== undefined || options.then !== undefined || options.otherwise !== undefined, 'options must have at least one of \"then\", \"otherwise\", or \"switch\"');\n Assert(!schemaCondition || options.is === undefined, '\"is\" can not be used with a schema condition');\n Assert(!schemaCondition || options.switch === undefined, '\"switch\" can not be used with a schema condition');\n Assert(schemaCondition || options.is !== undefined || options.switch !== undefined, 'Missing \"is\" or \"switch\" option');\n Assert(options.switch === undefined || Array.isArray(options.switch), '\"switch\" must be an array');\n const obj = this.clone();\n\n const normalize = (match, settings) => {\n const isSchema = Common.isSchema(match);\n const item = {\n ref: !isSchema ? Compile.ref(match) : null,\n peek: isSchema ? match : null,\n then: settings.then !== undefined ? obj.$_compile(settings.then) : undefined,\n otherwise: settings.otherwise !== undefined ? obj.$_compile(settings.otherwise) : undefined\n };\n\n if (settings.is !== undefined) {\n item.is = obj.$_compile(settings.is);\n\n if (settings.is === null || !(Ref.isRef(settings.is) || Common.isSchema(settings.is))) {\n item.is = item.is.required(); // Only apply required if this wasn't already a schema or a ref\n }\n }\n\n if (item.then && item.otherwise) {\n obj.$_setFlag('_endedSwitch', true, {\n clone: false\n });\n }\n\n return item;\n }; // Single case\n\n\n if (options.switch === undefined) {\n obj.$_terms.matches.push(normalize(condition, options));\n return obj.$_mutateRebuild();\n } // Switch statement\n\n\n for (let i = 0; i < options.switch.length; ++i) {\n const test = options.switch[i];\n Assert(test.is !== undefined, 'Switch statement missing \"is\"');\n Assert(test.then !== undefined, 'Switch statement missing \"then\"');\n\n if (i + 1 !== options.switch.length) {\n Common.assertOptions(test, ['is', 'then']);\n obj.$_terms.matches.push(normalize(condition, test));\n } else {\n // Last\n Common.assertOptions(test, ['is', 'then', 'otherwise']);\n Assert(options.otherwise === undefined || test.otherwise === undefined, 'Cannot specify \"otherwise\" inside and outside a \"switch\"');\n const otherwise = options.otherwise !== undefined ? options.otherwise : test.otherwise;\n obj.$_terms.matches.push(normalize(condition, {\n is: test.is,\n then: test.then,\n otherwise\n }));\n }\n }\n\n return obj.$_mutateRebuild();\n }\n\n },\n // Build\n build: function build(obj, desc) {\n for (const _ref2 of desc.matches) {\n const {\n schema,\n ref,\n peek,\n is,\n then,\n otherwise\n } = _ref2;\n\n if (schema) {\n obj = obj.try(schema);\n } else {\n obj = obj.when(ref || peek, {\n is,\n then,\n otherwise\n });\n }\n }\n\n return obj;\n },\n // Modify\n modify: function modify(schema, id, replacement) {\n let i = 0;\n\n for (const match of schema.$_terms.matches) {\n for (const key of ['schema', 'peek', 'is', 'then', 'otherwise']) {\n if (match[key] && id === match[key]._flags.id) {\n const obj = schema.clone();\n obj.$_terms.matches[i] = Object.assign({}, match, {\n [key]: replacement\n });\n return obj.$_mutateRebuild();\n }\n }\n\n ++i;\n }\n },\n rebuild: function rebuild(schema) {\n for (const match of schema.$_terms.matches) {\n for (const key of ['schema', 'ref', 'peek', 'is', 'then', 'otherwise']) {\n schema.$_mutateRegister(match[key], {\n family: Ref.toSibling\n });\n } // Flag when an alternative type is an array\n\n\n for (const key of ['schema', 'then', 'otherwise']) {\n if (match[key] && match[key].type === 'array') {\n schema.$_setFlag('_arrayItems', true, {\n clone: false\n });\n break;\n }\n }\n }\n\n return schema;\n },\n // Errors\n messages: {\n 'alternatives.base': '\"{{#label}}\" does not match any of the allowed types',\n 'alternatives.match': '\"{{#label}}\" does not match any of the allowed types',\n 'alternatives.types': '\"{{#label}}\" must be one of {{#types}}'\n }\n});" }, { - "id": 31, + "id": 30, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "name": "../lib/base.js", "index": 23, "index2": 26, - "size": 33168, + "size": 23126, "cacheable": true, "built": true, "optional": false, @@ -3076,8 +2983,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -3085,15 +2992,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/any.js", "name": "../lib/types/any.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 767, - "building": 322, + "factory": 353, + "building": 264, "dependencies": 2 }, "failed": false, @@ -3108,7 +3015,7 @@ "moduleName": "../lib/types/any.js", "type": "cjs require", "userRequest": "../base", - "loc": "5:11-29" + "loc": "5:13-31" } ], "usedExports": true, @@ -3117,15 +3024,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar DeepEqual = require('@hapi/hoek/lib/deepEqual');\n\nvar Merge = require('@hapi/hoek/lib/merge');\n\nvar Cache = require('./cache');\n\nvar Common = require('./common');\n\nvar Compile = require('./compile');\n\nvar Errors = require('./errors');\n\nvar Extend = require('./extend');\n\nvar Manifest = require('./manifest');\n\nvar Messages = require('./messages');\n\nvar Modify = require('./modify');\n\nvar Ref = require('./ref');\n\nvar Validator = require('./validator');\n\nvar Values = require('./values');\n\nvar internals = {};\n\ninternals.Base =\n/*#__PURE__*/\nfunction () {\n function _class(type) {\n _classCallCheck(this, _class);\n\n // Naming: public, _private, $_extension, $_mutate{action}\n this.type = type;\n this._definition = {};\n this._ids = new Modify.Ids();\n this._preferences = null;\n this._refs = new Ref.Manager();\n this._cache = null;\n this._valids = null;\n this._invalids = null;\n this._flags = {};\n this._rules = [];\n this._singleRules = new Map(); // The rule options passed for non-multi rules\n\n this._ruleset = null; // null: use last, false: error, number: start position\n\n this.$_terms = {\n // Hash of arrays of immutable objects (extended by other types)\n alterations: null,\n examples: null,\n externals: null,\n metas: [],\n notes: [],\n tags: []\n };\n } // Manifest\n\n\n _createClass(_class, [{\n key: \"describe\",\n value: function describe() {\n return Manifest.describe(this);\n } // Rules\n\n }, {\n key: \"allow\",\n value: function allow() {\n for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {\n values[_key] = arguments[_key];\n }\n\n Common.verifyFlat(values, 'allow');\n var obj = this.clone();\n\n if (!obj._valids) {\n obj._valids = new Values();\n }\n\n for (var _i = 0, _values = values; _i < _values.length; _i++) {\n var value = _values[_i];\n Assert(value !== undefined, 'Cannot call allow/valid/invalid with undefined');\n\n if (obj._invalids) {\n obj._invalids.remove(value);\n\n if (!obj._invalids.length) {\n obj._invalids = null;\n }\n }\n\n obj._valids.add(value, obj._refs);\n }\n\n return obj;\n }\n }, {\n key: \"alter\",\n value: function alter(targets) {\n Assert(targets && _typeof(targets) === 'object' && !Array.isArray(targets), 'Invalid targets argument');\n Assert(!this._inRuleset(), 'Cannot set alterations inside a ruleset');\n var obj = this.clone();\n obj.$_terms.alterations = obj.$_terms.alterations || [];\n\n for (var target in targets) {\n var adjuster = targets[target];\n Assert(typeof adjuster === 'function', 'Alteration adjuster for', target, 'must be a function');\n obj.$_terms.alterations.push({\n target: target,\n adjuster: adjuster\n });\n }\n\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"cast\",\n value: function cast(to) {\n Assert(to === false || this._definition.cast[to], 'Type', this.type, 'does not support casting to', to);\n return this.$_setFlag('cast', to === false ? undefined : to);\n }\n }, {\n key: \"default\",\n value: function _default(value, options) {\n return this._default('default', value, options);\n }\n }, {\n key: \"description\",\n value: function description(desc) {\n Assert(desc && typeof desc === 'string', 'Description must be a non-empty string');\n return this.$_setFlag('description', desc);\n }\n }, {\n key: \"empty\",\n value: function empty(schema) {\n var obj = this.clone();\n\n if (schema !== undefined) {\n schema = obj.$_compile(schema);\n\n obj._refs.register(schema);\n }\n\n return obj.$_setFlag('empty', schema, {\n clone: false\n });\n }\n }, {\n key: \"error\",\n value: function error(err) {\n Assert(err, 'Missing error');\n Assert(err instanceof Error || typeof err === 'function', 'Must provide a valid Error object or a function');\n return this.$_setFlag('error', err);\n }\n }, {\n key: \"example\",\n value: function example(_example) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(_example !== undefined, 'Missing example');\n Common.assertOptions(options, ['override']);\n return this._inner('examples', _example, {\n single: true,\n override: options.override\n });\n }\n }, {\n key: \"external\",\n value: function external(method) {\n Assert(typeof method === 'function', 'Method must be a function');\n return this._inner('externals', method, {\n single: true\n });\n }\n }, {\n key: \"failover\",\n value: function failover(value, options) {\n return this._default('failover', value, options);\n }\n }, {\n key: \"forbidden\",\n value: function forbidden() {\n return this.presence('forbidden');\n }\n }, {\n key: \"id\",\n value: function id(_id) {\n Assert(_id && typeof _id === 'string', 'id must be a non-empty string');\n Assert(/^[^\\.]+$/.test(_id), 'id cannot contain period character');\n Assert(!this._flags.id, 'Cannot override schema id');\n return this.$_setFlag('id', _id);\n }\n }, {\n key: \"invalid\",\n value: function invalid() {\n for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n values[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(values, 'invalid');\n var obj = this.clone();\n\n if (!obj._invalids) {\n obj._invalids = new Values();\n }\n\n for (var _i2 = 0, _values2 = values; _i2 < _values2.length; _i2++) {\n var value = _values2[_i2];\n Assert(value !== undefined, 'Cannot call allow/valid/invalid with undefined');\n\n if (obj._valids) {\n obj._valids.remove(value);\n\n if (!obj._valids.length) {\n Assert(!obj._flags.only, 'Setting invalid value', value, 'leaves schema rejecting all values due to previous valid rule');\n obj._valids = null;\n }\n }\n\n obj._invalids.add(value, obj._refs);\n }\n\n return obj;\n }\n }, {\n key: \"keep\",\n value: function keep() {\n return this.rule({\n keep: true\n });\n }\n }, {\n key: \"label\",\n value: function label(name) {\n Assert(name && typeof name === 'string', 'Label name must be a non-empty string');\n return this.$_setFlag('label', name);\n }\n }, {\n key: \"meta\",\n value: function meta(_meta) {\n Assert(_meta !== undefined, 'Meta cannot be undefined');\n return this._inner('metas', _meta, {\n single: true\n });\n }\n }, {\n key: \"note\",\n value: function note() {\n for (var _len3 = arguments.length, notes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n notes[_key3] = arguments[_key3];\n }\n\n Assert(notes.length, 'Missing notes');\n\n for (var _i3 = 0, _notes = notes; _i3 < _notes.length; _i3++) {\n var note = _notes[_i3];\n Assert(note && typeof note === 'string', 'Notes must be non-empty strings');\n }\n\n return this._inner('notes', notes);\n }\n }, {\n key: \"only\",\n value: function only() {\n var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof mode === 'boolean', 'Invalid mode:', mode);\n return this.$_setFlag('only', mode);\n }\n }, {\n key: \"optional\",\n value: function optional() {\n return this.presence('optional');\n }\n }, {\n key: \"prefs\",\n value: function prefs(_prefs) {\n Assert(_prefs.context === undefined, 'Cannot override context');\n Assert(_prefs.externals === undefined, 'Cannot override externals');\n Assert(_prefs.warnings === undefined, 'Cannot override warnings');\n Common.checkPreferences(_prefs);\n var obj = this.clone();\n obj._preferences = Common.preferences(obj._preferences, _prefs);\n return obj;\n }\n }, {\n key: \"presence\",\n value: function presence(mode) {\n Assert(['optional', 'required', 'forbidden'].includes(mode), 'Unknown presence mode', mode);\n return this.$_setFlag('presence', mode);\n }\n }, {\n key: \"raw\",\n value: function raw() {\n var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n return this.$_setFlag('result', enabled ? 'raw' : undefined);\n }\n }, {\n key: \"result\",\n value: function result(mode) {\n Assert(['raw', 'strip'].includes(mode), 'Unknown result mode', mode);\n return this.$_setFlag('result', mode);\n }\n }, {\n key: \"required\",\n value: function required() {\n return this.presence('required');\n }\n }, {\n key: \"strict\",\n value: function strict(enabled) {\n var obj = this.clone();\n var convert = enabled === undefined ? false : !enabled;\n obj._preferences = Common.preferences(obj._preferences, {\n convert: convert\n });\n return obj;\n }\n }, {\n key: \"strip\",\n value: function strip() {\n var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n return this.$_setFlag('result', enabled ? 'strip' : undefined);\n }\n }, {\n key: \"tag\",\n value: function tag() {\n for (var _len4 = arguments.length, tags = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n tags[_key4] = arguments[_key4];\n }\n\n Assert(tags.length, 'Missing tags');\n\n for (var _i4 = 0, _tags = tags; _i4 < _tags.length; _i4++) {\n var tag = _tags[_i4];\n Assert(tag && typeof tag === 'string', 'Tags must be non-empty strings');\n }\n\n return this._inner('tags', tags);\n }\n }, {\n key: \"unit\",\n value: function unit(name) {\n Assert(name && typeof name === 'string', 'Unit name must be a non-empty string');\n return this.$_setFlag('unit', name);\n }\n }, {\n key: \"valid\",\n value: function valid() {\n return this.allow.apply(this, arguments).$_setFlag('only', true, {\n clone: false\n });\n }\n }, {\n key: \"when\",\n value: function when(condition, options) {\n var _this = this;\n\n if (Array.isArray(options)) {\n options = {\n switch: options\n };\n }\n\n Common.assertOptions(options, ['is', 'then', 'otherwise', 'switch']);\n Assert(options.then || options.otherwise || options.switch, 'At least one of then, otherwise, or switch is required');\n\n var process = function process(settings) {\n var item = {\n is: settings.is,\n then: settings.then && _this.concat(_this.$_compile(settings.then))\n };\n\n if (settings.otherwise) {\n item.otherwise = _this.concat(_this.$_compile(settings.otherwise));\n }\n\n return item;\n };\n\n var alt = process(options);\n\n if (options.switch) {\n Assert(Array.isArray(options.switch), '\"switch\" must be an array');\n alt.switch = options.switch.map(process);\n var last = alt.switch[alt.switch.length - 1];\n\n if (!alt.otherwise && !last.otherwise) {\n last.otherwise = this;\n }\n } else {\n if (!alt.then) {\n alt.then = this;\n } else if (!alt.otherwise) {\n alt.otherwise = this;\n }\n }\n\n return this._root.alternatives().when(condition, alt);\n } // Helpers\n\n }, {\n key: \"cache\",\n value: function cache(_cache) {\n Assert(!this._inRuleset(), 'Cannot set caching inside a ruleset');\n Assert(!this._cache, 'Cannot override schema cache');\n var obj = this.clone();\n obj._cache = _cache || Cache.provider.provision();\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"clone\",\n value: function clone() {\n var obj = Object.create(Object.getPrototypeOf(this));\n return this._assign(obj);\n }\n }, {\n key: \"concat\",\n value: function concat(source) {\n Assert(Common.isSchema(source), 'Invalid schema object');\n Assert(this.type === 'any' || source.type === 'any' || source.type === this.type, 'Cannot merge type', this.type, 'with another type:', source.type);\n var obj = this.clone();\n\n if (this.type === 'any' && source.type !== 'any') {\n // Change obj to match source type\n var tmpObj = source.clone();\n\n for (var _i5 = 0, _Object$keys = Object.keys(obj); _i5 < _Object$keys.length; _i5++) {\n var key = _Object$keys[_i5];\n\n if (key !== 'type') {\n tmpObj[key] = obj[key];\n }\n }\n\n obj = tmpObj;\n }\n\n obj._ids.concat(source._ids);\n\n obj._preferences = obj._preferences ? Common.preferences(obj._preferences, source._preferences) : source._preferences;\n obj._valids = Values.merge(obj._valids, source._valids, source._invalids);\n obj._invalids = Values.merge(obj._invalids, source._invalids, source._valids);\n\n obj._refs.register(source, Ref.toSibling); // Remove unique rules present in source\n\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n var _loop = function _loop() {\n var name = _step.value;\n\n if (obj._singleRules.has(name)) {\n obj._rules = obj._rules.filter(function (target) {\n return target.name !== name;\n });\n\n obj._singleRules.delete(name);\n }\n };\n\n for (var _iterator = source._singleRules.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n _loop();\n } // Adjust ruleset\n\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n if (source._ruleset !== null) {\n Assert(!obj._inRuleset(), 'Cannot concatenate onto a schema with open ruleset');\n obj._ruleset = source._ruleset === false ? false : source._ruleset + obj._rules.length;\n } // Rules\n\n\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = source._rules[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var test = _step2.value;\n\n if (!source._definition.rules[test.method].multi) {\n obj._singleRules.set(test.name, test.options);\n }\n\n obj._rules.push(test);\n } // Flags\n\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (obj._flags.empty && source._flags.empty) {\n obj._flags.empty = obj._flags.empty.concat(source._flags.empty);\n var flags = Object.assign({}, source._flags);\n delete flags.empty;\n Merge(obj._flags, flags);\n } else if (source._flags.empty) {\n obj._flags.empty = source._flags.empty;\n\n var _flags = Object.assign({}, source._flags);\n\n delete _flags.empty;\n Merge(obj._flags, _flags);\n } else {\n Merge(obj._flags, source._flags);\n } // Terms\n\n\n for (var _key5 in source.$_terms) {\n var terms = source.$_terms[_key5];\n\n if (!terms) {\n if (!obj.$_terms[_key5]) {\n obj.$_terms[_key5] = terms;\n }\n\n continue;\n }\n\n if (!obj.$_terms[_key5]) {\n obj.$_terms[_key5] = terms.slice();\n continue;\n }\n\n obj.$_terms[_key5] = obj.$_terms[_key5].concat(terms);\n }\n\n return obj.$_mutateRebuild();\n }\n }, {\n key: \"extend\",\n value: function extend(options) {\n return Extend.type(this, options);\n }\n }, {\n key: \"extract\",\n value: function extract(path) {\n path = Array.isArray(path) ? path : path.split('.');\n return this._ids.reach(path);\n }\n }, {\n key: \"fork\",\n value: function fork(paths, adjuster) {\n Assert(!this._inRuleset(), 'Cannot fork inside a ruleset');\n var obj = this; // eslint-disable-line consistent-this\n\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = [].concat(paths)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var path = _step3.value;\n path = Array.isArray(path) ? path : path.split('.');\n obj = obj._ids.fork(path, adjuster, obj);\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"message\",\n value: function message(_message) {\n return this.rule({\n message: _message\n });\n }\n }, {\n key: \"rule\",\n value: function rule(options) {\n Common.assertOptions(options, ['keep', 'message', 'warn']);\n Assert(this._ruleset !== false, 'Cannot apply rules to empty ruleset');\n var start = this._ruleset === null ? this._rules.length - 1 : this._ruleset;\n Assert(start >= 0 && start < this._rules.length, 'Cannot apply rules to empty ruleset');\n options = Object.assign({}, options); // Shallow cloned\n\n if (options.message) {\n options.message = Messages.compile(options.message);\n }\n\n var obj = this.clone();\n\n for (var i = start; i < obj._rules.length; ++i) {\n obj._rules[i] = Object.assign({}, obj._rules[i], options);\n }\n\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"tailor\",\n value: function tailor(targets) {\n Assert(!this._inRuleset(), 'Cannot tailor inside a ruleset');\n\n if (!this.$_terms.alterations) {\n return this;\n }\n\n targets = [].concat(targets);\n var obj = this; // eslint-disable-line consistent-this\n\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = this.$_terms.alterations[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var _step4$value = _step4.value,\n target = _step4$value.target,\n adjuster = _step4$value.adjuster;\n\n if (targets.includes(target)) {\n obj = adjuster(obj);\n Assert(Common.isSchema(obj), 'Alteration adjuster for', target, 'failed to return a schema object');\n }\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"validate\",\n value: function validate(value, options) {\n return Validator.entry(value, this, options);\n }\n }, {\n key: \"validateAsync\",\n value: function validateAsync(value, options) {\n return Validator.entryAsync(value, this, options);\n }\n }, {\n key: \"warn\",\n value: function warn() {\n return this.rule({\n warn: true\n });\n } // Extensions\n\n }, {\n key: \"$_addRule\",\n value: function $_addRule(options) {\n // Normalize rule\n if (typeof options === 'string') {\n options = {\n name: options\n };\n }\n\n Assert(options && _typeof(options) === 'object', 'Invalid options');\n Assert(options.name && typeof options.name === 'string', 'Invalid rule name');\n var rule = {\n name: options.name,\n method: options.method || options.name,\n args: options.args,\n resolve: [],\n warn: options.warn,\n options: options\n };\n var definition = this._definition.rules[rule.method];\n Assert(definition, 'Unknown rule', rule.method);\n Assert(!rule.args || Object.keys(rule.args).length === 1 || Object.keys(rule.args).length === this._definition.rules[rule.name].args.length, 'Invalid rule definition for', this.type, rule.name); // Check for unique changes\n\n if (!definition.multi && this._singleRules.has(rule.name) && DeepEqual(rule.options, this._singleRules.get(rule.name))) {\n return this;\n } // Args\n\n\n var obj = this.clone();\n var args = rule.args;\n\n if (args) {\n for (var key in args) {\n var arg = args[key];\n\n if (arg === undefined) {\n delete args[key];\n continue;\n }\n\n if (definition.argsByName) {\n var resolver = definition.argsByName.get(key);\n\n if (resolver.ref) {\n if (Common.isResolvable(arg)) {\n rule.resolve.push(key);\n\n obj._refs.register(arg);\n } else {\n if (resolver.normalize) {\n arg = resolver.normalize(arg);\n rule.args[key] = arg;\n }\n\n Assert(resolver.assert(arg), key, resolver.message, 'or reference');\n }\n }\n }\n\n args[key] = arg;\n }\n } // Unique rules\n\n\n if (!definition.multi) {\n obj._ruleRemove(rule.name, {\n clone: false\n });\n\n obj._singleRules.set(rule.name, rule.options);\n }\n\n if (obj._ruleset === false) {\n obj._ruleset = null;\n }\n\n if (definition.priority) {\n obj._rules.unshift(rule);\n } else {\n obj._rules.push(rule);\n }\n\n return obj;\n }\n }, {\n key: \"$_compile\",\n value: function $_compile(schema, options) {\n return Compile.schema(this._root, schema, options);\n }\n }, {\n key: \"$_createError\",\n value: function $_createError(code, value, local, state, prefs) {\n var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};\n var flags = options.flags !== false ? this._flags : {};\n return new Errors.Report(code, value, local, flags, this._definition.messages, state, prefs);\n }\n }, {\n key: \"$_getFlag\",\n value: function $_getFlag(name) {\n return this._flags[name];\n }\n }, {\n key: \"$_getRule\",\n value: function $_getRule(name) {\n return this._singleRules.get(name);\n }\n }, {\n key: \"$_getRules\",\n value: function $_getRules(name) {\n var rules = [];\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = this._rules[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var test = _step5.value;\n\n if (test.name === name) {\n rules.push(test.options);\n }\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n\n return rules;\n }\n }, {\n key: \"$_mapLabels\",\n value: function $_mapLabels(path) {\n path = Array.isArray(path) ? path : path.split('.');\n return this._ids.labels(path);\n }\n }, {\n key: \"$_match\",\n value: function $_match(value, state, prefs) {\n prefs = Object.assign({}, prefs); // Shallow cloned\n\n prefs.abortEarly = true;\n prefs._externals = false;\n return !Validator.validate(value, this, state, prefs).errors;\n }\n }, {\n key: \"$_mutateRebuild\",\n value: function $_mutateRebuild() {\n if (!this._definition.rebuild) {\n return this;\n }\n\n Assert(!this._inRuleset(), 'Cannot add this rule inside a ruleset');\n\n this._refs.reset();\n\n this._ids.reset();\n\n this._definition.rebuild(this);\n\n this._ruleset = false;\n return this;\n }\n }, {\n key: \"$_mutateRegister\",\n value: function $_mutateRegister(schema) {\n var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n family = _ref.family,\n key = _ref.key;\n\n this._refs.register(schema, family);\n\n this._ids.register(schema, key);\n }\n }, {\n key: \"$_property\",\n value: function $_property(name) {\n return this._definition.properties[name];\n }\n }, {\n key: \"$_reach\",\n value: function $_reach(path) {\n return this._ids.reach(path);\n }\n }, {\n key: \"$_replaceRules\",\n value: function $_replaceRules(name, each) {\n var obj;\n\n for (var i = 0; i < this._rules.length; ++i) {\n var rule = this._rules[i];\n\n if (rule.name !== name) {\n continue;\n }\n\n var override = each(rule);\n\n if (override) {\n override.args = override.options.args;\n obj = obj || this.clone();\n obj._rules[i] = override;\n\n if (obj._singleRules.has(name)) {\n obj._singleRules.set(name, override.options);\n }\n }\n }\n\n if (obj) {\n return obj.$_mutateRebuild();\n }\n\n return this;\n }\n }, {\n key: \"$_rootReferences\",\n value: function $_rootReferences() {\n return this._refs.roots();\n }\n }, {\n key: \"$_setFlag\",\n value: function $_setFlag(name, value) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(!this._inRuleset(), 'Cannot set flag inside a ruleset');\n\n if (DeepEqual(value, this._flags[name])) {\n return this;\n }\n\n var obj = options.clone !== false ? this.clone() : this;\n\n if (value !== undefined) {\n obj._flags[name] = value;\n } else {\n delete obj._flags[name];\n }\n\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"$_validate\",\n value: function $_validate(value, state, prefs) {\n return Validator.validate(value, this, state, prefs);\n } // Internals\n\n }, {\n key: \"_assign\",\n value: function _assign(target) {\n target.type = this.type;\n target._root = this._root;\n target._ids = this._ids.clone();\n target._preferences = this._preferences;\n target._valids = this._valids && this._valids.clone();\n target._invalids = this._invalids && this._invalids.clone();\n target._rules = this._rules.slice();\n target._singleRules = Clone(this._singleRules, {\n shallow: true\n });\n target._ruleset = this._ruleset;\n target._refs = this._refs.clone();\n target._flags = Clone(this._flags);\n target._cache = null;\n target.$_terms = {};\n\n for (var key in this.$_terms) {\n target.$_terms[key] = this.$_terms[key] ? this.$_terms[key].slice() : null;\n }\n\n target.super = {};\n\n for (var override in this.super) {\n target.super[override] = this._super[override].bind(target);\n }\n\n return target;\n }\n }, {\n key: \"_default\",\n value: function _default(flag, value) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Common.assertOptions(options, 'literal');\n Assert(value !== undefined, 'Missing', flag, 'value');\n Assert(typeof value === 'function' || !options.literal, 'Only function value supports literal option');\n\n if (typeof value === 'function' && options.literal) {\n var _value;\n\n value = (_value = {}, _defineProperty(_value, Common.symbols.literal, true), _defineProperty(_value, \"literal\", value), _value);\n }\n\n var obj = this.$_setFlag(flag, value);\n\n obj._refs.register(value);\n\n return obj;\n }\n }, {\n key: \"_inner\",\n value: function _inner(type, values) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(!this._inRuleset(), \"Cannot set \".concat(type, \" inside a ruleset\"));\n var obj = this.clone();\n\n if (!obj.$_terms[type] || options.override) {\n obj.$_terms[type] = [];\n }\n\n if (options.single) {\n obj.$_terms[type].push(values);\n } else {\n var _obj$$_terms$type;\n\n (_obj$$_terms$type = obj.$_terms[type]).push.apply(_obj$$_terms$type, _toConsumableArray(values));\n }\n\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"_inRuleset\",\n value: function _inRuleset() {\n return this._ruleset !== null && this._ruleset !== false;\n }\n }, {\n key: \"_ruleRemove\",\n value: function _ruleRemove(name) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!this._singleRules.has(name)) {\n return this;\n }\n\n var obj = options.clone !== false ? this.clone() : this;\n\n obj._singleRules.delete(name);\n\n var filtered = [];\n\n for (var i = 0; i < obj._rules.length; ++i) {\n var test = obj._rules[i];\n\n if (test.name === name && !test.keep) {\n if (obj._inRuleset() && i < obj._ruleset) {\n --obj._ruleset;\n }\n\n continue;\n }\n\n filtered.push(test);\n }\n\n obj._rules = filtered;\n return obj;\n }\n }, {\n key: \"ruleset\",\n get: function get() {\n Assert(!this._inRuleset(), 'Cannot start a new ruleset without closing the previous one');\n var obj = this.clone();\n obj._ruleset = obj._rules.length;\n return obj;\n }\n }, {\n key: \"$\",\n get: function get() {\n return this.ruleset;\n }\n }]);\n\n return _class;\n}();\n\ninternals.Base.prototype.isImmutable = true; // Prevents Hoek from deep cloning schema objects\n\ninternals.Base.prototype[Common.symbols.any] = {\n version: Common.version,\n compile: Compile.compile,\n root: '_root'\n}; // Aliases\n\ninternals.Base.prototype.disallow = internals.Base.prototype.invalids;\ninternals.Base.prototype.equal = internals.Base.prototype.valid;\ninternals.Base.prototype.exist = internals.Base.prototype.required;\ninternals.Base.prototype.not = internals.Base.prototype.invalid;\ninternals.Base.prototype.options = internals.Base.prototype.prefs;\ninternals.Base.prototype.preferences = internals.Base.prototype.prefs;\nmodule.exports = new internals.Base();" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst DeepEqual = require('@hapi/hoek/lib/deepEqual');\n\nconst Merge = require('@hapi/hoek/lib/merge');\n\nconst Cache = require('./cache');\n\nconst Common = require('./common');\n\nconst Compile = require('./compile');\n\nconst Errors = require('./errors');\n\nconst Extend = require('./extend');\n\nconst Manifest = require('./manifest');\n\nconst Messages = require('./messages');\n\nconst Modify = require('./modify');\n\nconst Ref = require('./ref');\n\nconst Validator = require('./validator');\n\nconst Values = require('./values');\n\nconst internals = {};\ninternals.Base = class {\n constructor(type) {\n // Naming: public, _private, $_extension, $_mutate{action}\n this.type = type;\n this._definition = {};\n this._ids = new Modify.Ids();\n this._preferences = null;\n this._refs = new Ref.Manager();\n this._cache = null;\n this._valids = null;\n this._invalids = null;\n this._flags = {};\n this._rules = [];\n this._singleRules = new Map(); // The rule options passed for non-multi rules\n\n this._ruleset = null; // null: use last, false: error, number: start position\n\n this.$_terms = {\n // Hash of arrays of immutable objects (extended by other types)\n alterations: null,\n examples: null,\n externals: null,\n metas: [],\n notes: [],\n tags: []\n };\n } // Manifest\n\n\n describe() {\n return Manifest.describe(this);\n } // Rules\n\n\n allow() {\n for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {\n values[_key] = arguments[_key];\n }\n\n Common.verifyFlat(values, 'allow');\n const obj = this.clone();\n\n if (!obj._valids) {\n obj._valids = new Values();\n }\n\n for (const value of values) {\n Assert(value !== undefined, 'Cannot call allow/valid/invalid with undefined');\n\n if (obj._invalids) {\n obj._invalids.remove(value);\n\n if (!obj._invalids.length) {\n obj._invalids = null;\n }\n }\n\n obj._valids.add(value, obj._refs);\n }\n\n return obj;\n }\n\n alter(targets) {\n Assert(targets && typeof targets === 'object' && !Array.isArray(targets), 'Invalid targets argument');\n Assert(!this._inRuleset(), 'Cannot set alterations inside a ruleset');\n const obj = this.clone();\n obj.$_terms.alterations = obj.$_terms.alterations || [];\n\n for (const target in targets) {\n const adjuster = targets[target];\n Assert(typeof adjuster === 'function', 'Alteration adjuster for', target, 'must be a function');\n obj.$_terms.alterations.push({\n target,\n adjuster\n });\n }\n\n obj._ruleset = false;\n return obj;\n }\n\n cast(to) {\n Assert(to === false || this._definition.cast[to], 'Type', this.type, 'does not support casting to', to);\n return this.$_setFlag('cast', to === false ? undefined : to);\n }\n\n default(value, options) {\n return this._default('default', value, options);\n }\n\n description(desc) {\n Assert(desc && typeof desc === 'string', 'Description must be a non-empty string');\n return this.$_setFlag('description', desc);\n }\n\n empty(schema) {\n const obj = this.clone();\n\n if (schema !== undefined) {\n schema = obj.$_compile(schema);\n\n obj._refs.register(schema);\n }\n\n return obj.$_setFlag('empty', schema, {\n clone: false\n });\n }\n\n error(err) {\n Assert(err, 'Missing error');\n Assert(err instanceof Error || typeof err === 'function', 'Must provide a valid Error object or a function');\n return this.$_setFlag('error', err);\n }\n\n example(example) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(example !== undefined, 'Missing example');\n Common.assertOptions(options, ['override']);\n return this._inner('examples', example, {\n single: true,\n override: options.override\n });\n }\n\n external(method) {\n Assert(typeof method === 'function', 'Method must be a function');\n return this._inner('externals', method, {\n single: true\n });\n }\n\n failover(value, options) {\n return this._default('failover', value, options);\n }\n\n forbidden() {\n return this.presence('forbidden');\n }\n\n id(id) {\n Assert(id && typeof id === 'string', 'id must be a non-empty string');\n Assert(/^[^\\.]+$/.test(id), 'id cannot contain period character');\n Assert(!this._flags.id, 'Cannot override schema id');\n return this.$_setFlag('id', id);\n }\n\n invalid() {\n for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n values[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(values, 'invalid');\n const obj = this.clone();\n\n if (!obj._invalids) {\n obj._invalids = new Values();\n }\n\n for (const value of values) {\n Assert(value !== undefined, 'Cannot call allow/valid/invalid with undefined');\n\n if (obj._valids) {\n obj._valids.remove(value);\n\n if (!obj._valids.length) {\n Assert(!obj._flags.only, 'Setting invalid value', value, 'leaves schema rejecting all values due to previous valid rule');\n obj._valids = null;\n }\n }\n\n obj._invalids.add(value, obj._refs);\n }\n\n return obj;\n }\n\n keep() {\n return this.rule({\n keep: true\n });\n }\n\n label(name) {\n Assert(name && typeof name === 'string', 'Label name must be a non-empty string');\n return this.$_setFlag('label', name);\n }\n\n meta(meta) {\n Assert(meta !== undefined, 'Meta cannot be undefined');\n return this._inner('metas', meta, {\n single: true\n });\n }\n\n note() {\n for (var _len3 = arguments.length, notes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n notes[_key3] = arguments[_key3];\n }\n\n Assert(notes.length, 'Missing notes');\n\n for (const note of notes) {\n Assert(note && typeof note === 'string', 'Notes must be non-empty strings');\n }\n\n return this._inner('notes', notes);\n }\n\n only() {\n let mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof mode === 'boolean', 'Invalid mode:', mode);\n return this.$_setFlag('only', mode);\n }\n\n optional() {\n return this.presence('optional');\n }\n\n prefs(prefs) {\n Assert(prefs.context === undefined, 'Cannot override context');\n Assert(prefs.externals === undefined, 'Cannot override externals');\n Assert(prefs.warnings === undefined, 'Cannot override warnings');\n Common.checkPreferences(prefs);\n const obj = this.clone();\n obj._preferences = Common.preferences(obj._preferences, prefs);\n return obj;\n }\n\n presence(mode) {\n Assert(['optional', 'required', 'forbidden'].includes(mode), 'Unknown presence mode', mode);\n return this.$_setFlag('presence', mode);\n }\n\n raw() {\n let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n return this.$_setFlag('result', enabled ? 'raw' : undefined);\n }\n\n result(mode) {\n Assert(['raw', 'strip'].includes(mode), 'Unknown result mode', mode);\n return this.$_setFlag('result', mode);\n }\n\n required() {\n return this.presence('required');\n }\n\n strict(enabled) {\n const obj = this.clone();\n const convert = enabled === undefined ? false : !enabled;\n obj._preferences = Common.preferences(obj._preferences, {\n convert\n });\n return obj;\n }\n\n strip() {\n let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n return this.$_setFlag('result', enabled ? 'strip' : undefined);\n }\n\n tag() {\n for (var _len4 = arguments.length, tags = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n tags[_key4] = arguments[_key4];\n }\n\n Assert(tags.length, 'Missing tags');\n\n for (const tag of tags) {\n Assert(tag && typeof tag === 'string', 'Tags must be non-empty strings');\n }\n\n return this._inner('tags', tags);\n }\n\n unit(name) {\n Assert(name && typeof name === 'string', 'Unit name must be a non-empty string');\n return this.$_setFlag('unit', name);\n }\n\n valid() {\n return this.allow(...arguments).$_setFlag('only', true, {\n clone: false\n });\n }\n\n when(condition, options) {\n if (Array.isArray(options)) {\n options = {\n switch: options\n };\n }\n\n Common.assertOptions(options, ['is', 'then', 'otherwise', 'switch']);\n Assert(options.then || options.otherwise || options.switch, 'At least one of then, otherwise, or switch is required');\n\n const process = settings => {\n const item = {\n is: settings.is,\n then: settings.then && this.concat(this.$_compile(settings.then))\n };\n\n if (settings.otherwise) {\n item.otherwise = this.concat(this.$_compile(settings.otherwise));\n }\n\n return item;\n };\n\n const alt = process(options);\n\n if (options.switch) {\n Assert(Array.isArray(options.switch), '\"switch\" must be an array');\n alt.switch = options.switch.map(process);\n const last = alt.switch[alt.switch.length - 1];\n\n if (!alt.otherwise && !last.otherwise) {\n last.otherwise = this;\n }\n } else {\n if (!alt.then) {\n alt.then = this;\n } else if (!alt.otherwise) {\n alt.otherwise = this;\n }\n }\n\n return this._root.alternatives().when(condition, alt);\n } // Helpers\n\n\n cache(cache) {\n Assert(!this._inRuleset(), 'Cannot set caching inside a ruleset');\n Assert(!this._cache, 'Cannot override schema cache');\n const obj = this.clone();\n obj._cache = cache || Cache.provider.provision();\n obj._ruleset = false;\n return obj;\n }\n\n clone() {\n const obj = Object.create(Object.getPrototypeOf(this));\n return this._assign(obj);\n }\n\n concat(source) {\n Assert(Common.isSchema(source), 'Invalid schema object');\n Assert(this.type === 'any' || source.type === 'any' || source.type === this.type, 'Cannot merge type', this.type, 'with another type:', source.type);\n let obj = this.clone();\n\n if (this.type === 'any' && source.type !== 'any') {\n // Change obj to match source type\n const tmpObj = source.clone();\n\n for (const key of Object.keys(obj)) {\n if (key !== 'type') {\n tmpObj[key] = obj[key];\n }\n }\n\n obj = tmpObj;\n }\n\n obj._ids.concat(source._ids);\n\n obj._preferences = obj._preferences ? Common.preferences(obj._preferences, source._preferences) : source._preferences;\n obj._valids = Values.merge(obj._valids, source._valids, source._invalids);\n obj._invalids = Values.merge(obj._invalids, source._invalids, source._valids);\n\n obj._refs.register(source, Ref.toSibling); // Remove unique rules present in source\n\n\n for (const name of source._singleRules.keys()) {\n if (obj._singleRules.has(name)) {\n obj._rules = obj._rules.filter(target => target.name !== name);\n\n obj._singleRules.delete(name);\n }\n } // Adjust ruleset\n\n\n if (source._ruleset !== null) {\n Assert(!obj._inRuleset(), 'Cannot concatenate onto a schema with open ruleset');\n obj._ruleset = source._ruleset === false ? false : source._ruleset + obj._rules.length;\n } // Rules\n\n\n for (const test of source._rules) {\n if (!source._definition.rules[test.method].multi) {\n obj._singleRules.set(test.name, test.options);\n }\n\n obj._rules.push(test);\n } // Flags\n\n\n if (obj._flags.empty && source._flags.empty) {\n obj._flags.empty = obj._flags.empty.concat(source._flags.empty);\n const flags = Object.assign({}, source._flags);\n delete flags.empty;\n Merge(obj._flags, flags);\n } else if (source._flags.empty) {\n obj._flags.empty = source._flags.empty;\n const flags = Object.assign({}, source._flags);\n delete flags.empty;\n Merge(obj._flags, flags);\n } else {\n Merge(obj._flags, source._flags);\n } // Terms\n\n\n for (const key in source.$_terms) {\n const terms = source.$_terms[key];\n\n if (!terms) {\n if (!obj.$_terms[key]) {\n obj.$_terms[key] = terms;\n }\n\n continue;\n }\n\n if (!obj.$_terms[key]) {\n obj.$_terms[key] = terms.slice();\n continue;\n }\n\n obj.$_terms[key] = obj.$_terms[key].concat(terms);\n }\n\n return obj.$_mutateRebuild();\n }\n\n extend(options) {\n return Extend.type(this, options);\n }\n\n extract(path) {\n path = Array.isArray(path) ? path : path.split('.');\n return this._ids.reach(path);\n }\n\n fork(paths, adjuster) {\n Assert(!this._inRuleset(), 'Cannot fork inside a ruleset');\n let obj = this; // eslint-disable-line consistent-this\n\n for (let path of [].concat(paths)) {\n path = Array.isArray(path) ? path : path.split('.');\n obj = obj._ids.fork(path, adjuster, obj);\n }\n\n obj._ruleset = false;\n return obj;\n }\n\n message(message) {\n return this.rule({\n message\n });\n }\n\n rule(options) {\n Common.assertOptions(options, ['keep', 'message', 'warn']);\n Assert(this._ruleset !== false, 'Cannot apply rules to empty ruleset');\n const start = this._ruleset === null ? this._rules.length - 1 : this._ruleset;\n Assert(start >= 0 && start < this._rules.length, 'Cannot apply rules to empty ruleset');\n options = Object.assign({}, options); // Shallow cloned\n\n if (options.message) {\n options.message = Messages.compile(options.message);\n }\n\n const obj = this.clone();\n\n for (let i = start; i < obj._rules.length; ++i) {\n obj._rules[i] = Object.assign({}, obj._rules[i], options);\n }\n\n obj._ruleset = false;\n return obj;\n }\n\n get ruleset() {\n Assert(!this._inRuleset(), 'Cannot start a new ruleset without closing the previous one');\n const obj = this.clone();\n obj._ruleset = obj._rules.length;\n return obj;\n }\n\n get $() {\n return this.ruleset;\n }\n\n tailor(targets) {\n Assert(!this._inRuleset(), 'Cannot tailor inside a ruleset');\n\n if (!this.$_terms.alterations) {\n return this;\n }\n\n targets = [].concat(targets);\n let obj = this; // eslint-disable-line consistent-this\n\n for (const _ref of this.$_terms.alterations) {\n const {\n target,\n adjuster\n } = _ref;\n\n if (targets.includes(target)) {\n obj = adjuster(obj);\n Assert(Common.isSchema(obj), 'Alteration adjuster for', target, 'failed to return a schema object');\n }\n }\n\n obj._ruleset = false;\n return obj;\n }\n\n validate(value, options) {\n return Validator.entry(value, this, options);\n }\n\n validateAsync(value, options) {\n return Validator.entryAsync(value, this, options);\n }\n\n warn() {\n return this.rule({\n warn: true\n });\n } // Extensions\n\n\n $_addRule(options) {\n // Normalize rule\n if (typeof options === 'string') {\n options = {\n name: options\n };\n }\n\n Assert(options && typeof options === 'object', 'Invalid options');\n Assert(options.name && typeof options.name === 'string', 'Invalid rule name');\n const rule = {\n name: options.name,\n method: options.method || options.name,\n args: options.args,\n resolve: [],\n warn: options.warn,\n options\n };\n const definition = this._definition.rules[rule.method];\n Assert(definition, 'Unknown rule', rule.method);\n Assert(!rule.args || Object.keys(rule.args).length === 1 || Object.keys(rule.args).length === this._definition.rules[rule.name].args.length, 'Invalid rule definition for', this.type, rule.name); // Check for unique changes\n\n if (!definition.multi && this._singleRules.has(rule.name) && DeepEqual(rule.options, this._singleRules.get(rule.name))) {\n return this;\n } // Args\n\n\n const obj = this.clone();\n const args = rule.args;\n\n if (args) {\n for (const key in args) {\n let arg = args[key];\n\n if (arg === undefined) {\n delete args[key];\n continue;\n }\n\n if (definition.argsByName) {\n const resolver = definition.argsByName.get(key);\n\n if (resolver.ref) {\n if (Common.isResolvable(arg)) {\n rule.resolve.push(key);\n\n obj._refs.register(arg);\n } else {\n if (resolver.normalize) {\n arg = resolver.normalize(arg);\n rule.args[key] = arg;\n }\n\n Assert(resolver.assert(arg), key, resolver.message, 'or reference');\n }\n }\n }\n\n args[key] = arg;\n }\n } // Unique rules\n\n\n if (!definition.multi) {\n obj._ruleRemove(rule.name, {\n clone: false\n });\n\n obj._singleRules.set(rule.name, rule.options);\n }\n\n if (obj._ruleset === false) {\n obj._ruleset = null;\n }\n\n if (definition.priority) {\n obj._rules.unshift(rule);\n } else {\n obj._rules.push(rule);\n }\n\n return obj;\n }\n\n $_compile(schema, options) {\n return Compile.schema(this._root, schema, options);\n }\n\n $_createError(code, value, local, state, prefs) {\n let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};\n const flags = options.flags !== false ? this._flags : {};\n return new Errors.Report(code, value, local, flags, this._definition.messages, state, prefs);\n }\n\n $_getFlag(name) {\n return this._flags[name];\n }\n\n $_getRule(name) {\n return this._singleRules.get(name);\n }\n\n $_getRules(name) {\n const rules = [];\n\n for (const test of this._rules) {\n if (test.name === name) {\n rules.push(test.options);\n }\n }\n\n return rules;\n }\n\n $_mapLabels(path) {\n path = Array.isArray(path) ? path : path.split('.');\n return this._ids.labels(path);\n }\n\n $_match(value, state, prefs) {\n prefs = Object.assign({}, prefs); // Shallow cloned\n\n prefs.abortEarly = true;\n prefs._externals = false;\n return !Validator.validate(value, this, state, prefs).errors;\n }\n\n $_mutateRebuild() {\n if (!this._definition.rebuild) {\n return this;\n }\n\n Assert(!this._inRuleset(), 'Cannot add this rule inside a ruleset');\n\n this._refs.reset();\n\n this._ids.reset();\n\n this._definition.rebuild(this);\n\n this._ruleset = false;\n return this;\n }\n\n $_mutateRegister(schema) {\n let {\n family,\n key\n } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n this._refs.register(schema, family);\n\n this._ids.register(schema, key);\n }\n\n $_property(name) {\n return this._definition.properties[name];\n }\n\n $_reach(path) {\n return this._ids.reach(path);\n }\n\n $_replaceRules(name, each) {\n let obj;\n\n for (let i = 0; i < this._rules.length; ++i) {\n const rule = this._rules[i];\n\n if (rule.name !== name) {\n continue;\n }\n\n const override = each(rule);\n\n if (override) {\n override.args = override.options.args;\n obj = obj || this.clone();\n obj._rules[i] = override;\n\n if (obj._singleRules.has(name)) {\n obj._singleRules.set(name, override.options);\n }\n }\n }\n\n if (obj) {\n return obj.$_mutateRebuild();\n }\n\n return this;\n }\n\n $_rootReferences() {\n return this._refs.roots();\n }\n\n $_setFlag(name, value) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(!this._inRuleset(), 'Cannot set flag inside a ruleset');\n\n if (DeepEqual(value, this._flags[name])) {\n return this;\n }\n\n const obj = options.clone !== false ? this.clone() : this;\n\n if (value !== undefined) {\n obj._flags[name] = value;\n } else {\n delete obj._flags[name];\n }\n\n obj._ruleset = false;\n return obj;\n }\n\n $_validate(value, state, prefs) {\n return Validator.validate(value, this, state, prefs);\n } // Internals\n\n\n _assign(target) {\n target.type = this.type;\n target._root = this._root;\n target._ids = this._ids.clone();\n target._preferences = this._preferences;\n target._valids = this._valids && this._valids.clone();\n target._invalids = this._invalids && this._invalids.clone();\n target._rules = this._rules.slice();\n target._singleRules = Clone(this._singleRules, {\n shallow: true\n });\n target._ruleset = this._ruleset;\n target._refs = this._refs.clone();\n target._flags = Clone(this._flags);\n target._cache = null;\n target.$_terms = {};\n\n for (const key in this.$_terms) {\n target.$_terms[key] = this.$_terms[key] ? this.$_terms[key].slice() : null;\n }\n\n target.super = {};\n\n for (const override in this.super) {\n target.super[override] = this._super[override].bind(target);\n }\n\n return target;\n }\n\n _default(flag, value) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Common.assertOptions(options, 'literal');\n Assert(value !== undefined, 'Missing', flag, 'value');\n Assert(typeof value === 'function' || !options.literal, 'Only function value supports literal option');\n\n if (typeof value === 'function' && options.literal) {\n value = {\n [Common.symbols.literal]: true,\n literal: value\n };\n }\n\n const obj = this.$_setFlag(flag, value);\n\n obj._refs.register(value);\n\n return obj;\n }\n\n _inner(type, values) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(!this._inRuleset(), \"Cannot set \".concat(type, \" inside a ruleset\"));\n const obj = this.clone();\n\n if (!obj.$_terms[type] || options.override) {\n obj.$_terms[type] = [];\n }\n\n if (options.single) {\n obj.$_terms[type].push(values);\n } else {\n obj.$_terms[type].push(...values);\n }\n\n obj._ruleset = false;\n return obj;\n }\n\n _inRuleset() {\n return this._ruleset !== null && this._ruleset !== false;\n }\n\n _ruleRemove(name) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!this._singleRules.has(name)) {\n return this;\n }\n\n const obj = options.clone !== false ? this.clone() : this;\n\n obj._singleRules.delete(name);\n\n const filtered = [];\n\n for (let i = 0; i < obj._rules.length; ++i) {\n const test = obj._rules[i];\n\n if (test.name === name && !test.keep) {\n if (obj._inRuleset() && i < obj._ruleset) {\n --obj._ruleset;\n }\n\n continue;\n }\n\n filtered.push(test);\n }\n\n obj._rules = filtered;\n return obj;\n }\n\n};\ninternals.Base.prototype.isImmutable = true; // Prevents Hoek from deep cloning schema objects\n\ninternals.Base.prototype[Common.symbols.any] = {\n version: Common.version,\n compile: Compile.compile,\n root: '_root'\n}; // Aliases\n\ninternals.Base.prototype.disallow = internals.Base.prototype.invalids;\ninternals.Base.prototype.equal = internals.Base.prototype.valid;\ninternals.Base.prototype.exist = internals.Base.prototype.required;\ninternals.Base.prototype.not = internals.Base.prototype.invalid;\ninternals.Base.prototype.options = internals.Base.prototype.prefs;\ninternals.Base.prototype.preferences = internals.Base.prototype.prefs;\nmodule.exports = new internals.Base();" }, { - "id": 32, + "id": 31, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/extend.js", "name": "../lib/extend.js", "index": 26, "index2": 22, - "size": 6758, + "size": 5055, "cacheable": true, "built": true, "optional": false, @@ -3134,7 +3041,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", - "issuerId": 31, + "issuerId": 30, "issuerName": "../lib/base.js", "issuerPath": [ { @@ -3142,8 +3049,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -3151,25 +3058,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/any.js", "name": "../lib/types/any.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 31, + "id": 30, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "name": "../lib/base.js", "profile": { - "factory": 767, - "building": 322, + "factory": 353, + "building": 264, "dependencies": 2 } } ], "profile": { - "factory": 169, - "building": 279, + "factory": 101, + "building": 141, "dependencies": 0 }, "failed": false, @@ -3178,13 +3085,13 @@ "assets": [], "reasons": [ { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./extend", - "loc": "37:13-32" + "loc": "19:15-34" } ], "usedExports": true, @@ -3193,15 +3100,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Messages = require('./messages');\n\nvar internals = {};\n\nexports.type = function (from, options) {\n var base = Object.getPrototypeOf(from);\n var prototype = Clone(base);\n\n var schema = from._assign(Object.create(prototype));\n\n var def = Object.assign({}, options); // Shallow cloned\n\n prototype._definition = def;\n var parent = base._definition || {};\n def.messages = Messages.merge(parent.messages, def.messages);\n def.properties = Object.assign({}, parent.properties, def.properties); // Initialize\n\n schema.type = def.type;\n\n if (def.initialize) {\n def.initialize(schema);\n }\n\n if (!def.args) {\n def.args = parent.args;\n } // Validate\n\n\n def.validate = internals.validate(def.validate, parent.validate); // Coerce\n\n if (def.coerce) {\n if (typeof def.coerce === 'function') {\n def.coerce = {\n method: def.coerce\n };\n }\n\n if (def.coerce.from && !Array.isArray(def.coerce.from)) {\n def.coerce = {\n method: def.coerce.method,\n from: [].concat(def.coerce.from)\n };\n }\n }\n\n def.coerce = internals.coerce(def.coerce, parent.coerce); // Rules\n\n var rules = Object.assign({}, parent.rules);\n\n if (def.rules) {\n var _loop = function _loop(name) {\n var rule = def.rules[name];\n Assert(_typeof(rule) === 'object', 'Invalid rule definition for', def.type, name);\n var method = rule.method;\n\n if (method === undefined) {\n method = function method() {\n return this.$_addRule(name);\n };\n }\n\n if (method) {\n Assert(!prototype[name], 'Rule conflict in', def.type, name);\n prototype[name] = method;\n }\n\n Assert(!rules[name], 'Rule conflict in', def.type, name);\n rules[name] = rule;\n\n if (rule.alias) {\n var aliases = [].concat(rule.alias);\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = aliases[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var alias = _step.value;\n prototype[alias] = rule.method;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n\n if (rule.args) {\n rule.argsByName = new Map();\n rule.args = rule.args.map(function (arg) {\n if (typeof arg === 'string') {\n arg = {\n name: arg\n };\n }\n\n Assert(!rule.argsByName.has(arg.name), 'Duplicated argument name', arg.name);\n rule.argsByName.set(arg.name, arg);\n return arg;\n });\n }\n };\n\n for (var name in def.rules) {\n _loop(name);\n }\n }\n\n def.rules = rules; // Overrides\n\n if (def.overrides) {\n prototype._super = base;\n schema.super = {};\n\n for (var override in def.overrides) {\n Assert(base[override], 'Cannot override missing', override);\n schema.super[override] = base[override].bind(schema);\n }\n\n Object.assign(prototype, def.overrides);\n } // Casts\n\n\n def.cast = Object.assign({}, parent.cast, def.cast); // Manifest\n\n def.build = internals.build(def.build, parent.build); // Modify\n\n def.modify = internals.modify(def.modify, parent.modify);\n def.rebuild = internals.rebuild(def.rebuild, parent.rebuild);\n schema._ids._reachable = !!def.modify;\n return schema;\n}; // Helpers\n\n\ninternals.build = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (obj, desc) {\n return child(parent(obj, desc), desc);\n };\n};\n\ninternals.coerce = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return {\n from: child.from && parent.from ? _toConsumableArray(new Set([].concat(_toConsumableArray(child.from), _toConsumableArray(parent.from)))) : null,\n method: function method(schema, value, helpers) {\n var coerced;\n\n if (!parent.from || parent.from.includes(_typeof(value))) {\n coerced = parent.method(schema, value, helpers);\n\n if (coerced) {\n if (coerced.errors) {\n return coerced;\n }\n\n value = coerced.value;\n }\n }\n\n if (value !== undefined && (!child.from || child.from.includes(_typeof(value)))) {\n var own = child.method(schema, value, helpers);\n\n if (own) {\n if (own.errors) {\n return own;\n }\n\n coerced = own;\n }\n }\n\n return coerced;\n }\n };\n};\n\ninternals.modify = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (obj, id, schema) {\n var found = parent(obj, id, schema);\n\n if (found) {\n return found;\n }\n\n return child(obj, id, schema);\n };\n};\n\ninternals.rebuild = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (schema) {\n parent(schema);\n child(schema);\n };\n};\n\ninternals.validate = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (schema, value, helpers) {\n var result = parent(schema, value, helpers);\n\n if (result) {\n if (result.errors && (!Array.isArray(result.errors) || result.errors.length)) {\n return result;\n }\n\n value = result.value;\n }\n\n return child(schema, value, helpers);\n };\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Messages = require('./messages');\n\nconst internals = {};\n\nexports.type = function (from, options) {\n const base = Object.getPrototypeOf(from);\n const prototype = Clone(base);\n\n const schema = from._assign(Object.create(prototype));\n\n const def = Object.assign({}, options); // Shallow cloned\n\n prototype._definition = def;\n const parent = base._definition || {};\n def.messages = Messages.merge(parent.messages, def.messages);\n def.properties = Object.assign({}, parent.properties, def.properties); // Initialize\n\n schema.type = def.type;\n\n if (def.initialize) {\n def.initialize(schema);\n }\n\n if (!def.args) {\n def.args = parent.args;\n } // Validate\n\n\n def.validate = internals.validate(def.validate, parent.validate); // Coerce\n\n if (def.coerce) {\n if (typeof def.coerce === 'function') {\n def.coerce = {\n method: def.coerce\n };\n }\n\n if (def.coerce.from && !Array.isArray(def.coerce.from)) {\n def.coerce = {\n method: def.coerce.method,\n from: [].concat(def.coerce.from)\n };\n }\n }\n\n def.coerce = internals.coerce(def.coerce, parent.coerce); // Rules\n\n const rules = Object.assign({}, parent.rules);\n\n if (def.rules) {\n for (const name in def.rules) {\n const rule = def.rules[name];\n Assert(typeof rule === 'object', 'Invalid rule definition for', def.type, name);\n let method = rule.method;\n\n if (method === undefined) {\n method = function method() {\n return this.$_addRule(name);\n };\n }\n\n if (method) {\n Assert(!prototype[name], 'Rule conflict in', def.type, name);\n prototype[name] = method;\n }\n\n Assert(!rules[name], 'Rule conflict in', def.type, name);\n rules[name] = rule;\n\n if (rule.alias) {\n const aliases = [].concat(rule.alias);\n\n for (const alias of aliases) {\n prototype[alias] = rule.method;\n }\n }\n\n if (rule.args) {\n rule.argsByName = new Map();\n rule.args = rule.args.map(arg => {\n if (typeof arg === 'string') {\n arg = {\n name: arg\n };\n }\n\n Assert(!rule.argsByName.has(arg.name), 'Duplicated argument name', arg.name);\n rule.argsByName.set(arg.name, arg);\n return arg;\n });\n }\n }\n }\n\n def.rules = rules; // Overrides\n\n if (def.overrides) {\n prototype._super = base;\n schema.super = {};\n\n for (const override in def.overrides) {\n Assert(base[override], 'Cannot override missing', override);\n schema.super[override] = base[override].bind(schema);\n }\n\n Object.assign(prototype, def.overrides);\n } // Casts\n\n\n def.cast = Object.assign({}, parent.cast, def.cast); // Manifest\n\n def.build = internals.build(def.build, parent.build); // Modify\n\n def.modify = internals.modify(def.modify, parent.modify);\n def.rebuild = internals.rebuild(def.rebuild, parent.rebuild);\n schema._ids._reachable = !!def.modify;\n return schema;\n}; // Helpers\n\n\ninternals.build = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (obj, desc) {\n return child(parent(obj, desc), desc);\n };\n};\n\ninternals.coerce = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return {\n from: child.from && parent.from ? [...new Set([...child.from, ...parent.from])] : null,\n method: function method(schema, value, helpers) {\n let coerced;\n\n if (!parent.from || parent.from.includes(typeof value)) {\n coerced = parent.method(schema, value, helpers);\n\n if (coerced) {\n if (coerced.errors) {\n return coerced;\n }\n\n value = coerced.value;\n }\n }\n\n if (value !== undefined && (!child.from || child.from.includes(typeof value))) {\n const own = child.method(schema, value, helpers);\n\n if (own) {\n if (own.errors) {\n return own;\n }\n\n coerced = own;\n }\n }\n\n return coerced;\n }\n };\n};\n\ninternals.modify = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (obj, id, schema) {\n const found = parent(obj, id, schema);\n\n if (found) {\n return found;\n }\n\n return child(obj, id, schema);\n };\n};\n\ninternals.rebuild = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (schema) {\n parent(schema);\n child(schema);\n };\n};\n\ninternals.validate = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (schema, value, helpers) {\n const result = parent(schema, value, helpers);\n\n if (result) {\n if (result.errors && (!Array.isArray(result.errors) || result.errors.length)) {\n return result;\n }\n\n value = result.value;\n }\n\n return child(schema, value, helpers);\n };\n};" }, { - "id": 33, + "id": 32, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/modify.js", "name": "../lib/modify.js", "index": 27, "index2": 23, - "size": 7000, + "size": 3527, "cacheable": true, "built": true, "optional": false, @@ -3210,7 +3117,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", - "issuerId": 31, + "issuerId": 30, "issuerName": "../lib/base.js", "issuerPath": [ { @@ -3218,8 +3125,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -3227,25 +3134,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/any.js", "name": "../lib/types/any.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 31, + "id": 30, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "name": "../lib/base.js", "profile": { - "factory": 767, - "building": 322, + "factory": 353, + "building": 264, "dependencies": 2 } } ], "profile": { - "factory": 169, - "building": 279, + "factory": 101, + "building": 141, "dependencies": 0 }, "failed": false, @@ -3254,13 +3161,13 @@ "assets": [], "reasons": [ { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./modify", - "loc": "43:13-32" + "loc": "25:15-34" } ], "usedExports": true, @@ -3269,15 +3176,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Common = require('./common');\n\nvar internals = {};\n\nexports.Ids = internals.Ids =\n/*#__PURE__*/\nfunction () {\n function _class() {\n _classCallCheck(this, _class);\n\n this._reachable = false;\n this._map = new Map();\n this._schemaChain = false;\n }\n\n _createClass(_class, [{\n key: \"clone\",\n value: function clone() {\n var clone = new internals.Ids();\n clone._map = new Map(this._map);\n clone._schemaChain = this._schemaChain;\n clone._reachable = this._reachable;\n return clone;\n }\n }, {\n key: \"concat\",\n value: function concat(source) {\n this._reachable = source._reachable;\n\n if (source._schemaChain) {\n this._schemaChain = true;\n }\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = source._map.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n\n this._map.set(key, source._map.get(key));\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n }, {\n key: \"fork\",\n value: function fork(path, adjuster, root) {\n var chain = this._collect(path);\n\n chain.push({\n schema: root\n });\n var tail = chain.shift();\n var adjusted = {\n id: tail.id,\n schema: adjuster(tail.schema)\n };\n Assert(Common.isSchema(adjusted.schema), 'adjuster function failed to return a joi schema type');\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = chain[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var node = _step2.value;\n var def = node.schema._definition;\n adjusted = {\n id: node.id,\n schema: def.modify(node.schema, adjusted.id, adjusted.schema)\n };\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return adjusted.schema;\n }\n }, {\n key: \"labels\",\n value: function labels(path) {\n var behind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n Assert(this._reachable, 'Schema type is not reachable');\n var current = path[0];\n\n var node = this._map.get(current);\n\n if (!node) {\n return [].concat(_toConsumableArray(behind), _toConsumableArray(path)).join('.');\n }\n\n var forward = path.slice(1);\n behind = [].concat(_toConsumableArray(behind), [node.schema._flags.label || current]);\n\n if (!forward.length) {\n return behind.join('.');\n }\n\n return node.schema._ids.labels(forward, behind);\n }\n }, {\n key: \"reach\",\n value: function reach(path) {\n var behind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n Assert(this._reachable, 'Schema type is not reachable');\n var current = path[0];\n\n var node = this._map.get(current);\n\n Assert(node, 'Schema does not contain path', [].concat(_toConsumableArray(behind), _toConsumableArray(path)).join('.'));\n var forward = path.slice(1);\n\n if (!forward.length) {\n return node.schema;\n }\n\n return node.schema._ids.reach(forward, [].concat(_toConsumableArray(behind), [current]));\n }\n }, {\n key: \"register\",\n value: function register(schema, key) {\n if (!schema || !Common.isSchema(schema)) {\n return;\n }\n\n if (schema._definition.properties.schemaChain || schema._ids._schemaChain) {\n this._schemaChain = true;\n }\n\n var id = schema._flags.id || key;\n\n if (!id) {\n return;\n }\n\n Assert(!this._map.has(id), 'Schema already contains id', id);\n\n this._map.set(id, {\n schema: schema,\n key: key,\n id: id\n });\n }\n }, {\n key: \"reset\",\n value: function reset() {\n this._map = new Map();\n this._schemaChain = false;\n }\n }, {\n key: \"_collect\",\n value: function _collect(path) {\n var behind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var nodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n Assert(this._reachable, 'Schema type is not reachable');\n var current = path[0];\n\n var node = this._map.get(current);\n\n Assert(node, 'Schema does not contain path', [].concat(_toConsumableArray(behind), _toConsumableArray(path)).join('.'));\n nodes = [node].concat(_toConsumableArray(nodes));\n var forward = path.slice(1);\n\n if (!forward.length) {\n return nodes;\n }\n\n Assert(node.schema._definition.modify, 'Schema node', [].concat(_toConsumableArray(behind), _toConsumableArray(path)).join('.'), 'does not support manipulation');\n return node.schema._ids._collect(forward, [].concat(_toConsumableArray(behind), [current]), nodes);\n }\n }]);\n\n return _class;\n}();" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Common = require('./common');\n\nconst internals = {};\nexports.Ids = internals.Ids = class {\n constructor() {\n this._reachable = false;\n this._map = new Map();\n this._schemaChain = false;\n }\n\n clone() {\n const clone = new internals.Ids();\n clone._map = new Map(this._map);\n clone._schemaChain = this._schemaChain;\n clone._reachable = this._reachable;\n return clone;\n }\n\n concat(source) {\n this._reachable = source._reachable;\n\n if (source._schemaChain) {\n this._schemaChain = true;\n }\n\n for (const key of source._map.keys()) {\n this._map.set(key, source._map.get(key));\n }\n }\n\n fork(path, adjuster, root) {\n const chain = this._collect(path);\n\n chain.push({\n schema: root\n });\n const tail = chain.shift();\n let adjusted = {\n id: tail.id,\n schema: adjuster(tail.schema)\n };\n Assert(Common.isSchema(adjusted.schema), 'adjuster function failed to return a joi schema type');\n\n for (const node of chain) {\n const def = node.schema._definition;\n adjusted = {\n id: node.id,\n schema: def.modify(node.schema, adjusted.id, adjusted.schema)\n };\n }\n\n return adjusted.schema;\n }\n\n labels(path) {\n let behind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n Assert(this._reachable, 'Schema type is not reachable');\n const current = path[0];\n\n const node = this._map.get(current);\n\n if (!node) {\n return [...behind, ...path].join('.');\n }\n\n const forward = path.slice(1);\n behind = [...behind, node.schema._flags.label || current];\n\n if (!forward.length) {\n return behind.join('.');\n }\n\n return node.schema._ids.labels(forward, behind);\n }\n\n reach(path) {\n let behind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n Assert(this._reachable, 'Schema type is not reachable');\n const current = path[0];\n\n const node = this._map.get(current);\n\n Assert(node, 'Schema does not contain path', [...behind, ...path].join('.'));\n const forward = path.slice(1);\n\n if (!forward.length) {\n return node.schema;\n }\n\n return node.schema._ids.reach(forward, [...behind, current]);\n }\n\n register(schema, key) {\n if (!schema || !Common.isSchema(schema)) {\n return;\n }\n\n if (schema._definition.properties.schemaChain || schema._ids._schemaChain) {\n this._schemaChain = true;\n }\n\n const id = schema._flags.id || key;\n\n if (!id) {\n return;\n }\n\n Assert(!this._map.has(id), 'Schema already contains id', id);\n\n this._map.set(id, {\n schema,\n key,\n id\n });\n }\n\n reset() {\n this._map = new Map();\n this._schemaChain = false;\n }\n\n _collect(path) {\n let behind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n let nodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n Assert(this._reachable, 'Schema type is not reachable');\n const current = path[0];\n\n const node = this._map.get(current);\n\n Assert(node, 'Schema does not contain path', [...behind, ...path].join('.'));\n nodes = [node, ...nodes];\n const forward = path.slice(1);\n\n if (!forward.length) {\n return nodes;\n }\n\n Assert(node.schema._definition.modify, 'Schema node', [...behind, ...path].join('.'), 'does not support manipulation');\n return node.schema._ids._collect(forward, [...behind, current], nodes);\n }\n\n};" }, { - "id": 34, + "id": 33, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/validator.js", "name": "../lib/validator.js", "index": 28, "index2": 24, - "size": 20415, + "size": 12648, "cacheable": true, "built": true, "optional": false, @@ -3286,7 +3193,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", - "issuerId": 31, + "issuerId": 30, "issuerName": "../lib/base.js", "issuerPath": [ { @@ -3294,8 +3201,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -3303,25 +3210,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/any.js", "name": "../lib/types/any.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 31, + "id": 30, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "name": "../lib/base.js", "profile": { - "factory": 767, - "building": 322, + "factory": 353, + "building": 264, "dependencies": 2 } } ], "profile": { - "factory": 169, - "building": 279, + "factory": 101, + "building": 141, "dependencies": 0 }, "failed": false, @@ -3330,13 +3237,13 @@ "assets": [], "reasons": [ { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./validator", - "loc": "47:16-38" + "loc": "29:18-40" } ], "usedExports": true, @@ -3345,15 +3252,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Reach = require('@hapi/hoek/lib/reach');\n\nvar Common = require('./common');\n\nvar Errors = require('./errors');\n\nvar internals = {\n result: Symbol('result')\n};\n\nexports.entry = function (value, schema, prefs) {\n var settings = Common.defaults;\n\n if (prefs) {\n Assert(prefs.warnings === undefined, 'Cannot override warnings preference in synchronous validation');\n settings = Common.preferences(Common.defaults, prefs);\n }\n\n var result = internals.entry(value, schema, settings);\n Assert(!result.mainstay.externals.length, 'Schema with external rules must use validateAsync()');\n var outcome = {\n value: result.value\n };\n\n if (result.error) {\n outcome.error = result.error;\n }\n\n if (result.mainstay.warnings.length) {\n outcome.warning = Errors.details(result.mainstay.warnings);\n }\n\n return outcome;\n};\n\nexports.entryAsync =\n/*#__PURE__*/\nfunction () {\n var _ref = _asyncToGenerator(\n /*#__PURE__*/\n regeneratorRuntime.mark(function _callee(value, schema, prefs) {\n var settings, result, mainstay, root, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step$value, method, path, label, node, key, parent, output, outcome;\n\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n settings = Common.defaults;\n\n if (prefs) {\n settings = Common.preferences(Common.defaults, prefs);\n }\n\n result = internals.entry(value, schema, settings);\n\n if (!result.error) {\n _context.next = 5;\n break;\n }\n\n throw result.error;\n\n case 5:\n mainstay = result.mainstay;\n\n if (!mainstay.externals.length) {\n _context.next = 50;\n break;\n }\n\n root = result.value;\n _iteratorNormalCompletion = true;\n _didIteratorError = false;\n _iteratorError = undefined;\n _context.prev = 11;\n _iterator = mainstay.externals[Symbol.iterator]();\n\n case 13:\n if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {\n _context.next = 35;\n break;\n }\n\n _step$value = _step.value, method = _step$value.method, path = _step$value.path, label = _step$value.label;\n node = root;\n key = void 0;\n parent = void 0;\n\n if (path.length) {\n key = path[path.length - 1];\n parent = Reach(root, path.slice(0, -1));\n node = parent[key];\n }\n\n _context.prev = 19;\n _context.next = 22;\n return method(node);\n\n case 22:\n output = _context.sent;\n\n if (!(output === undefined || output === node)) {\n _context.next = 25;\n break;\n }\n\n return _context.abrupt(\"continue\", 32);\n\n case 25:\n if (parent) {\n parent[key] = output;\n } else {\n root = output;\n }\n\n _context.next = 32;\n break;\n\n case 28:\n _context.prev = 28;\n _context.t0 = _context[\"catch\"](19);\n _context.t0.message += \" (\".concat(label, \")\"); // Change message to include path\n\n throw _context.t0;\n\n case 32:\n _iteratorNormalCompletion = true;\n _context.next = 13;\n break;\n\n case 35:\n _context.next = 41;\n break;\n\n case 37:\n _context.prev = 37;\n _context.t1 = _context[\"catch\"](11);\n _didIteratorError = true;\n _iteratorError = _context.t1;\n\n case 41:\n _context.prev = 41;\n _context.prev = 42;\n\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n\n case 44:\n _context.prev = 44;\n\n if (!_didIteratorError) {\n _context.next = 47;\n break;\n }\n\n throw _iteratorError;\n\n case 47:\n return _context.finish(44);\n\n case 48:\n return _context.finish(41);\n\n case 49:\n result.value = root;\n\n case 50:\n if (settings.warnings) {\n _context.next = 52;\n break;\n }\n\n return _context.abrupt(\"return\", result.value);\n\n case 52:\n outcome = {\n value: result.value\n };\n\n if (mainstay.warnings.length) {\n outcome.warning = Errors.details(mainstay.warnings);\n }\n\n return _context.abrupt(\"return\", outcome);\n\n case 55:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, null, [[11, 37, 41, 49], [19, 28], [42,, 44, 48]]);\n }));\n\n return function (_x, _x2, _x3) {\n return _ref.apply(this, arguments);\n };\n}();\n\ninternals.entry = function (value, schema, prefs) {\n var mainstay = {\n externals: [],\n warnings: []\n };\n var state = new Common.State([], [], {\n mainstay: mainstay,\n schemas: schema._ids._schemaChain && [schema]\n });\n var result = exports.validate(value, schema, state, prefs);\n var error = Errors.process(result.errors, value, prefs);\n return {\n value: result.value,\n error: error,\n mainstay: mainstay\n };\n};\n\nexports.validate = function (value, schema, state, prefs) {\n // Setup state and settings\n if (schema._preferences) {\n prefs = internals.prefs(schema, prefs);\n }\n\n var original = value; // Cache\n\n if (schema._cache && prefs.cache) {\n var result = schema._cache.get(original);\n\n if (result) {\n return result;\n }\n } // Helpers\n\n\n var helpers = {\n prefs: prefs,\n schema: schema,\n state: state,\n error: function error(code, local, localState) {\n return schema.$_createError(code, value, local, localState || state, prefs);\n }\n }; // Type coercion\n\n var def = schema._definition;\n\n if (def.coerce && value !== undefined && prefs.convert && (!def.coerce.from || def.coerce.from.includes(_typeof(value)))) {\n var coerced = def.coerce.method(schema, value, helpers);\n\n if (coerced) {\n if (coerced.errors) {\n return internals.finalize(coerced.value, original, [].concat(coerced.errors), helpers); // Coerced error always aborts early\n }\n\n value = coerced.value;\n }\n } // Empty value\n\n\n if (schema._flags.empty && schema._flags.empty.$_match(internals.trim(value, schema), state.entry(schema._flags.empty), Common.defaults)) {\n value = undefined;\n } // Presence requirements (required, optional, forbidden)\n\n\n var presence = schema._flags.presence || (schema._flags._endedSwitch ? 'ignore' : prefs.presence);\n\n if (value === undefined) {\n if (presence === 'forbidden') {\n return internals.finalize(value, original, null, helpers);\n }\n\n if (presence === 'required') {\n return internals.finalize(value, original, [schema.$_createError('any.required', value, null, state, prefs)], helpers);\n }\n\n if (presence === 'optional') {\n if (schema._flags.default !== Common.symbols.deepDefault) {\n return internals.finalize(value, original, null, helpers);\n }\n\n value = {};\n }\n } else if (presence === 'forbidden') {\n return internals.finalize(value, original, [schema.$_createError('any.unknown', value, null, state, prefs)], helpers);\n } // Allowed values\n\n\n var errors = [];\n\n if (schema._valids) {\n var match = schema._valids.get(value, state, prefs, schema._flags.insensitive);\n\n if (match) {\n if (prefs.convert) {\n value = match.value;\n }\n\n return internals.finalize(value, original, null, helpers);\n }\n\n if (schema._flags.only) {\n var report = schema.$_createError('any.only', value, {\n valids: schema._valids.values({\n stripUndefined: true\n })\n }, state, prefs);\n\n if (prefs.abortEarly) {\n return internals.finalize(value, original, [report], helpers);\n }\n\n errors.push(report);\n }\n } // Denied values\n\n\n if (schema._invalids) {\n if (schema._invalids.has(value, state, prefs, schema._flags.insensitive)) {\n var _report = schema.$_createError('any.invalid', value, {\n invalids: schema._invalids.values({\n stripUndefined: true\n })\n }, state, prefs);\n\n if (prefs.abortEarly) {\n return internals.finalize(value, original, [_report], helpers);\n }\n\n errors.push(_report);\n }\n } // Base type\n\n\n if (def.validate) {\n var base = def.validate(schema, value, helpers);\n\n if (base) {\n value = base.value;\n\n if (base.errors) {\n if (!Array.isArray(base.errors)) {\n errors.push(base.errors);\n return internals.finalize(value, original, errors, helpers); // Base error always aborts early\n }\n\n if (base.errors.length) {\n errors.push.apply(errors, _toConsumableArray(base.errors));\n return internals.finalize(value, original, errors, helpers); // Base error always aborts early\n }\n }\n }\n } // Validate tests\n\n\n if (!schema._rules.length) {\n return internals.finalize(value, original, errors, helpers);\n }\n\n return internals.rules(value, errors, original, helpers);\n};\n\ninternals.rules = function (value, errors, original, helpers) {\n var schema = helpers.schema,\n state = helpers.state,\n prefs = helpers.prefs;\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = schema._rules[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var rule = _step2.value;\n var definition = schema._definition.rules[rule.method]; // Skip rules that are also applied in coerce step\n\n if (definition.convert && prefs.convert) {\n continue;\n } // Resolve references\n\n\n var ret = void 0;\n var args = rule.args;\n\n if (rule.resolve.length) {\n args = Object.assign({}, args); // Shallow copy\n\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = rule.resolve[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var key = _step3.value;\n var resolver = definition.argsByName.get(key);\n var resolved = args[key].resolve(value, state, prefs);\n var normalized = resolver.normalize ? resolver.normalize(resolved) : resolved;\n var invalid = Common.validateArg(normalized, resolver);\n\n if (invalid) {\n ret = schema.$_createError('any.ref', resolved, {\n arg: key,\n ref: args[key],\n reason: invalid\n }, state, prefs);\n break;\n }\n\n args[key] = normalized;\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n } // Test rule\n\n\n ret = ret || definition.validate(value, helpers, args, rule.options); // Use ret if already set to reference error\n\n var result = internals.rule(ret, rule);\n\n if (result.errors) {\n if (rule.warn) {\n var _state$mainstay$warni;\n\n (_state$mainstay$warni = state.mainstay.warnings).push.apply(_state$mainstay$warni, _toConsumableArray(result.errors));\n\n continue;\n }\n\n if (prefs.abortEarly) {\n return internals.finalize(value, original, result.errors, helpers);\n }\n\n errors.push.apply(errors, _toConsumableArray(result.errors));\n } else {\n value = result.value;\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return internals.finalize(value, original, errors, helpers);\n};\n\ninternals.rule = function (ret, rule) {\n if (ret instanceof Errors.Report) {\n internals.error(ret, rule);\n return {\n errors: [ret]\n };\n }\n\n if (Array.isArray(ret) && ret[0] instanceof Errors.Report) {\n ret.forEach(function (report) {\n return internals.error(report, rule);\n });\n return {\n errors: ret\n };\n }\n\n return {\n value: ret\n };\n};\n\ninternals.error = function (report, _ref2) {\n var message = _ref2.message;\n\n if (message) {\n report._setTemplate(message);\n }\n\n return report;\n};\n\ninternals.finalize = function (value, original, errors, helpers) {\n errors = errors || [];\n var schema = helpers.schema,\n state = helpers.state,\n prefs = helpers.prefs; // Failover value\n\n if (errors.length) {\n var failover = internals.default('failover', undefined, errors, helpers);\n\n if (failover !== undefined) {\n value = failover;\n errors = [];\n }\n } // Error override\n\n\n if (errors.length && schema._flags.error) {\n if (typeof schema._flags.error === 'function') {\n errors = schema._flags.error(errors);\n\n if (!Array.isArray(errors)) {\n errors = [errors];\n }\n } else {\n errors = [schema._flags.error];\n }\n } // Default\n\n\n if (value === undefined) {\n value = internals.default('default', value, errors, helpers);\n } // Cast\n\n\n if (schema._flags.cast && value !== undefined) {\n var caster = schema._definition.cast[schema._flags.cast];\n\n if (caster.from(value)) {\n value = caster.to(value, helpers);\n }\n } // Externals\n\n\n if (schema.$_terms.externals && prefs.externals && prefs._externals !== false) {\n // Disabled for matching\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = schema.$_terms.externals[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var method = _step4.value;\n state.mainstay.externals.push({\n method: method,\n path: state.path,\n label: Errors.label(schema._flags, state, prefs)\n });\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n } // Result\n\n\n var result = {\n value: value,\n errors: errors.length ? errors : null\n };\n\n if (schema._flags.result) {\n result.value = schema._flags.result === 'strip' ? undefined :\n /* raw */\n original;\n state.mainstay.shadow = state.mainstay.shadow || new internals.Shadow();\n state.mainstay.shadow.set(state.path, value);\n } // Cache\n\n\n if (schema._cache && prefs.cache !== false && !schema._refs.length) {\n schema._cache.set(original, result);\n }\n\n return result;\n};\n\ninternals.prefs = function (schema, prefs) {\n var isDefaultOptions = prefs === Common.defaults;\n\n if (isDefaultOptions && schema._preferences[Common.symbols.prefs]) {\n return schema._preferences[Common.symbols.prefs];\n }\n\n prefs = Common.preferences(prefs, schema._preferences);\n\n if (isDefaultOptions) {\n schema._preferences[Common.symbols.prefs] = prefs;\n }\n\n return prefs;\n};\n\ninternals.default = function (flag, value, errors, _ref3) {\n var schema = _ref3.schema,\n state = _ref3.state,\n prefs = _ref3.prefs;\n var source = schema._flags[flag];\n\n if (prefs.noDefaults || source === undefined) {\n return value;\n }\n\n if (!source) {\n return source;\n }\n\n if (typeof source === 'function') {\n var args = source.length > 0 ? [Clone(state.ancestors[0]), prefs] : [];\n\n try {\n return source.apply(void 0, args);\n } catch (err) {\n errors.push(schema.$_createError(\"any.\".concat(flag), null, {\n error: err\n }, state, prefs));\n return;\n }\n }\n\n if (_typeof(source) !== 'object') {\n return source;\n }\n\n if (source[Common.symbols.literal]) {\n return source.literal;\n }\n\n if (Common.isResolvable(source)) {\n return source.resolve(value, state, prefs);\n }\n\n return Clone(source);\n};\n\ninternals.trim = function (value, schema) {\n if (typeof value !== 'string') {\n return value;\n }\n\n var trim = schema.$_getRule('trim');\n\n if (!trim || !trim.args.enabled) {\n return value;\n }\n\n return value.trim();\n};\n\ninternals.Shadow =\n/*#__PURE__*/\nfunction () {\n function _class() {\n _classCallCheck(this, _class);\n\n this._value = null;\n }\n\n _createClass(_class, [{\n key: \"set\",\n value: function set(path, value) {\n if (!path.length) {\n // No need to store root value\n return;\n }\n\n this._value = this._value || new Map();\n var node = this._value;\n\n for (var i = 0; i < path.length - 1; ++i) {\n var segment = path[i];\n var next = node.get(segment);\n\n if (!next) {\n next = new Map();\n node.set(segment, next);\n }\n\n node = next;\n }\n\n node.set(path[path.length - 1], value);\n }\n }, {\n key: \"get\",\n value: function get(path) {\n return Reach(this._value, path, {\n iterables: true\n });\n }\n }]);\n\n return _class;\n}();" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Reach = require('@hapi/hoek/lib/reach');\n\nconst Common = require('./common');\n\nconst Errors = require('./errors');\n\nconst internals = {\n result: Symbol('result')\n};\n\nexports.entry = function (value, schema, prefs) {\n let settings = Common.defaults;\n\n if (prefs) {\n Assert(prefs.warnings === undefined, 'Cannot override warnings preference in synchronous validation');\n settings = Common.preferences(Common.defaults, prefs);\n }\n\n const result = internals.entry(value, schema, settings);\n Assert(!result.mainstay.externals.length, 'Schema with external rules must use validateAsync()');\n const outcome = {\n value: result.value\n };\n\n if (result.error) {\n outcome.error = result.error;\n }\n\n if (result.mainstay.warnings.length) {\n outcome.warning = Errors.details(result.mainstay.warnings);\n }\n\n return outcome;\n};\n\nexports.entryAsync = async function (value, schema, prefs) {\n let settings = Common.defaults;\n\n if (prefs) {\n settings = Common.preferences(Common.defaults, prefs);\n }\n\n const result = internals.entry(value, schema, settings);\n\n if (result.error) {\n throw result.error;\n }\n\n const mainstay = result.mainstay;\n\n if (mainstay.externals.length) {\n let root = result.value;\n\n for (const _ref of mainstay.externals) {\n const {\n method,\n path,\n label\n } = _ref;\n let node = root;\n let key;\n let parent;\n\n if (path.length) {\n key = path[path.length - 1];\n parent = Reach(root, path.slice(0, -1));\n node = parent[key];\n }\n\n try {\n const output = await method(node);\n\n if (output === undefined || output === node) {\n continue;\n }\n\n if (parent) {\n parent[key] = output;\n } else {\n root = output;\n }\n } catch (err) {\n err.message += \" (\".concat(label, \")\"); // Change message to include path\n\n throw err;\n }\n }\n\n result.value = root;\n }\n\n if (!settings.warnings) {\n return result.value;\n }\n\n const outcome = {\n value: result.value\n };\n\n if (mainstay.warnings.length) {\n outcome.warning = Errors.details(mainstay.warnings);\n }\n\n return outcome;\n};\n\ninternals.entry = function (value, schema, prefs) {\n const mainstay = {\n externals: [],\n warnings: []\n };\n const state = new Common.State([], [], {\n mainstay,\n schemas: schema._ids._schemaChain && [schema]\n });\n const result = exports.validate(value, schema, state, prefs);\n const error = Errors.process(result.errors, value, prefs);\n return {\n value: result.value,\n error,\n mainstay\n };\n};\n\nexports.validate = function (value, schema, state, prefs) {\n // Setup state and settings\n if (schema._preferences) {\n prefs = internals.prefs(schema, prefs);\n }\n\n const original = value; // Cache\n\n if (schema._cache && prefs.cache) {\n const result = schema._cache.get(original);\n\n if (result) {\n return result;\n }\n } // Helpers\n\n\n const helpers = {\n prefs,\n schema,\n state,\n error: (code, local, localState) => schema.$_createError(code, value, local, localState || state, prefs)\n }; // Type coercion\n\n const def = schema._definition;\n\n if (def.coerce && value !== undefined && prefs.convert && (!def.coerce.from || def.coerce.from.includes(typeof value))) {\n const coerced = def.coerce.method(schema, value, helpers);\n\n if (coerced) {\n if (coerced.errors) {\n return internals.finalize(coerced.value, original, [].concat(coerced.errors), helpers); // Coerced error always aborts early\n }\n\n value = coerced.value;\n }\n } // Empty value\n\n\n if (schema._flags.empty && schema._flags.empty.$_match(internals.trim(value, schema), state.entry(schema._flags.empty), Common.defaults)) {\n value = undefined;\n } // Presence requirements (required, optional, forbidden)\n\n\n const presence = schema._flags.presence || (schema._flags._endedSwitch ? 'ignore' : prefs.presence);\n\n if (value === undefined) {\n if (presence === 'forbidden') {\n return internals.finalize(value, original, null, helpers);\n }\n\n if (presence === 'required') {\n return internals.finalize(value, original, [schema.$_createError('any.required', value, null, state, prefs)], helpers);\n }\n\n if (presence === 'optional') {\n if (schema._flags.default !== Common.symbols.deepDefault) {\n return internals.finalize(value, original, null, helpers);\n }\n\n value = {};\n }\n } else if (presence === 'forbidden') {\n return internals.finalize(value, original, [schema.$_createError('any.unknown', value, null, state, prefs)], helpers);\n } // Allowed values\n\n\n const errors = [];\n\n if (schema._valids) {\n const match = schema._valids.get(value, state, prefs, schema._flags.insensitive);\n\n if (match) {\n if (prefs.convert) {\n value = match.value;\n }\n\n return internals.finalize(value, original, null, helpers);\n }\n\n if (schema._flags.only) {\n const report = schema.$_createError('any.only', value, {\n valids: schema._valids.values({\n stripUndefined: true\n })\n }, state, prefs);\n\n if (prefs.abortEarly) {\n return internals.finalize(value, original, [report], helpers);\n }\n\n errors.push(report);\n }\n } // Denied values\n\n\n if (schema._invalids) {\n if (schema._invalids.has(value, state, prefs, schema._flags.insensitive)) {\n const report = schema.$_createError('any.invalid', value, {\n invalids: schema._invalids.values({\n stripUndefined: true\n })\n }, state, prefs);\n\n if (prefs.abortEarly) {\n return internals.finalize(value, original, [report], helpers);\n }\n\n errors.push(report);\n }\n } // Base type\n\n\n if (def.validate) {\n const base = def.validate(schema, value, helpers);\n\n if (base) {\n value = base.value;\n\n if (base.errors) {\n if (!Array.isArray(base.errors)) {\n errors.push(base.errors);\n return internals.finalize(value, original, errors, helpers); // Base error always aborts early\n }\n\n if (base.errors.length) {\n errors.push(...base.errors);\n return internals.finalize(value, original, errors, helpers); // Base error always aborts early\n }\n }\n }\n } // Validate tests\n\n\n if (!schema._rules.length) {\n return internals.finalize(value, original, errors, helpers);\n }\n\n return internals.rules(value, errors, original, helpers);\n};\n\ninternals.rules = function (value, errors, original, helpers) {\n const {\n schema,\n state,\n prefs\n } = helpers;\n\n for (const rule of schema._rules) {\n const definition = schema._definition.rules[rule.method]; // Skip rules that are also applied in coerce step\n\n if (definition.convert && prefs.convert) {\n continue;\n } // Resolve references\n\n\n let ret;\n let args = rule.args;\n\n if (rule.resolve.length) {\n args = Object.assign({}, args); // Shallow copy\n\n for (const key of rule.resolve) {\n const resolver = definition.argsByName.get(key);\n const resolved = args[key].resolve(value, state, prefs);\n const normalized = resolver.normalize ? resolver.normalize(resolved) : resolved;\n const invalid = Common.validateArg(normalized, resolver);\n\n if (invalid) {\n ret = schema.$_createError('any.ref', resolved, {\n arg: key,\n ref: args[key],\n reason: invalid\n }, state, prefs);\n break;\n }\n\n args[key] = normalized;\n }\n } // Test rule\n\n\n ret = ret || definition.validate(value, helpers, args, rule.options); // Use ret if already set to reference error\n\n const result = internals.rule(ret, rule);\n\n if (result.errors) {\n if (rule.warn) {\n state.mainstay.warnings.push(...result.errors);\n continue;\n }\n\n if (prefs.abortEarly) {\n return internals.finalize(value, original, result.errors, helpers);\n }\n\n errors.push(...result.errors);\n } else {\n value = result.value;\n }\n }\n\n return internals.finalize(value, original, errors, helpers);\n};\n\ninternals.rule = function (ret, rule) {\n if (ret instanceof Errors.Report) {\n internals.error(ret, rule);\n return {\n errors: [ret]\n };\n }\n\n if (Array.isArray(ret) && ret[0] instanceof Errors.Report) {\n ret.forEach(report => internals.error(report, rule));\n return {\n errors: ret\n };\n }\n\n return {\n value: ret\n };\n};\n\ninternals.error = function (report, _ref2) {\n let {\n message\n } = _ref2;\n\n if (message) {\n report._setTemplate(message);\n }\n\n return report;\n};\n\ninternals.finalize = function (value, original, errors, helpers) {\n errors = errors || [];\n const {\n schema,\n state,\n prefs\n } = helpers; // Failover value\n\n if (errors.length) {\n const failover = internals.default('failover', undefined, errors, helpers);\n\n if (failover !== undefined) {\n value = failover;\n errors = [];\n }\n } // Error override\n\n\n if (errors.length && schema._flags.error) {\n if (typeof schema._flags.error === 'function') {\n errors = schema._flags.error(errors);\n\n if (!Array.isArray(errors)) {\n errors = [errors];\n }\n } else {\n errors = [schema._flags.error];\n }\n } // Default\n\n\n if (value === undefined) {\n value = internals.default('default', value, errors, helpers);\n } // Cast\n\n\n if (schema._flags.cast && value !== undefined) {\n const caster = schema._definition.cast[schema._flags.cast];\n\n if (caster.from(value)) {\n value = caster.to(value, helpers);\n }\n } // Externals\n\n\n if (schema.$_terms.externals && prefs.externals && prefs._externals !== false) {\n // Disabled for matching\n for (const method of schema.$_terms.externals) {\n state.mainstay.externals.push({\n method,\n path: state.path,\n label: Errors.label(schema._flags, state, prefs)\n });\n }\n } // Result\n\n\n const result = {\n value,\n errors: errors.length ? errors : null\n };\n\n if (schema._flags.result) {\n result.value = schema._flags.result === 'strip' ? undefined :\n /* raw */\n original;\n state.mainstay.shadow = state.mainstay.shadow || new internals.Shadow();\n state.mainstay.shadow.set(state.path, value);\n } // Cache\n\n\n if (schema._cache && prefs.cache !== false && !schema._refs.length) {\n schema._cache.set(original, result);\n }\n\n return result;\n};\n\ninternals.prefs = function (schema, prefs) {\n const isDefaultOptions = prefs === Common.defaults;\n\n if (isDefaultOptions && schema._preferences[Common.symbols.prefs]) {\n return schema._preferences[Common.symbols.prefs];\n }\n\n prefs = Common.preferences(prefs, schema._preferences);\n\n if (isDefaultOptions) {\n schema._preferences[Common.symbols.prefs] = prefs;\n }\n\n return prefs;\n};\n\ninternals.default = function (flag, value, errors, _ref3) {\n let {\n schema,\n state,\n prefs\n } = _ref3;\n const source = schema._flags[flag];\n\n if (prefs.noDefaults || source === undefined) {\n return value;\n }\n\n if (!source) {\n return source;\n }\n\n if (typeof source === 'function') {\n const args = source.length > 0 ? [Clone(state.ancestors[0]), prefs] : [];\n\n try {\n return source(...args);\n } catch (err) {\n errors.push(schema.$_createError(\"any.\".concat(flag), null, {\n error: err\n }, state, prefs));\n return;\n }\n }\n\n if (typeof source !== 'object') {\n return source;\n }\n\n if (source[Common.symbols.literal]) {\n return source.literal;\n }\n\n if (Common.isResolvable(source)) {\n return source.resolve(value, state, prefs);\n }\n\n return Clone(source);\n};\n\ninternals.trim = function (value, schema) {\n if (typeof value !== 'string') {\n return value;\n }\n\n const trim = schema.$_getRule('trim');\n\n if (!trim || !trim.args.enabled) {\n return value;\n }\n\n return value.trim();\n};\n\ninternals.Shadow = class {\n constructor() {\n this._value = null;\n }\n\n set(path, value) {\n if (!path.length) {\n // No need to store root value\n return;\n }\n\n this._value = this._value || new Map();\n let node = this._value;\n\n for (let i = 0; i < path.length - 1; ++i) {\n const segment = path[i];\n let next = node.get(segment);\n\n if (!next) {\n next = new Map();\n node.set(segment, next);\n }\n\n node = next;\n }\n\n node.set(path[path.length - 1], value);\n }\n\n get(path) {\n return Reach(this._value, path, {\n iterables: true\n });\n }\n\n};" }, { - "id": 35, + "id": 34, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "name": "../lib/types/array.js", "index": 30, "index2": 30, - "size": 31315, + "size": 24061, "cacheable": true, "built": true, "optional": false, @@ -3370,15 +3277,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -3392,7 +3299,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/array", - "loc": "40:11-35" + "loc": "26:11-35" } ], "usedExports": true, @@ -3401,15 +3308,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Bourne = require('@hapi/bourne');\n\nvar DeepEqual = require('@hapi/hoek/lib/deepEqual');\n\nvar Reach = require('@hapi/hoek/lib/reach');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar Compile = require('../compile');\n\nvar internals = {};\nmodule.exports = Any.extend({\n type: 'array',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.items = [];\n schema.$_terms.ordered = [];\n schema.$_terms._inclusions = [];\n schema.$_terms._exclusions = [];\n schema.$_terms._requireds = [];\n },\n // Coerce\n coerce: {\n method: function method(schema, value, _ref) {\n var state = _ref.state,\n prefs = _ref.prefs;\n var result = {\n value: value\n };\n\n if (typeof value === 'string') {\n if (value[0] !== '[' && !/^\\s*\\[/.test(value)) {\n return;\n }\n\n try {\n result.value = Bourne.parse(value);\n } catch (ignoreErr) {\n return;\n }\n }\n\n if (!Array.isArray(result.value)) {\n return;\n }\n\n var sort = schema.$_getRule('sort');\n\n if (sort) {\n return internals.sort(schema, result.value, sort.args.options, state, prefs);\n }\n\n return result;\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n var error = _ref2.error;\n\n if (!Array.isArray(value)) {\n if (schema._flags.single) {\n var single = [value];\n single[Common.symbols.arraySingle] = true;\n return {\n value: single\n };\n }\n\n return {\n errors: error('array.base')\n };\n }\n\n if (!schema.$_getRule('items') && !schema.$_terms.externals) {\n return;\n }\n\n return {\n value: value.slice()\n }; // Clone the array so that we don't modify the original\n },\n // Rules\n rules: {\n has: {\n method: function method(schema) {\n schema = this.$_compile(schema, {\n appendPath: true\n });\n var obj = this.$_addRule({\n name: 'has',\n args: {\n schema: schema\n }\n });\n obj.$_mutateRegister(schema);\n return obj;\n },\n validate: function validate(value, _ref3, _ref4) {\n var state = _ref3.state,\n prefs = _ref3.prefs,\n error = _ref3.error,\n schema = _ref3.schema;\n var has = _ref4.schema;\n var ancestors = [value].concat(_toConsumableArray(state.ancestors));\n\n for (var i = 0; i < value.length; ++i) {\n var localState = state.localize([].concat(_toConsumableArray(state.path), [i]), ancestors, has);\n\n if (has.$_match(value[i], localState, prefs)) {\n return value;\n }\n }\n\n var patternLabel = has._flags.label;\n\n if (patternLabel) {\n return error('array.hasKnown', {\n patternLabel: patternLabel\n });\n }\n\n return error('array.hasUnknown', null);\n },\n multi: true\n },\n items: {\n method: function method() {\n var _this = this;\n\n for (var _len = arguments.length, schemas = new Array(_len), _key = 0; _key < _len; _key++) {\n schemas[_key] = arguments[_key];\n }\n\n Common.verifyFlat(schemas, 'items');\n var obj = this.$_addRule('items');\n\n var _loop = function _loop(i) {\n var type = Common.tryWithPath(function () {\n return _this.$_compile(schemas[i]);\n }, i, {\n append: true\n });\n obj.$_terms.items.push(type);\n };\n\n for (var i = 0; i < schemas.length; ++i) {\n _loop(i);\n }\n\n return obj.$_mutateRebuild();\n },\n validate: function validate(value, _ref5) {\n var schema = _ref5.schema,\n error = _ref5.error,\n state = _ref5.state,\n prefs = _ref5.prefs;\n\n var requireds = schema.$_terms._requireds.slice();\n\n var ordereds = schema.$_terms.ordered.slice();\n var inclusions = [].concat(_toConsumableArray(schema.$_terms._inclusions), _toConsumableArray(requireds));\n var wasArray = !value[Common.symbols.arraySingle];\n var errors = [];\n var il = value.length;\n\n for (var i = 0; i < il; ++i) {\n var item = value[i];\n var errored = false;\n var isValid = false;\n var key = wasArray ? i : new Number(i); // eslint-disable-line no-new-wrappers\n\n var path = [].concat(_toConsumableArray(state.path), [key]); // Sparse\n\n if (!schema._flags.sparse && item === undefined) {\n errors.push(error('array.sparse', {\n key: key,\n path: path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n ordereds.shift();\n continue;\n } // Exclusions\n\n\n var ancestors = [value].concat(_toConsumableArray(state.ancestors));\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = schema.$_terms._exclusions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var exclusion = _step.value;\n\n if (!exclusion.$_match(item, state.localize(path, ancestors, exclusion), prefs)) {\n continue;\n }\n\n errors.push(error('array.excludes', {\n pos: i,\n value: item\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n errored = true;\n ordereds.shift();\n break;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n if (errored) {\n continue;\n } // Ordered\n\n\n if (schema.$_terms.ordered.length) {\n if (ordereds.length) {\n var ordered = ordereds.shift();\n var res = ordered.$_validate(item, state.localize(path, ancestors, ordered), prefs);\n\n if (!res.errors) {\n if (ordered._flags.result === 'strip') {\n internals.fastSplice(value, i);\n --i;\n --il;\n } else if (!schema._flags.sparse && res.value === undefined) {\n errors.push(error('array.sparse', {\n key: key,\n path: path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n continue;\n } else {\n value[i] = res.value;\n }\n } else {\n errors.push.apply(errors, _toConsumableArray(res.errors));\n\n if (prefs.abortEarly) {\n return errors;\n }\n }\n\n continue;\n } else if (!schema.$_terms.items.length) {\n errors.push(error('array.orderedLength', {\n pos: i,\n limit: schema.$_terms.ordered.length\n }));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n break; // No reason to continue since there are no other rules to validate other than array.orderedLength\n }\n } // Requireds\n\n\n var requiredChecks = [];\n var jl = requireds.length;\n\n for (var j = 0; j < jl; ++j) {\n var _res = requireds[j].$_validate(item, state.localize(path, ancestors, requireds[j]), prefs);\n\n requiredChecks[j] = _res;\n\n if (!_res.errors) {\n value[i] = _res.value;\n isValid = true;\n internals.fastSplice(requireds, j);\n --j;\n --jl;\n\n if (!schema._flags.sparse && _res.value === undefined) {\n errors.push(error('array.sparse', {\n key: key,\n path: path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n }\n\n break;\n }\n }\n\n if (isValid) {\n continue;\n } // Inclusions\n\n\n var stripUnknown = prefs.stripUnknown && !!prefs.stripUnknown.arrays || false;\n jl = inclusions.length;\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = inclusions[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var inclusion = _step2.value;\n\n // Avoid re-running requireds that already didn't match in the previous loop\n var _res2 = void 0;\n\n var previousCheck = requireds.indexOf(inclusion);\n\n if (previousCheck !== -1) {\n _res2 = requiredChecks[previousCheck];\n } else {\n _res2 = inclusion.$_validate(item, state.localize(path, ancestors, inclusion), prefs);\n\n if (!_res2.errors) {\n if (inclusion._flags.result === 'strip') {\n internals.fastSplice(value, i);\n --i;\n --il;\n } else if (!schema._flags.sparse && _res2.value === undefined) {\n errors.push(error('array.sparse', {\n key: key,\n path: path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n errored = true;\n } else {\n value[i] = _res2.value;\n }\n\n isValid = true;\n break;\n }\n } // Return the actual error if only one inclusion defined\n\n\n if (jl === 1) {\n if (stripUnknown) {\n internals.fastSplice(value, i);\n --i;\n --il;\n isValid = true;\n break;\n }\n\n errors.push.apply(errors, _toConsumableArray(_res2.errors));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n errored = true;\n break;\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (errored) {\n continue;\n }\n\n if (schema.$_terms._inclusions.length && !isValid) {\n if (stripUnknown) {\n internals.fastSplice(value, i);\n --i;\n --il;\n continue;\n }\n\n errors.push(error('array.includes', {\n pos: i,\n value: item\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n }\n }\n\n if (requireds.length) {\n internals.fillMissedErrors(schema, errors, requireds, value, state, prefs);\n }\n\n if (ordereds.length) {\n internals.fillOrderedErrors(schema, errors, ordereds, value, state, prefs);\n }\n\n return errors.length ? errors : value;\n },\n priority: true\n },\n length: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'length',\n args: {\n limit: limit\n },\n operator: '='\n });\n },\n validate: function validate(value, helpers, _ref6, _ref7) {\n var limit = _ref6.limit;\n var name = _ref7.name,\n operator = _ref7.operator,\n args = _ref7.args;\n\n if (Common.compare(value.length, limit, operator)) {\n return value;\n }\n\n return helpers.error('array.' + name, {\n limit: args.limit,\n value: value\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.limit,\n message: 'must be a positive integer'\n }]\n },\n max: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'max',\n method: 'length',\n args: {\n limit: limit\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'min',\n method: 'length',\n args: {\n limit: limit\n },\n operator: '>='\n });\n }\n },\n ordered: {\n method: function method() {\n var _this2 = this;\n\n for (var _len2 = arguments.length, schemas = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n schemas[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(schemas, 'ordered');\n var obj = this.$_addRule('items');\n\n var _loop2 = function _loop2(i) {\n var type = Common.tryWithPath(function () {\n return _this2.$_compile(schemas[i]);\n }, i, {\n append: true\n });\n internals.validateSingle(type, obj);\n obj.$_mutateRegister(type);\n obj.$_terms.ordered.push(type);\n };\n\n for (var i = 0; i < schemas.length; ++i) {\n _loop2(i);\n }\n\n return obj.$_mutateRebuild();\n }\n },\n single: {\n method: function method(enabled) {\n var value = enabled === undefined ? true : !!enabled;\n Assert(!value || !this._flags._arrayItems, 'Cannot specify single rule when array has array items');\n return this.$_setFlag('single', value);\n }\n },\n sort: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['by', 'order']);\n var settings = {\n order: options.order || 'ascending'\n };\n\n if (options.by) {\n settings.by = Compile.ref(options.by, {\n ancestor: 0\n });\n Assert(!settings.by.ancestor, 'Cannot sort by ancestor');\n }\n\n return this.$_addRule({\n name: 'sort',\n args: {\n options: settings\n }\n });\n },\n validate: function validate(value, _ref8, _ref9) {\n var error = _ref8.error,\n state = _ref8.state,\n prefs = _ref8.prefs,\n schema = _ref8.schema;\n var options = _ref9.options;\n\n var _internals$sort = internals.sort(schema, value, options, state, prefs),\n sorted = _internals$sort.value,\n errors = _internals$sort.errors;\n\n if (errors) {\n return errors;\n }\n\n for (var i = 0; i < value.length; ++i) {\n if (value[i] !== sorted[i]) {\n return error('array.sort', {\n order: options.order,\n by: options.by ? options.by.key : 'value'\n });\n }\n }\n\n return value;\n },\n convert: true\n },\n sparse: {\n method: function method(enabled) {\n var value = enabled === undefined ? true : !!enabled;\n\n if (this._flags.sparse === value) {\n return this;\n }\n\n var obj = value ? this.clone() : this.$_addRule('items');\n return obj.$_setFlag('sparse', value, {\n clone: false\n });\n }\n },\n unique: {\n method: function method(comparator) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(!comparator || typeof comparator === 'function' || typeof comparator === 'string', 'comparator must be a function or a string');\n Common.assertOptions(options, ['ignoreUndefined', 'separator']);\n var rule = {\n name: 'unique',\n args: {\n options: options,\n comparator: comparator\n }\n };\n\n if (comparator) {\n if (typeof comparator === 'string') {\n var separator = Common.default(options.separator, '.');\n rule.path = separator ? comparator.split(separator) : [comparator];\n } else {\n rule.comparator = comparator;\n }\n }\n\n return this.$_addRule(rule);\n },\n validate: function validate(value, _ref10, _ref11, _ref12) {\n var state = _ref10.state,\n error = _ref10.error,\n schema = _ref10.schema;\n var raw = _ref11.comparator,\n options = _ref11.options;\n var comparator = _ref12.comparator,\n path = _ref12.path;\n var found = {\n string: Object.create(null),\n number: Object.create(null),\n undefined: Object.create(null),\n boolean: Object.create(null),\n object: new Map(),\n function: new Map(),\n custom: new Map()\n };\n var compare = comparator || DeepEqual;\n var ignoreUndefined = options.ignoreUndefined;\n\n for (var i = 0; i < value.length; ++i) {\n var item = path ? Reach(value[i], path) : value[i];\n var records = comparator ? found.custom : found[_typeof(item)];\n Assert(records, 'Failed to find unique map container for type', _typeof(item));\n\n if (records instanceof Map) {\n var entries = records.entries();\n var current = void 0;\n\n while (!(current = entries.next()).done) {\n if (compare(current.value[0], item)) {\n var localState = state.localize([].concat(_toConsumableArray(state.path), [i]), [value].concat(_toConsumableArray(state.ancestors)));\n var context = {\n pos: i,\n value: value[i],\n dupePos: current.value[1],\n dupeValue: value[current.value[1]]\n };\n\n if (path) {\n context.path = raw;\n }\n\n return error('array.unique', context, localState);\n }\n }\n\n records.set(item, i);\n } else {\n if ((!ignoreUndefined || item !== undefined) && records[item] !== undefined) {\n var _context = {\n pos: i,\n value: value[i],\n dupePos: records[item],\n dupeValue: value[records[item]]\n };\n\n if (path) {\n _context.path = raw;\n }\n\n var _localState = state.localize([].concat(_toConsumableArray(state.path), [i]), [value].concat(_toConsumableArray(state.ancestors)));\n\n return error('array.unique', _context, _localState);\n }\n\n records[item] = i;\n }\n }\n\n return value;\n },\n args: ['comparator', 'options'],\n multi: true\n }\n },\n // Cast\n cast: {\n set: {\n from: Array.isArray,\n to: function to(value, helpers) {\n return new Set(value);\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n if (desc.items) {\n var _obj;\n\n obj = (_obj = obj).items.apply(_obj, _toConsumableArray(desc.items));\n }\n\n if (desc.ordered) {\n var _obj2;\n\n obj = (_obj2 = obj).ordered.apply(_obj2, _toConsumableArray(desc.ordered));\n }\n\n return obj;\n },\n // Modify\n modify: function modify(schema, id, replacement) {\n for (var _i = 0, _arr = ['items', 'ordered']; _i < _arr.length; _i++) {\n var set = _arr[_i];\n\n for (var i = 0; i < schema.$_terms[set].length; ++i) {\n var existing = schema.$_terms[set][i];\n\n if (id === existing._flags.id) {\n var obj = schema.clone();\n obj.$_terms[set][i] = replacement;\n return obj.$_mutateRebuild();\n }\n }\n }\n\n var hases = schema.$_getRules('has');\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = hases[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var has = _step3.value;\n\n if (id === has.args.schema._flags.id) {\n var _obj3 = schema.clone();\n\n has.args.schema = replacement;\n return _obj3.$_mutateRebuild();\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n },\n rebuild: function rebuild(schema) {\n schema.$_terms._inclusions = [];\n schema.$_terms._exclusions = [];\n schema.$_terms._requireds = [];\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = schema.$_terms.items[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var type = _step4.value;\n internals.validateSingle(type, schema);\n schema.$_mutateRegister(type);\n\n if (type._flags.presence === 'required') {\n schema.$_terms._requireds.push(type);\n } else if (type._flags.presence === 'forbidden') {\n schema.$_terms._exclusions.push(type.optional());\n } else {\n schema.$_terms._inclusions.push(type);\n }\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = schema.$_terms.ordered[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var _type = _step5.value;\n internals.validateSingle(_type, schema);\n schema.$_mutateRegister(_type);\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n\n var hases = schema.$_getRules('has');\n var _iteratorNormalCompletion6 = true;\n var _didIteratorError6 = false;\n var _iteratorError6 = undefined;\n\n try {\n for (var _iterator6 = hases[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {\n var has = _step6.value;\n schema.$_mutateRegister(has.args.schema);\n }\n } catch (err) {\n _didIteratorError6 = true;\n _iteratorError6 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion6 && _iterator6.return != null) {\n _iterator6.return();\n }\n } finally {\n if (_didIteratorError6) {\n throw _iteratorError6;\n }\n }\n }\n\n return schema;\n },\n // Errors\n messages: {\n 'array.base': '\"{{#label}}\" must be an array',\n 'array.excludes': '\"{{#label}}\" contains an excluded value',\n 'array.hasKnown': '\"{{#label}}\" does not contain at least one required match for type \"{#patternLabel}\"',\n 'array.hasUnknown': '\"{{#label}}\" does not contain at least one required match',\n 'array.includes': '\"{{#label}}\" does not match any of the allowed types',\n 'array.includesRequiredBoth': '\"{{#label}}\" does not contain {{#knownMisses}} and {{#unknownMisses}} other required value(s)',\n 'array.includesRequiredKnowns': '\"{{#label}}\" does not contain {{#knownMisses}}',\n 'array.includesRequiredUnknowns': '\"{{#label}}\" does not contain {{#unknownMisses}} required value(s)',\n 'array.length': '\"{{#label}}\" must contain {{#limit}} items',\n 'array.max': '\"{{#label}}\" must contain less than or equal to {{#limit}} items',\n 'array.min': '\"{{#label}}\" must contain at least {{#limit}} items',\n 'array.orderedLength': '\"{{#label}}\" must contain at most {{#limit}} items',\n 'array.sort': '\"{{#label}}\" must be sorted in {#order} order by {{#by}}',\n 'array.sort.mismatching': '\"{{#label}}\" cannot be sorted due to mismatching types',\n 'array.sort.unsupported': '\"{{#label}}\" cannot be sorted due to unsupported type {#type}',\n 'array.sparse': '\"{{#label}}\" must not be a sparse array item',\n 'array.unique': '\"{{#label}}\" contains a duplicate value'\n }\n}); // Helpers\n\ninternals.fillMissedErrors = function (schema, errors, requireds, value, state, prefs) {\n var knownMisses = [];\n var unknownMisses = 0;\n var _iteratorNormalCompletion7 = true;\n var _didIteratorError7 = false;\n var _iteratorError7 = undefined;\n\n try {\n for (var _iterator7 = requireds[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {\n var required = _step7.value;\n var label = required._flags.label;\n\n if (label) {\n knownMisses.push(label);\n } else {\n ++unknownMisses;\n }\n }\n } catch (err) {\n _didIteratorError7 = true;\n _iteratorError7 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion7 && _iterator7.return != null) {\n _iterator7.return();\n }\n } finally {\n if (_didIteratorError7) {\n throw _iteratorError7;\n }\n }\n }\n\n if (knownMisses.length) {\n if (unknownMisses) {\n errors.push(schema.$_createError('array.includesRequiredBoth', value, {\n knownMisses: knownMisses,\n unknownMisses: unknownMisses\n }, state, prefs));\n } else {\n errors.push(schema.$_createError('array.includesRequiredKnowns', value, {\n knownMisses: knownMisses\n }, state, prefs));\n }\n } else {\n errors.push(schema.$_createError('array.includesRequiredUnknowns', value, {\n unknownMisses: unknownMisses\n }, state, prefs));\n }\n};\n\ninternals.fillOrderedErrors = function (schema, errors, ordereds, value, state, prefs) {\n var requiredOrdereds = [];\n var _iteratorNormalCompletion8 = true;\n var _didIteratorError8 = false;\n var _iteratorError8 = undefined;\n\n try {\n for (var _iterator8 = ordereds[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {\n var ordered = _step8.value;\n\n if (ordered._flags.presence === 'required') {\n requiredOrdereds.push(ordered);\n }\n }\n } catch (err) {\n _didIteratorError8 = true;\n _iteratorError8 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion8 && _iterator8.return != null) {\n _iterator8.return();\n }\n } finally {\n if (_didIteratorError8) {\n throw _iteratorError8;\n }\n }\n }\n\n if (requiredOrdereds.length) {\n internals.fillMissedErrors(schema, errors, requiredOrdereds, value, state, prefs);\n }\n};\n\ninternals.fastSplice = function (arr, i) {\n var pos = i;\n\n while (pos < arr.length) {\n arr[pos++] = arr[pos];\n }\n\n --arr.length;\n};\n\ninternals.validateSingle = function (type, obj) {\n if (type.type === 'array' || type._flags._arrayItems) {\n Assert(!obj._flags.single, 'Cannot specify array item with single rule enabled');\n obj.$_setFlag('_arrayItems', true, {\n clone: false\n });\n }\n};\n\ninternals.sort = function (schema, value, settings, state, prefs) {\n var order = settings.order === 'ascending' ? 1 : -1;\n var aFirst = -1 * order;\n var bFirst = order;\n\n var sort = function sort(a, b) {\n var compare = internals.compare(a, b, aFirst, bFirst);\n\n if (compare !== null) {\n return compare;\n }\n\n if (settings.by) {\n a = settings.by.resolve(a, state, prefs);\n b = settings.by.resolve(b, state, prefs);\n }\n\n compare = internals.compare(a, b, aFirst, bFirst);\n\n if (compare !== null) {\n return compare;\n }\n\n var type = _typeof(a);\n\n if (type !== _typeof(b)) {\n throw schema.$_createError('array.sort.mismatching', value, null, state, prefs);\n }\n\n if (type !== 'number' && type !== 'string') {\n throw schema.$_createError('array.sort.unsupported', value, {\n type: type\n }, state, prefs);\n }\n\n if (type === 'number') {\n return (a - b) * order;\n }\n\n return a < b ? aFirst : bFirst;\n };\n\n try {\n return {\n value: value.slice().sort(sort)\n };\n } catch (err) {\n return {\n errors: err\n };\n }\n};\n\ninternals.compare = function (a, b, aFirst, bFirst) {\n if (a === b) {\n return 0;\n }\n\n if (a === undefined) {\n return 1; // Always last regardless of sort order\n }\n\n if (b === undefined) {\n return -1; // Always last regardless of sort order\n }\n\n if (a === null) {\n return bFirst;\n }\n\n if (b === null) {\n return aFirst;\n }\n\n return null;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Bourne = require('@hapi/bourne');\n\nconst DeepEqual = require('@hapi/hoek/lib/deepEqual');\n\nconst Reach = require('@hapi/hoek/lib/reach');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst Compile = require('../compile');\n\nconst internals = {};\nmodule.exports = Any.extend({\n type: 'array',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.items = [];\n schema.$_terms.ordered = [];\n schema.$_terms._inclusions = [];\n schema.$_terms._exclusions = [];\n schema.$_terms._requireds = [];\n },\n // Coerce\n coerce: {\n method: function method(schema, value, _ref) {\n let {\n state,\n prefs\n } = _ref;\n const result = {\n value\n };\n\n if (typeof value === 'string') {\n if (value[0] !== '[' && !/^\\s*\\[/.test(value)) {\n return;\n }\n\n try {\n result.value = Bourne.parse(value);\n } catch (ignoreErr) {\n return;\n }\n }\n\n if (!Array.isArray(result.value)) {\n return;\n }\n\n const sort = schema.$_getRule('sort');\n\n if (sort) {\n return internals.sort(schema, result.value, sort.args.options, state, prefs);\n }\n\n return result;\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n let {\n error\n } = _ref2;\n\n if (!Array.isArray(value)) {\n if (schema._flags.single) {\n const single = [value];\n single[Common.symbols.arraySingle] = true;\n return {\n value: single\n };\n }\n\n return {\n errors: error('array.base')\n };\n }\n\n if (!schema.$_getRule('items') && !schema.$_terms.externals) {\n return;\n }\n\n return {\n value: value.slice()\n }; // Clone the array so that we don't modify the original\n },\n // Rules\n rules: {\n has: {\n method: function method(schema) {\n schema = this.$_compile(schema, {\n appendPath: true\n });\n const obj = this.$_addRule({\n name: 'has',\n args: {\n schema\n }\n });\n obj.$_mutateRegister(schema);\n return obj;\n },\n validate: function validate(value, _ref3, _ref4) {\n let {\n state,\n prefs,\n error,\n schema\n } = _ref3;\n let {\n schema: has\n } = _ref4;\n const ancestors = [value, ...state.ancestors];\n\n for (let i = 0; i < value.length; ++i) {\n const localState = state.localize([...state.path, i], ancestors, has);\n\n if (has.$_match(value[i], localState, prefs)) {\n return value;\n }\n }\n\n const patternLabel = has._flags.label;\n\n if (patternLabel) {\n return error('array.hasKnown', {\n patternLabel\n });\n }\n\n return error('array.hasUnknown', null);\n },\n multi: true\n },\n items: {\n method: function method() {\n for (var _len = arguments.length, schemas = new Array(_len), _key = 0; _key < _len; _key++) {\n schemas[_key] = arguments[_key];\n }\n\n Common.verifyFlat(schemas, 'items');\n const obj = this.$_addRule('items');\n\n for (let i = 0; i < schemas.length; ++i) {\n const type = Common.tryWithPath(() => this.$_compile(schemas[i]), i, {\n append: true\n });\n obj.$_terms.items.push(type);\n }\n\n return obj.$_mutateRebuild();\n },\n validate: function validate(value, _ref5) {\n let {\n schema,\n error,\n state,\n prefs\n } = _ref5;\n\n const requireds = schema.$_terms._requireds.slice();\n\n const ordereds = schema.$_terms.ordered.slice();\n const inclusions = [...schema.$_terms._inclusions, ...requireds];\n const wasArray = !value[Common.symbols.arraySingle];\n const errors = [];\n let il = value.length;\n\n for (let i = 0; i < il; ++i) {\n const item = value[i];\n let errored = false;\n let isValid = false;\n const key = wasArray ? i : new Number(i); // eslint-disable-line no-new-wrappers\n\n const path = [...state.path, key]; // Sparse\n\n if (!schema._flags.sparse && item === undefined) {\n errors.push(error('array.sparse', {\n key,\n path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n ordereds.shift();\n continue;\n } // Exclusions\n\n\n const ancestors = [value, ...state.ancestors];\n\n for (const exclusion of schema.$_terms._exclusions) {\n if (!exclusion.$_match(item, state.localize(path, ancestors, exclusion), prefs)) {\n continue;\n }\n\n errors.push(error('array.excludes', {\n pos: i,\n value: item\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n errored = true;\n ordereds.shift();\n break;\n }\n\n if (errored) {\n continue;\n } // Ordered\n\n\n if (schema.$_terms.ordered.length) {\n if (ordereds.length) {\n const ordered = ordereds.shift();\n const res = ordered.$_validate(item, state.localize(path, ancestors, ordered), prefs);\n\n if (!res.errors) {\n if (ordered._flags.result === 'strip') {\n internals.fastSplice(value, i);\n --i;\n --il;\n } else if (!schema._flags.sparse && res.value === undefined) {\n errors.push(error('array.sparse', {\n key,\n path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n continue;\n } else {\n value[i] = res.value;\n }\n } else {\n errors.push(...res.errors);\n\n if (prefs.abortEarly) {\n return errors;\n }\n }\n\n continue;\n } else if (!schema.$_terms.items.length) {\n errors.push(error('array.orderedLength', {\n pos: i,\n limit: schema.$_terms.ordered.length\n }));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n break; // No reason to continue since there are no other rules to validate other than array.orderedLength\n }\n } // Requireds\n\n\n const requiredChecks = [];\n let jl = requireds.length;\n\n for (let j = 0; j < jl; ++j) {\n const res = requireds[j].$_validate(item, state.localize(path, ancestors, requireds[j]), prefs);\n requiredChecks[j] = res;\n\n if (!res.errors) {\n value[i] = res.value;\n isValid = true;\n internals.fastSplice(requireds, j);\n --j;\n --jl;\n\n if (!schema._flags.sparse && res.value === undefined) {\n errors.push(error('array.sparse', {\n key,\n path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n }\n\n break;\n }\n }\n\n if (isValid) {\n continue;\n } // Inclusions\n\n\n const stripUnknown = prefs.stripUnknown && !!prefs.stripUnknown.arrays || false;\n jl = inclusions.length;\n\n for (const inclusion of inclusions) {\n // Avoid re-running requireds that already didn't match in the previous loop\n let res;\n const previousCheck = requireds.indexOf(inclusion);\n\n if (previousCheck !== -1) {\n res = requiredChecks[previousCheck];\n } else {\n res = inclusion.$_validate(item, state.localize(path, ancestors, inclusion), prefs);\n\n if (!res.errors) {\n if (inclusion._flags.result === 'strip') {\n internals.fastSplice(value, i);\n --i;\n --il;\n } else if (!schema._flags.sparse && res.value === undefined) {\n errors.push(error('array.sparse', {\n key,\n path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n errored = true;\n } else {\n value[i] = res.value;\n }\n\n isValid = true;\n break;\n }\n } // Return the actual error if only one inclusion defined\n\n\n if (jl === 1) {\n if (stripUnknown) {\n internals.fastSplice(value, i);\n --i;\n --il;\n isValid = true;\n break;\n }\n\n errors.push(...res.errors);\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n errored = true;\n break;\n }\n }\n\n if (errored) {\n continue;\n }\n\n if (schema.$_terms._inclusions.length && !isValid) {\n if (stripUnknown) {\n internals.fastSplice(value, i);\n --i;\n --il;\n continue;\n }\n\n errors.push(error('array.includes', {\n pos: i,\n value: item\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n }\n }\n\n if (requireds.length) {\n internals.fillMissedErrors(schema, errors, requireds, value, state, prefs);\n }\n\n if (ordereds.length) {\n internals.fillOrderedErrors(schema, errors, ordereds, value, state, prefs);\n }\n\n return errors.length ? errors : value;\n },\n priority: true\n },\n length: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'length',\n args: {\n limit\n },\n operator: '='\n });\n },\n validate: function validate(value, helpers, _ref6, _ref7) {\n let {\n limit\n } = _ref6;\n let {\n name,\n operator,\n args\n } = _ref7;\n\n if (Common.compare(value.length, limit, operator)) {\n return value;\n }\n\n return helpers.error('array.' + name, {\n limit: args.limit,\n value\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.limit,\n message: 'must be a positive integer'\n }]\n },\n max: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'max',\n method: 'length',\n args: {\n limit\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'min',\n method: 'length',\n args: {\n limit\n },\n operator: '>='\n });\n }\n },\n ordered: {\n method: function method() {\n for (var _len2 = arguments.length, schemas = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n schemas[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(schemas, 'ordered');\n const obj = this.$_addRule('items');\n\n for (let i = 0; i < schemas.length; ++i) {\n const type = Common.tryWithPath(() => this.$_compile(schemas[i]), i, {\n append: true\n });\n internals.validateSingle(type, obj);\n obj.$_mutateRegister(type);\n obj.$_terms.ordered.push(type);\n }\n\n return obj.$_mutateRebuild();\n }\n },\n single: {\n method: function method(enabled) {\n const value = enabled === undefined ? true : !!enabled;\n Assert(!value || !this._flags._arrayItems, 'Cannot specify single rule when array has array items');\n return this.$_setFlag('single', value);\n }\n },\n sort: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['by', 'order']);\n const settings = {\n order: options.order || 'ascending'\n };\n\n if (options.by) {\n settings.by = Compile.ref(options.by, {\n ancestor: 0\n });\n Assert(!settings.by.ancestor, 'Cannot sort by ancestor');\n }\n\n return this.$_addRule({\n name: 'sort',\n args: {\n options: settings\n }\n });\n },\n validate: function validate(value, _ref8, _ref9) {\n let {\n error,\n state,\n prefs,\n schema\n } = _ref8;\n let {\n options\n } = _ref9;\n const {\n value: sorted,\n errors\n } = internals.sort(schema, value, options, state, prefs);\n\n if (errors) {\n return errors;\n }\n\n for (let i = 0; i < value.length; ++i) {\n if (value[i] !== sorted[i]) {\n return error('array.sort', {\n order: options.order,\n by: options.by ? options.by.key : 'value'\n });\n }\n }\n\n return value;\n },\n convert: true\n },\n sparse: {\n method: function method(enabled) {\n const value = enabled === undefined ? true : !!enabled;\n\n if (this._flags.sparse === value) {\n return this;\n }\n\n const obj = value ? this.clone() : this.$_addRule('items');\n return obj.$_setFlag('sparse', value, {\n clone: false\n });\n }\n },\n unique: {\n method: function method(comparator) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(!comparator || typeof comparator === 'function' || typeof comparator === 'string', 'comparator must be a function or a string');\n Common.assertOptions(options, ['ignoreUndefined', 'separator']);\n const rule = {\n name: 'unique',\n args: {\n options,\n comparator\n }\n };\n\n if (comparator) {\n if (typeof comparator === 'string') {\n const separator = Common.default(options.separator, '.');\n rule.path = separator ? comparator.split(separator) : [comparator];\n } else {\n rule.comparator = comparator;\n }\n }\n\n return this.$_addRule(rule);\n },\n validate: function validate(value, _ref10, _ref11, _ref12) {\n let {\n state,\n error,\n schema\n } = _ref10;\n let {\n comparator: raw,\n options\n } = _ref11;\n let {\n comparator,\n path\n } = _ref12;\n const found = {\n string: Object.create(null),\n number: Object.create(null),\n undefined: Object.create(null),\n boolean: Object.create(null),\n object: new Map(),\n function: new Map(),\n custom: new Map()\n };\n const compare = comparator || DeepEqual;\n const ignoreUndefined = options.ignoreUndefined;\n\n for (let i = 0; i < value.length; ++i) {\n const item = path ? Reach(value[i], path) : value[i];\n const records = comparator ? found.custom : found[typeof item];\n Assert(records, 'Failed to find unique map container for type', typeof item);\n\n if (records instanceof Map) {\n const entries = records.entries();\n let current;\n\n while (!(current = entries.next()).done) {\n if (compare(current.value[0], item)) {\n const localState = state.localize([...state.path, i], [value, ...state.ancestors]);\n const context = {\n pos: i,\n value: value[i],\n dupePos: current.value[1],\n dupeValue: value[current.value[1]]\n };\n\n if (path) {\n context.path = raw;\n }\n\n return error('array.unique', context, localState);\n }\n }\n\n records.set(item, i);\n } else {\n if ((!ignoreUndefined || item !== undefined) && records[item] !== undefined) {\n const context = {\n pos: i,\n value: value[i],\n dupePos: records[item],\n dupeValue: value[records[item]]\n };\n\n if (path) {\n context.path = raw;\n }\n\n const localState = state.localize([...state.path, i], [value, ...state.ancestors]);\n return error('array.unique', context, localState);\n }\n\n records[item] = i;\n }\n }\n\n return value;\n },\n args: ['comparator', 'options'],\n multi: true\n }\n },\n // Cast\n cast: {\n set: {\n from: Array.isArray,\n to: function to(value, helpers) {\n return new Set(value);\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n if (desc.items) {\n obj = obj.items(...desc.items);\n }\n\n if (desc.ordered) {\n obj = obj.ordered(...desc.ordered);\n }\n\n return obj;\n },\n // Modify\n modify: function modify(schema, id, replacement) {\n for (const set of ['items', 'ordered']) {\n for (let i = 0; i < schema.$_terms[set].length; ++i) {\n const existing = schema.$_terms[set][i];\n\n if (id === existing._flags.id) {\n const obj = schema.clone();\n obj.$_terms[set][i] = replacement;\n return obj.$_mutateRebuild();\n }\n }\n }\n\n const hases = schema.$_getRules('has');\n\n for (const has of hases) {\n if (id === has.args.schema._flags.id) {\n const obj = schema.clone();\n has.args.schema = replacement;\n return obj.$_mutateRebuild();\n }\n }\n },\n rebuild: function rebuild(schema) {\n schema.$_terms._inclusions = [];\n schema.$_terms._exclusions = [];\n schema.$_terms._requireds = [];\n\n for (const type of schema.$_terms.items) {\n internals.validateSingle(type, schema);\n schema.$_mutateRegister(type);\n\n if (type._flags.presence === 'required') {\n schema.$_terms._requireds.push(type);\n } else if (type._flags.presence === 'forbidden') {\n schema.$_terms._exclusions.push(type.optional());\n } else {\n schema.$_terms._inclusions.push(type);\n }\n }\n\n for (const type of schema.$_terms.ordered) {\n internals.validateSingle(type, schema);\n schema.$_mutateRegister(type);\n }\n\n const hases = schema.$_getRules('has');\n\n for (const has of hases) {\n schema.$_mutateRegister(has.args.schema);\n }\n\n return schema;\n },\n // Errors\n messages: {\n 'array.base': '\"{{#label}}\" must be an array',\n 'array.excludes': '\"{{#label}}\" contains an excluded value',\n 'array.hasKnown': '\"{{#label}}\" does not contain at least one required match for type \"{#patternLabel}\"',\n 'array.hasUnknown': '\"{{#label}}\" does not contain at least one required match',\n 'array.includes': '\"{{#label}}\" does not match any of the allowed types',\n 'array.includesRequiredBoth': '\"{{#label}}\" does not contain {{#knownMisses}} and {{#unknownMisses}} other required value(s)',\n 'array.includesRequiredKnowns': '\"{{#label}}\" does not contain {{#knownMisses}}',\n 'array.includesRequiredUnknowns': '\"{{#label}}\" does not contain {{#unknownMisses}} required value(s)',\n 'array.length': '\"{{#label}}\" must contain {{#limit}} items',\n 'array.max': '\"{{#label}}\" must contain less than or equal to {{#limit}} items',\n 'array.min': '\"{{#label}}\" must contain at least {{#limit}} items',\n 'array.orderedLength': '\"{{#label}}\" must contain at most {{#limit}} items',\n 'array.sort': '\"{{#label}}\" must be sorted in {#order} order by {{#by}}',\n 'array.sort.mismatching': '\"{{#label}}\" cannot be sorted due to mismatching types',\n 'array.sort.unsupported': '\"{{#label}}\" cannot be sorted due to unsupported type {#type}',\n 'array.sparse': '\"{{#label}}\" must not be a sparse array item',\n 'array.unique': '\"{{#label}}\" contains a duplicate value'\n }\n}); // Helpers\n\ninternals.fillMissedErrors = function (schema, errors, requireds, value, state, prefs) {\n const knownMisses = [];\n let unknownMisses = 0;\n\n for (const required of requireds) {\n const label = required._flags.label;\n\n if (label) {\n knownMisses.push(label);\n } else {\n ++unknownMisses;\n }\n }\n\n if (knownMisses.length) {\n if (unknownMisses) {\n errors.push(schema.$_createError('array.includesRequiredBoth', value, {\n knownMisses,\n unknownMisses\n }, state, prefs));\n } else {\n errors.push(schema.$_createError('array.includesRequiredKnowns', value, {\n knownMisses\n }, state, prefs));\n }\n } else {\n errors.push(schema.$_createError('array.includesRequiredUnknowns', value, {\n unknownMisses\n }, state, prefs));\n }\n};\n\ninternals.fillOrderedErrors = function (schema, errors, ordereds, value, state, prefs) {\n const requiredOrdereds = [];\n\n for (const ordered of ordereds) {\n if (ordered._flags.presence === 'required') {\n requiredOrdereds.push(ordered);\n }\n }\n\n if (requiredOrdereds.length) {\n internals.fillMissedErrors(schema, errors, requiredOrdereds, value, state, prefs);\n }\n};\n\ninternals.fastSplice = function (arr, i) {\n let pos = i;\n\n while (pos < arr.length) {\n arr[pos++] = arr[pos];\n }\n\n --arr.length;\n};\n\ninternals.validateSingle = function (type, obj) {\n if (type.type === 'array' || type._flags._arrayItems) {\n Assert(!obj._flags.single, 'Cannot specify array item with single rule enabled');\n obj.$_setFlag('_arrayItems', true, {\n clone: false\n });\n }\n};\n\ninternals.sort = function (schema, value, settings, state, prefs) {\n const order = settings.order === 'ascending' ? 1 : -1;\n const aFirst = -1 * order;\n const bFirst = order;\n\n const sort = (a, b) => {\n let compare = internals.compare(a, b, aFirst, bFirst);\n\n if (compare !== null) {\n return compare;\n }\n\n if (settings.by) {\n a = settings.by.resolve(a, state, prefs);\n b = settings.by.resolve(b, state, prefs);\n }\n\n compare = internals.compare(a, b, aFirst, bFirst);\n\n if (compare !== null) {\n return compare;\n }\n\n const type = typeof a;\n\n if (type !== typeof b) {\n throw schema.$_createError('array.sort.mismatching', value, null, state, prefs);\n }\n\n if (type !== 'number' && type !== 'string') {\n throw schema.$_createError('array.sort.unsupported', value, {\n type\n }, state, prefs);\n }\n\n if (type === 'number') {\n return (a - b) * order;\n }\n\n return a < b ? aFirst : bFirst;\n };\n\n try {\n return {\n value: value.slice().sort(sort)\n };\n } catch (err) {\n return {\n errors: err\n };\n }\n};\n\ninternals.compare = function (a, b, aFirst, bFirst) {\n if (a === b) {\n return 0;\n }\n\n if (a === undefined) {\n return 1; // Always last regardless of sort order\n }\n\n if (b === undefined) {\n return -1; // Always last regardless of sort order\n }\n\n if (a === null) {\n return bFirst;\n }\n\n if (b === null) {\n return aFirst;\n }\n\n return null;\n};" }, { - "id": 36, + "id": 35, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", "name": "../lib/types/boolean.js", "index": 32, "index2": 31, - "size": 3813, + "size": 3156, "cacheable": true, "built": true, "optional": false, @@ -3426,15 +3333,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -3448,7 +3355,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/boolean", - "loc": "41:13-39" + "loc": "27:13-39" } ], "usedExports": true, @@ -3457,15 +3364,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar Values = require('../values');\n\nvar internals = {};\n\ninternals.isBool = function (value) {\n return typeof value === 'boolean';\n};\n\nmodule.exports = Any.extend({\n type: 'boolean',\n // Initialize\n initialize: function initialize(schema) {\n schema._flags.insensitive = true;\n schema.$_terms.truthy = new Values();\n schema.$_terms.falsy = new Values();\n },\n // Coerce\n coerce: function coerce(schema, value, helpers) {\n if (typeof value === 'boolean') {\n return;\n }\n\n if (typeof value === 'string') {\n var normalized = schema._flags.insensitive ? value.toLowerCase() : value;\n value = normalized === 'true' ? true : normalized === 'false' ? false : value;\n }\n\n if (typeof value !== 'boolean') {\n value = schema.$_terms.truthy.has(value, null, null, schema._flags.insensitive) || (schema.$_terms.falsy.has(value, null, null, schema._flags.insensitive) ? false : value);\n }\n\n return {\n value: value\n };\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n var error = _ref.error;\n\n if (typeof value !== 'boolean') {\n return {\n value: value,\n errors: error('boolean.base')\n };\n }\n },\n // Rules\n rules: {\n truthy: {\n method: function method() {\n for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {\n values[_key] = arguments[_key];\n }\n\n Common.verifyFlat(values, 'truthy');\n var obj = this.clone();\n\n for (var i = 0; i < values.length; ++i) {\n var value = values[i];\n Assert(value !== undefined, 'Cannot call truthy with undefined');\n obj.$_terms.truthy.add(value);\n }\n\n return obj;\n }\n },\n falsy: {\n method: function method() {\n for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n values[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(values, 'falsy');\n var obj = this.clone();\n\n for (var i = 0; i < values.length; ++i) {\n var value = values[i];\n Assert(value !== undefined, 'Cannot call falsy with undefined');\n obj.$_terms.falsy.add(value);\n }\n\n return obj;\n }\n },\n insensitive: {\n method: function method(enabled) {\n return this.$_setFlag('insensitive', enabled !== false);\n }\n }\n },\n // Cast\n cast: {\n number: {\n from: internals.isBool,\n to: function to(value, helpers) {\n return value ? 1 : 0;\n }\n },\n string: {\n from: internals.isBool,\n to: function to(value, helpers) {\n return value ? 'true' : 'false';\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n if (desc.truthy) {\n var _obj;\n\n obj = (_obj = obj).truthy.apply(_obj, _toConsumableArray(desc.truthy));\n }\n\n if (desc.falsy) {\n var _obj2;\n\n obj = (_obj2 = obj).falsy.apply(_obj2, _toConsumableArray(desc.falsy));\n }\n\n return obj;\n },\n // Errors\n messages: {\n 'boolean.base': '\"{{#label}}\" must be a boolean'\n }\n});" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst Values = require('../values');\n\nconst internals = {};\n\ninternals.isBool = function (value) {\n return typeof value === 'boolean';\n};\n\nmodule.exports = Any.extend({\n type: 'boolean',\n // Initialize\n initialize: function initialize(schema) {\n schema._flags.insensitive = true;\n schema.$_terms.truthy = new Values();\n schema.$_terms.falsy = new Values();\n },\n // Coerce\n coerce: function coerce(schema, value, helpers) {\n if (typeof value === 'boolean') {\n return;\n }\n\n if (typeof value === 'string') {\n const normalized = schema._flags.insensitive ? value.toLowerCase() : value;\n value = normalized === 'true' ? true : normalized === 'false' ? false : value;\n }\n\n if (typeof value !== 'boolean') {\n value = schema.$_terms.truthy.has(value, null, null, schema._flags.insensitive) || (schema.$_terms.falsy.has(value, null, null, schema._flags.insensitive) ? false : value);\n }\n\n return {\n value\n };\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n let {\n error\n } = _ref;\n\n if (typeof value !== 'boolean') {\n return {\n value,\n errors: error('boolean.base')\n };\n }\n },\n // Rules\n rules: {\n truthy: {\n method: function method() {\n for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {\n values[_key] = arguments[_key];\n }\n\n Common.verifyFlat(values, 'truthy');\n const obj = this.clone();\n\n for (let i = 0; i < values.length; ++i) {\n const value = values[i];\n Assert(value !== undefined, 'Cannot call truthy with undefined');\n obj.$_terms.truthy.add(value);\n }\n\n return obj;\n }\n },\n falsy: {\n method: function method() {\n for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n values[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(values, 'falsy');\n const obj = this.clone();\n\n for (let i = 0; i < values.length; ++i) {\n const value = values[i];\n Assert(value !== undefined, 'Cannot call falsy with undefined');\n obj.$_terms.falsy.add(value);\n }\n\n return obj;\n }\n },\n insensitive: {\n method: function method(enabled) {\n return this.$_setFlag('insensitive', enabled !== false);\n }\n }\n },\n // Cast\n cast: {\n number: {\n from: internals.isBool,\n to: function to(value, helpers) {\n return value ? 1 : 0;\n }\n },\n string: {\n from: internals.isBool,\n to: function to(value, helpers) {\n return value ? 'true' : 'false';\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n if (desc.truthy) {\n obj = obj.truthy(...desc.truthy);\n }\n\n if (desc.falsy) {\n obj = obj.falsy(...desc.falsy);\n }\n\n return obj;\n },\n // Errors\n messages: {\n 'boolean.base': '\"{{#label}}\" must be a boolean'\n }\n});" }, { - "id": 37, + "id": 36, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/date.js", "name": "../lib/types/date.js", "index": 33, "index2": 32, - "size": 5384, + "size": 5305, "cacheable": true, "built": true, "optional": false, @@ -3482,15 +3389,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -3504,7 +3411,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/date", - "loc": "42:10-33" + "loc": "28:10-33" } ], "usedExports": true, @@ -3513,15 +3420,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar Template = require('../template');\n\nvar internals = {};\n\ninternals.isDate = function (value) {\n return value instanceof Date;\n};\n\nmodule.exports = Any.extend({\n type: 'date',\n // Coerce\n coerce: {\n from: ['number', 'string'],\n method: function method(schema, value, helpers) {\n return {\n value: internals.parse(value, schema._flags.format) || value\n };\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n var error = _ref.error,\n prefs = _ref.prefs;\n\n if (value instanceof Date && !isNaN(value.getTime())) {\n return;\n }\n\n if (!prefs.convert) {\n return {\n value: value,\n errors: error('date.strict')\n };\n }\n\n var format = schema._flags.format;\n var code = !format ? 'date.base' : format === 'iso' ? 'date.isoDate' : \"date.timestamp.\".concat(format);\n return {\n value: value,\n errors: error(code)\n };\n },\n // Rules\n rules: {\n compare: {\n method: false,\n validate: function validate(value, helpers, _ref2, _ref3) {\n var date = _ref2.date;\n var name = _ref3.name,\n operator = _ref3.operator,\n args = _ref3.args;\n var to = date === 'now' ? Date.now() : date.getTime();\n\n if (Common.compare(value.getTime(), to, operator)) {\n return value;\n }\n\n return helpers.error('date.' + name, {\n limit: args.date,\n value: value\n });\n },\n args: [{\n name: 'date',\n ref: true,\n normalize: function normalize(date) {\n return date === 'now' ? date : internals.parse(date);\n },\n assert: function assert(date) {\n return date !== null;\n },\n message: 'must have a valid date format'\n }]\n },\n format: {\n method: function method(format) {\n Assert(['iso', 'javascript', 'unix'].includes(format), 'Unknown date format', format);\n return this.$_setFlag('format', format);\n }\n },\n greater: {\n method: function method(date) {\n return this.$_addRule({\n name: 'greater',\n method: 'compare',\n args: {\n date: date\n },\n operator: '>'\n });\n }\n },\n iso: {\n method: function method() {\n return this.format('iso');\n }\n },\n less: {\n method: function method(date) {\n return this.$_addRule({\n name: 'less',\n method: 'compare',\n args: {\n date: date\n },\n operator: '<'\n });\n }\n },\n max: {\n method: function method(date) {\n return this.$_addRule({\n name: 'max',\n method: 'compare',\n args: {\n date: date\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(date) {\n return this.$_addRule({\n name: 'min',\n method: 'compare',\n args: {\n date: date\n },\n operator: '>='\n });\n }\n },\n timestamp: {\n method: function method() {\n var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'javascript';\n Assert(['javascript', 'unix'].includes(type), '\"type\" must be one of \"javascript, unix\"');\n return this.format(type);\n }\n }\n },\n // Cast\n cast: {\n number: {\n from: internals.isDate,\n to: function to(value, helpers) {\n return value.getTime();\n }\n },\n string: {\n from: internals.isDate,\n to: function to(value, _ref4) {\n var prefs = _ref4.prefs;\n return Template.date(value, prefs);\n }\n }\n },\n // Errors\n messages: {\n 'date.base': '\"{{#label}}\" must be a number of milliseconds or valid date string',\n 'date.greater': '\"{{#label}}\" must be greater than \"{{#limit}}\"',\n 'date.isoDate': '\"{{#label}}\" must be a valid ISO 8601 date',\n 'date.less': '\"{{#label}}\" must be less than \"{{#limit}}\"',\n 'date.max': '\"{{#label}}\" must be less than or equal to \"{{#limit}}\"',\n 'date.min': '\"{{#label}}\" must be larger than or equal to \"{{#limit}}\"',\n 'date.strict': '\"{{#label}}\" must be a valid date',\n 'date.timestamp.javascript': '\"{{#label}}\" must be a valid timestamp or number of milliseconds',\n 'date.timestamp.unix': '\"{{#label}}\" must be a valid timestamp or number of seconds'\n }\n}); // Helpers\n\ninternals.parse = function (value, format) {\n if (value instanceof Date) {\n return value;\n }\n\n if (typeof value !== 'string' && (isNaN(value) || !isFinite(value))) {\n return null;\n } // ISO\n\n\n if (format === 'iso') {\n if (!Common.isIsoDate(value)) {\n return null;\n }\n\n return internals.date(value.toString());\n } // Normalize number string\n\n\n if (typeof value === 'string' && /^[+-]?\\d+(\\.\\d+)?$/.test(value)) {\n value = parseFloat(value);\n } // Timestamp\n\n\n if (format) {\n if (/^\\s*$/.test(value)) {\n return null;\n }\n\n return internals.date(value * (format === 'unix' ? 1000 : 1));\n } // Plain\n\n\n return internals.date(value);\n};\n\ninternals.date = function (value) {\n var date = new Date(value);\n\n if (!isNaN(date.getTime())) {\n return date;\n }\n\n return null;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst Template = require('../template');\n\nconst internals = {};\n\ninternals.isDate = function (value) {\n return value instanceof Date;\n};\n\nmodule.exports = Any.extend({\n type: 'date',\n // Coerce\n coerce: {\n from: ['number', 'string'],\n method: function method(schema, value, helpers) {\n return {\n value: internals.parse(value, schema._flags.format) || value\n };\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n let {\n error,\n prefs\n } = _ref;\n\n if (value instanceof Date && !isNaN(value.getTime())) {\n return;\n }\n\n if (!prefs.convert) {\n return {\n value,\n errors: error('date.strict')\n };\n }\n\n const format = schema._flags.format;\n const code = !format ? 'date.base' : format === 'iso' ? 'date.isoDate' : \"date.timestamp.\".concat(format);\n return {\n value,\n errors: error(code)\n };\n },\n // Rules\n rules: {\n compare: {\n method: false,\n validate: function validate(value, helpers, _ref2, _ref3) {\n let {\n date\n } = _ref2;\n let {\n name,\n operator,\n args\n } = _ref3;\n const to = date === 'now' ? Date.now() : date.getTime();\n\n if (Common.compare(value.getTime(), to, operator)) {\n return value;\n }\n\n return helpers.error('date.' + name, {\n limit: args.date,\n value\n });\n },\n args: [{\n name: 'date',\n ref: true,\n normalize: date => {\n return date === 'now' ? date : internals.parse(date);\n },\n assert: date => date !== null,\n message: 'must have a valid date format'\n }]\n },\n format: {\n method: function method(format) {\n Assert(['iso', 'javascript', 'unix'].includes(format), 'Unknown date format', format);\n return this.$_setFlag('format', format);\n }\n },\n greater: {\n method: function method(date) {\n return this.$_addRule({\n name: 'greater',\n method: 'compare',\n args: {\n date\n },\n operator: '>'\n });\n }\n },\n iso: {\n method: function method() {\n return this.format('iso');\n }\n },\n less: {\n method: function method(date) {\n return this.$_addRule({\n name: 'less',\n method: 'compare',\n args: {\n date\n },\n operator: '<'\n });\n }\n },\n max: {\n method: function method(date) {\n return this.$_addRule({\n name: 'max',\n method: 'compare',\n args: {\n date\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(date) {\n return this.$_addRule({\n name: 'min',\n method: 'compare',\n args: {\n date\n },\n operator: '>='\n });\n }\n },\n timestamp: {\n method: function method() {\n let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'javascript';\n Assert(['javascript', 'unix'].includes(type), '\"type\" must be one of \"javascript, unix\"');\n return this.format(type);\n }\n }\n },\n // Cast\n cast: {\n number: {\n from: internals.isDate,\n to: function to(value, helpers) {\n return value.getTime();\n }\n },\n string: {\n from: internals.isDate,\n to: function to(value, _ref4) {\n let {\n prefs\n } = _ref4;\n return Template.date(value, prefs);\n }\n }\n },\n // Errors\n messages: {\n 'date.base': '\"{{#label}}\" must be a number of milliseconds or valid date string',\n 'date.greater': '\"{{#label}}\" must be greater than \"{{#limit}}\"',\n 'date.isoDate': '\"{{#label}}\" must be a valid ISO 8601 date',\n 'date.less': '\"{{#label}}\" must be less than \"{{#limit}}\"',\n 'date.max': '\"{{#label}}\" must be less than or equal to \"{{#limit}}\"',\n 'date.min': '\"{{#label}}\" must be larger than or equal to \"{{#limit}}\"',\n 'date.strict': '\"{{#label}}\" must be a valid date',\n 'date.timestamp.javascript': '\"{{#label}}\" must be a valid timestamp or number of milliseconds',\n 'date.timestamp.unix': '\"{{#label}}\" must be a valid timestamp or number of seconds'\n }\n}); // Helpers\n\ninternals.parse = function (value, format) {\n if (value instanceof Date) {\n return value;\n }\n\n if (typeof value !== 'string' && (isNaN(value) || !isFinite(value))) {\n return null;\n } // ISO\n\n\n if (format === 'iso') {\n if (!Common.isIsoDate(value)) {\n return null;\n }\n\n return internals.date(value.toString());\n } // Normalize number string\n\n\n if (typeof value === 'string' && /^[+-]?\\d+(\\.\\d+)?$/.test(value)) {\n value = parseFloat(value);\n } // Timestamp\n\n\n if (format) {\n if (/^\\s*$/.test(value)) {\n return null;\n }\n\n return internals.date(value * (format === 'unix' ? 1000 : 1));\n } // Plain\n\n\n return internals.date(value);\n};\n\ninternals.date = function (value) {\n const date = new Date(value);\n\n if (!isNaN(date.getTime())) {\n return date;\n }\n\n return null;\n};" }, { - "id": 38, + "id": 37, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/function.js", "name": "../lib/types/function.js", "index": 34, "index2": 36, - "size": 2495, + "size": 2536, "cacheable": true, "built": true, "optional": false, @@ -3538,15 +3445,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -3560,7 +3467,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/function", - "loc": "43:14-41" + "loc": "29:14-41" } ], "usedExports": true, @@ -3569,15 +3476,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar ObjectType = require('./object');\n\nvar internals = {};\nmodule.exports = ObjectType.extend({\n type: 'function',\n properties: {\n typeof: 'function'\n },\n // Rules\n rules: {\n arity: {\n method: function method(n) {\n Assert(Number.isSafeInteger(n) && n >= 0, 'n must be a positive integer');\n return this.$_addRule({\n name: 'arity',\n args: {\n n: n\n }\n });\n },\n validate: function validate(value, helpers, _ref) {\n var n = _ref.n;\n\n if (value.length === n) {\n return value;\n }\n\n return helpers.error('function.arity', {\n n: n\n });\n }\n },\n class: {\n method: function method() {\n return this.$_addRule('class');\n },\n validate: function validate(value, helpers) {\n if (/^\\s*class\\s/.test(value.toString())) {\n return value;\n }\n\n return helpers.error('function.class', {\n value: value\n });\n }\n },\n minArity: {\n method: function method(n) {\n Assert(Number.isSafeInteger(n) && n > 0, 'n must be a strict positive integer');\n return this.$_addRule({\n name: 'minArity',\n args: {\n n: n\n }\n });\n },\n validate: function validate(value, helpers, _ref2) {\n var n = _ref2.n;\n\n if (value.length >= n) {\n return value;\n }\n\n return helpers.error('function.minArity', {\n n: n\n });\n }\n },\n maxArity: {\n method: function method(n) {\n Assert(Number.isSafeInteger(n) && n >= 0, 'n must be a positive integer');\n return this.$_addRule({\n name: 'maxArity',\n args: {\n n: n\n }\n });\n },\n validate: function validate(value, helpers, _ref3) {\n var n = _ref3.n;\n\n if (value.length <= n) {\n return value;\n }\n\n return helpers.error('function.maxArity', {\n n: n\n });\n }\n }\n },\n // Cast\n cast: {\n map: null // Disable object cast\n\n },\n // Errors\n messages: {\n 'function.arity': '\"{{#label}}\" must have an arity of {{#n}}',\n 'function.class': '\"{{#label}}\" must be a class',\n 'function.maxArity': '\"{{#label}}\" must have an arity lesser or equal to {{#n}}',\n 'function.minArity': '\"{{#label}}\" must have an arity greater or equal to {{#n}}'\n }\n});" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst ObjectType = require('./object');\n\nconst internals = {};\nmodule.exports = ObjectType.extend({\n type: 'function',\n properties: {\n typeof: 'function'\n },\n // Rules\n rules: {\n arity: {\n method: function method(n) {\n Assert(Number.isSafeInteger(n) && n >= 0, 'n must be a positive integer');\n return this.$_addRule({\n name: 'arity',\n args: {\n n\n }\n });\n },\n validate: function validate(value, helpers, _ref) {\n let {\n n\n } = _ref;\n\n if (value.length === n) {\n return value;\n }\n\n return helpers.error('function.arity', {\n n\n });\n }\n },\n class: {\n method: function method() {\n return this.$_addRule('class');\n },\n validate: function validate(value, helpers) {\n if (/^\\s*class\\s/.test(value.toString())) {\n return value;\n }\n\n return helpers.error('function.class', {\n value\n });\n }\n },\n minArity: {\n method: function method(n) {\n Assert(Number.isSafeInteger(n) && n > 0, 'n must be a strict positive integer');\n return this.$_addRule({\n name: 'minArity',\n args: {\n n\n }\n });\n },\n validate: function validate(value, helpers, _ref2) {\n let {\n n\n } = _ref2;\n\n if (value.length >= n) {\n return value;\n }\n\n return helpers.error('function.minArity', {\n n\n });\n }\n },\n maxArity: {\n method: function method(n) {\n Assert(Number.isSafeInteger(n) && n >= 0, 'n must be a positive integer');\n return this.$_addRule({\n name: 'maxArity',\n args: {\n n\n }\n });\n },\n validate: function validate(value, helpers, _ref3) {\n let {\n n\n } = _ref3;\n\n if (value.length <= n) {\n return value;\n }\n\n return helpers.error('function.maxArity', {\n n\n });\n }\n }\n },\n // Cast\n cast: {\n map: null // Disable object cast\n\n },\n // Errors\n messages: {\n 'function.arity': '\"{{#label}}\" must have an arity of {{#n}}',\n 'function.class': '\"{{#label}}\" must be a class',\n 'function.maxArity': '\"{{#label}}\" must have an arity lesser or equal to {{#n}}',\n 'function.minArity': '\"{{#label}}\" must have an arity greater or equal to {{#n}}'\n }\n});" }, { - "id": 39, + "id": 38, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/applyToDefaults.js", "name": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "index": 36, "index2": 33, - "size": 2108, + "size": 1755, "cacheable": true, "built": true, "optional": false, @@ -3594,8 +3501,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -3603,16 +3510,16 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/object.js", "name": "../lib/types/object.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 609, - "building": 122, - "dependencies": 125 + "factory": 390, + "building": 59, + "dependencies": 76 }, "failed": false, "errors": 0, @@ -3626,7 +3533,7 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/applyToDefaults", - "loc": "39:22-63" + "loc": "3:24-65" } ], "usedExports": true, @@ -3635,15 +3542,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('./assert');\n\nvar Clone = require('./clone');\n\nvar Merge = require('./merge');\n\nvar Utils = require('./utils');\n\nvar internals = {};\n\nmodule.exports = function (defaults, source) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(defaults && _typeof(defaults) === 'object', 'Invalid defaults value: must be an object');\n Assert(!source || source === true || _typeof(source) === 'object', 'Invalid source value: must be true, falsy or an object');\n Assert(_typeof(options) === 'object', 'Invalid options: must be an object');\n\n if (!source) {\n // If no source, return null\n return null;\n }\n\n if (options.shallow) {\n return internals.applyToDefaultsWithShallow(defaults, source, options);\n }\n\n var copy = Clone(defaults);\n\n if (source === true) {\n // If source is set to true, use defaults\n return copy;\n }\n\n var nullOverride = options.nullOverride !== undefined ? options.nullOverride : false;\n return Merge(copy, source, {\n nullOverride: nullOverride,\n mergeArrays: false\n });\n};\n\ninternals.applyToDefaultsWithShallow = function (defaults, source, options) {\n var keys = options.shallow;\n Assert(Array.isArray(keys), 'Invalid keys');\n options = Object.assign({}, options);\n options.shallow = false;\n var copy = Clone(defaults, {\n shallow: keys\n });\n\n if (source === true) {\n // If source is set to true, use defaults\n return copy;\n }\n\n var storage = Utils.store(source, keys); // Move shallow copy items to storage\n\n Merge(copy, source, {\n mergeArrays: false,\n nullOverride: false\n }); // Deep copy the rest\n\n Utils.restore(copy, source, storage); // Shallow copy the stored items and restore\n\n return copy;\n};" + "source": "'use strict';\n\nconst Assert = require('./assert');\n\nconst Clone = require('./clone');\n\nconst Merge = require('./merge');\n\nconst Utils = require('./utils');\n\nconst internals = {};\n\nmodule.exports = function (defaults, source) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(defaults && typeof defaults === 'object', 'Invalid defaults value: must be an object');\n Assert(!source || source === true || typeof source === 'object', 'Invalid source value: must be true, falsy or an object');\n Assert(typeof options === 'object', 'Invalid options: must be an object');\n\n if (!source) {\n // If no source, return null\n return null;\n }\n\n if (options.shallow) {\n return internals.applyToDefaultsWithShallow(defaults, source, options);\n }\n\n const copy = Clone(defaults);\n\n if (source === true) {\n // If source is set to true, use defaults\n return copy;\n }\n\n const nullOverride = options.nullOverride !== undefined ? options.nullOverride : false;\n return Merge(copy, source, {\n nullOverride,\n mergeArrays: false\n });\n};\n\ninternals.applyToDefaultsWithShallow = function (defaults, source, options) {\n const keys = options.shallow;\n Assert(Array.isArray(keys), 'Invalid keys');\n options = Object.assign({}, options);\n options.shallow = false;\n const copy = Clone(defaults, {\n shallow: keys\n });\n\n if (source === true) {\n // If source is set to true, use defaults\n return copy;\n }\n\n const storage = Utils.store(source, keys); // Move shallow copy items to storage\n\n Merge(copy, source, {\n mergeArrays: false,\n nullOverride: false\n }); // Deep copy the rest\n\n Utils.restore(copy, source, storage); // Shallow copy the stored items and restore\n\n return copy;\n};" }, { - "id": 40, + "id": 39, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/topo/lib/index.js", "name": "../node_modules/@hapi/topo/lib/index.js", "index": 37, "index2": 34, - "size": 6755, + "size": 5433, "cacheable": true, "built": true, "optional": false, @@ -3660,8 +3567,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -3669,16 +3576,16 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/object.js", "name": "../lib/types/object.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 609, - "building": 122, - "dependencies": 125 + "factory": 390, + "building": 59, + "dependencies": 76 }, "failed": false, "errors": 0, @@ -3692,7 +3599,7 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "@hapi/topo", - "loc": "47:11-32" + "loc": "11:13-34" } ], "usedExports": true, @@ -3701,15 +3608,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar internals = {};\n\nmodule.exports =\n/*#__PURE__*/\nfunction () {\n function Topo() {\n _classCallCheck(this, Topo);\n\n this._items = [];\n this.nodes = [];\n }\n\n _createClass(Topo, [{\n key: \"add\",\n value: function add(nodes, options) {\n var _this = this;\n\n options = options || {}; // Validate rules\n\n var before = [].concat(options.before || []);\n var after = [].concat(options.after || []);\n var group = options.group || '?';\n var sort = options.sort || 0; // Used for merging only\n\n Assert(!before.includes(group), \"Item cannot come before itself: \".concat(group));\n Assert(!before.includes('?'), 'Item cannot come before unassociated items');\n Assert(!after.includes(group), \"Item cannot come after itself: \".concat(group));\n Assert(!after.includes('?'), 'Item cannot come after unassociated items');\n [].concat(nodes).forEach(function (node, i) {\n var item = {\n seq: _this._items.length,\n sort: sort,\n before: before,\n after: after,\n group: group,\n node: node\n };\n\n _this._items.push(item);\n }); // Insert event\n\n var error = this._sort();\n\n Assert(!error, 'item', group !== '?' ? \"added into group \".concat(group) : '', 'created a dependencies error');\n return this.nodes;\n }\n }, {\n key: \"merge\",\n value: function merge(others) {\n others = [].concat(others);\n\n for (var i = 0; i < others.length; ++i) {\n var other = others[i];\n\n if (other) {\n for (var j = 0; j < other._items.length; ++j) {\n var item = Object.assign({}, other._items[j]); // Shallow cloned\n\n this._items.push(item);\n }\n }\n } // Sort items\n\n\n this._items.sort(internals.mergeSort);\n\n for (var _i = 0; _i < this._items.length; ++_i) {\n this._items[_i].seq = _i;\n }\n\n var error = this._sort();\n\n Assert(!error, 'merge created a dependencies error');\n return this.nodes;\n }\n }, {\n key: \"_sort\",\n value: function _sort() {\n // Construct graph\n var graph = {};\n var graphAfters = Object.create(null); // A prototype can bungle lookups w/ false positives\n\n var groups = Object.create(null);\n\n for (var i = 0; i < this._items.length; ++i) {\n var item = this._items[i];\n var seq = item.seq; // Unique across all items\n\n var group = item.group; // Determine Groups\n\n groups[group] = groups[group] || [];\n groups[group].push(seq); // Build intermediary graph using 'before'\n\n graph[seq] = item.before; // Build second intermediary graph with 'after'\n\n var after = item.after;\n\n for (var j = 0; j < after.length; ++j) {\n graphAfters[after[j]] = (graphAfters[after[j]] || []).concat(seq);\n }\n } // Expand intermediary graph\n\n\n var graphNodes = Object.keys(graph);\n\n for (var _i2 = 0; _i2 < graphNodes.length; ++_i2) {\n var node = graphNodes[_i2];\n var expandedGroups = [];\n var graphNodeItems = Object.keys(graph[node]);\n\n for (var _j = 0; _j < graphNodeItems.length; ++_j) {\n var _group = graph[node][graphNodeItems[_j]];\n groups[_group] = groups[_group] || [];\n\n for (var k = 0; k < groups[_group].length; ++k) {\n expandedGroups.push(groups[_group][k]);\n }\n }\n\n graph[node] = expandedGroups;\n } // Merge intermediary graph using graphAfters into final graph\n\n\n var afterNodes = Object.keys(graphAfters);\n\n for (var _i3 = 0; _i3 < afterNodes.length; ++_i3) {\n var _group2 = afterNodes[_i3];\n\n if (groups[_group2]) {\n for (var _j2 = 0; _j2 < groups[_group2].length; ++_j2) {\n var _node = groups[_group2][_j2];\n graph[_node] = graph[_node].concat(graphAfters[_group2]);\n }\n }\n } // Compile ancestors\n\n\n var children;\n var ancestors = {};\n graphNodes = Object.keys(graph);\n\n for (var _i4 = 0; _i4 < graphNodes.length; ++_i4) {\n var _node2 = graphNodes[_i4];\n children = graph[_node2];\n\n for (var _j3 = 0; _j3 < children.length; ++_j3) {\n ancestors[children[_j3]] = (ancestors[children[_j3]] || []).concat(_node2);\n }\n } // Topo sort\n\n\n var visited = {};\n var sorted = [];\n\n for (var _i5 = 0; _i5 < this._items.length; ++_i5) {\n // Really looping thru item.seq values out of order\n var next = _i5;\n\n if (ancestors[_i5]) {\n next = null;\n\n for (var _j4 = 0; _j4 < this._items.length; ++_j4) {\n // As above, these are item.seq values\n if (visited[_j4] === true) {\n continue;\n }\n\n if (!ancestors[_j4]) {\n ancestors[_j4] = [];\n }\n\n var shouldSeeCount = ancestors[_j4].length;\n var seenCount = 0;\n\n for (var _k = 0; _k < shouldSeeCount; ++_k) {\n if (visited[ancestors[_j4][_k]]) {\n ++seenCount;\n }\n }\n\n if (seenCount === shouldSeeCount) {\n next = _j4;\n break;\n }\n }\n }\n\n if (next !== null) {\n visited[next] = true;\n sorted.push(next);\n }\n }\n\n if (sorted.length !== this._items.length) {\n return new Error('Invalid dependencies');\n }\n\n var seqIndex = {};\n\n for (var _i6 = 0; _i6 < this._items.length; ++_i6) {\n var _item = this._items[_i6];\n seqIndex[_item.seq] = _item;\n }\n\n var sortedNodes = [];\n this._items = sorted.map(function (value) {\n var sortedItem = seqIndex[value];\n sortedNodes.push(sortedItem.node);\n return sortedItem;\n });\n this.nodes = sortedNodes;\n }\n }]);\n\n return Topo;\n}();\n\ninternals.mergeSort = function (a, b) {\n return a.sort === b.sort ? 0 : a.sort < b.sort ? -1 : 1;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst internals = {};\nmodule.exports = class Topo {\n constructor() {\n this._items = [];\n this.nodes = [];\n }\n\n add(nodes, options) {\n options = options || {}; // Validate rules\n\n const before = [].concat(options.before || []);\n const after = [].concat(options.after || []);\n const group = options.group || '?';\n const sort = options.sort || 0; // Used for merging only\n\n Assert(!before.includes(group), \"Item cannot come before itself: \".concat(group));\n Assert(!before.includes('?'), 'Item cannot come before unassociated items');\n Assert(!after.includes(group), \"Item cannot come after itself: \".concat(group));\n Assert(!after.includes('?'), 'Item cannot come after unassociated items');\n [].concat(nodes).forEach((node, i) => {\n const item = {\n seq: this._items.length,\n sort,\n before,\n after,\n group,\n node\n };\n\n this._items.push(item);\n }); // Insert event\n\n const error = this._sort();\n\n Assert(!error, 'item', group !== '?' ? \"added into group \".concat(group) : '', 'created a dependencies error');\n return this.nodes;\n }\n\n merge(others) {\n others = [].concat(others);\n\n for (let i = 0; i < others.length; ++i) {\n const other = others[i];\n\n if (other) {\n for (let j = 0; j < other._items.length; ++j) {\n const item = Object.assign({}, other._items[j]); // Shallow cloned\n\n this._items.push(item);\n }\n }\n } // Sort items\n\n\n this._items.sort(internals.mergeSort);\n\n for (let i = 0; i < this._items.length; ++i) {\n this._items[i].seq = i;\n }\n\n const error = this._sort();\n\n Assert(!error, 'merge created a dependencies error');\n return this.nodes;\n }\n\n _sort() {\n // Construct graph\n const graph = {};\n const graphAfters = Object.create(null); // A prototype can bungle lookups w/ false positives\n\n const groups = Object.create(null);\n\n for (let i = 0; i < this._items.length; ++i) {\n const item = this._items[i];\n const seq = item.seq; // Unique across all items\n\n const group = item.group; // Determine Groups\n\n groups[group] = groups[group] || [];\n groups[group].push(seq); // Build intermediary graph using 'before'\n\n graph[seq] = item.before; // Build second intermediary graph with 'after'\n\n const after = item.after;\n\n for (let j = 0; j < after.length; ++j) {\n graphAfters[after[j]] = (graphAfters[after[j]] || []).concat(seq);\n }\n } // Expand intermediary graph\n\n\n let graphNodes = Object.keys(graph);\n\n for (let i = 0; i < graphNodes.length; ++i) {\n const node = graphNodes[i];\n const expandedGroups = [];\n const graphNodeItems = Object.keys(graph[node]);\n\n for (let j = 0; j < graphNodeItems.length; ++j) {\n const group = graph[node][graphNodeItems[j]];\n groups[group] = groups[group] || [];\n\n for (let k = 0; k < groups[group].length; ++k) {\n expandedGroups.push(groups[group][k]);\n }\n }\n\n graph[node] = expandedGroups;\n } // Merge intermediary graph using graphAfters into final graph\n\n\n const afterNodes = Object.keys(graphAfters);\n\n for (let i = 0; i < afterNodes.length; ++i) {\n const group = afterNodes[i];\n\n if (groups[group]) {\n for (let j = 0; j < groups[group].length; ++j) {\n const node = groups[group][j];\n graph[node] = graph[node].concat(graphAfters[group]);\n }\n }\n } // Compile ancestors\n\n\n let children;\n const ancestors = {};\n graphNodes = Object.keys(graph);\n\n for (let i = 0; i < graphNodes.length; ++i) {\n const node = graphNodes[i];\n children = graph[node];\n\n for (let j = 0; j < children.length; ++j) {\n ancestors[children[j]] = (ancestors[children[j]] || []).concat(node);\n }\n } // Topo sort\n\n\n const visited = {};\n const sorted = [];\n\n for (let i = 0; i < this._items.length; ++i) {\n // Really looping thru item.seq values out of order\n let next = i;\n\n if (ancestors[i]) {\n next = null;\n\n for (let j = 0; j < this._items.length; ++j) {\n // As above, these are item.seq values\n if (visited[j] === true) {\n continue;\n }\n\n if (!ancestors[j]) {\n ancestors[j] = [];\n }\n\n const shouldSeeCount = ancestors[j].length;\n let seenCount = 0;\n\n for (let k = 0; k < shouldSeeCount; ++k) {\n if (visited[ancestors[j][k]]) {\n ++seenCount;\n }\n }\n\n if (seenCount === shouldSeeCount) {\n next = j;\n break;\n }\n }\n }\n\n if (next !== null) {\n visited[next] = true;\n sorted.push(next);\n }\n }\n\n if (sorted.length !== this._items.length) {\n return new Error('Invalid dependencies');\n }\n\n const seqIndex = {};\n\n for (let i = 0; i < this._items.length; ++i) {\n const item = this._items[i];\n seqIndex[item.seq] = item;\n }\n\n const sortedNodes = [];\n this._items = sorted.map(value => {\n const sortedItem = seqIndex[value];\n sortedNodes.push(sortedItem.node);\n return sortedItem;\n });\n this.nodes = sortedNodes;\n }\n\n};\n\ninternals.mergeSort = (a, b) => {\n return a.sort === b.sort ? 0 : a.sort < b.sort ? -1 : 1;\n};" }, { - "id": 41, + "id": 40, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/link.js", "name": "../lib/types/link.js", "index": 38, "index2": 37, - "size": 3107, + "size": 2999, "cacheable": true, "built": true, "optional": false, @@ -3726,15 +3633,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -3748,7 +3655,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/link", - "loc": "44:10-33" + "loc": "30:10-33" } ], "usedExports": true, @@ -3757,15 +3664,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar Compile = require('../compile');\n\nvar internals = {};\nmodule.exports = Any.extend({\n type: 'link',\n properties: {\n schemaChain: true\n },\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.link = null;\n },\n args: function args(schema, ref) {\n return schema.ref(ref);\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n var error = _ref.error,\n state = _ref.state,\n prefs = _ref.prefs;\n\n if (!schema.$_terms.link) {\n return {\n value: value,\n errors: error('link.uninitialized')\n };\n }\n\n var ref = schema.$_terms.link[0].ref;\n var perspective = ref.ancestor === 'root' ? state.schemas[0] : state.schemas[state.schemas.length - ref.ancestor - 1];\n\n if (!perspective) {\n return {\n value: value,\n errors: error('link.depth', {\n ref: ref\n })\n };\n }\n\n try {\n var linked = ref.path.length ? perspective.$_reach(ref.path) : perspective;\n } catch (err) {\n return {\n value: value,\n errors: error('link.ref', {\n ref: ref\n })\n };\n }\n\n if (linked.type === 'link') {\n return {\n value: value,\n errors: error('link.loop', {\n ref: ref\n })\n };\n }\n\n return linked.$_validate(value, state.nest(linked), prefs);\n },\n // Rules\n rules: {\n ref: {\n method: function method(ref) {\n Assert(!this.$_terms.link, 'Cannot reinitialize schema');\n ref = Compile.ref(ref);\n Assert(ref.type === 'value', 'Invalid reference type');\n Assert(ref.ancestor === 'root' || ref.ancestor > 0, 'Link cannot reference itself');\n var obj = this.clone();\n obj.$_terms.link = [{\n ref: ref\n }];\n return obj;\n }\n }\n },\n // Overrides\n overrides: {\n concat: function concat(source) {\n Assert(this.$_terms.link, 'Uninitialized link schema');\n Assert(Common.isSchema(source), 'Invalid schema object');\n Assert(source.type === 'any', 'Cannot merge type link with another type:', source.type);\n return this.super.concat(source);\n },\n when: function when() {\n var _obj$super;\n\n Assert(this.$_terms.link, 'Uninitialized link schema');\n var ref = this.$_terms.link[0].ref.clone();\n ++ref.ancestor;\n ref.updateDisplay();\n var obj = this.clone();\n obj.$_terms.link = [{\n ref: ref\n }];\n return (_obj$super = obj.super).when.apply(_obj$super, arguments);\n }\n },\n // Build\n build: function build(obj, desc) {\n return obj.ref(desc.link);\n },\n // Errors\n messages: {\n 'link.depth': '\"{{#label}}\" contains link reference \"{{#ref}}\" outside of schema boundaries',\n 'link.loop': '\"{{#label}}\" contains link reference to another link \"{{#ref}}\"',\n 'link.ref': '\"{{#label}}\" contains link reference to non-existing \"{{#ref}}\" schema',\n 'link.uninitialized': 'uninitialized schema'\n }\n});" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst Compile = require('../compile');\n\nconst internals = {};\nmodule.exports = Any.extend({\n type: 'link',\n properties: {\n schemaChain: true\n },\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.link = null;\n },\n args: function args(schema, ref) {\n return schema.ref(ref);\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n let {\n error,\n state,\n prefs\n } = _ref;\n\n if (!schema.$_terms.link) {\n return {\n value,\n errors: error('link.uninitialized')\n };\n }\n\n const ref = schema.$_terms.link[0].ref;\n const perspective = ref.ancestor === 'root' ? state.schemas[0] : state.schemas[state.schemas.length - ref.ancestor - 1];\n\n if (!perspective) {\n return {\n value,\n errors: error('link.depth', {\n ref\n })\n };\n }\n\n try {\n var linked = ref.path.length ? perspective.$_reach(ref.path) : perspective;\n } catch (err) {\n return {\n value,\n errors: error('link.ref', {\n ref\n })\n };\n }\n\n if (linked.type === 'link') {\n return {\n value,\n errors: error('link.loop', {\n ref\n })\n };\n }\n\n return linked.$_validate(value, state.nest(linked), prefs);\n },\n // Rules\n rules: {\n ref: {\n method: function method(ref) {\n Assert(!this.$_terms.link, 'Cannot reinitialize schema');\n ref = Compile.ref(ref);\n Assert(ref.type === 'value', 'Invalid reference type');\n Assert(ref.ancestor === 'root' || ref.ancestor > 0, 'Link cannot reference itself');\n const obj = this.clone();\n obj.$_terms.link = [{\n ref\n }];\n return obj;\n }\n }\n },\n // Overrides\n overrides: {\n concat: function concat(source) {\n Assert(this.$_terms.link, 'Uninitialized link schema');\n Assert(Common.isSchema(source), 'Invalid schema object');\n Assert(source.type === 'any', 'Cannot merge type link with another type:', source.type);\n return this.super.concat(source);\n },\n when: function when() {\n Assert(this.$_terms.link, 'Uninitialized link schema');\n const ref = this.$_terms.link[0].ref.clone();\n ++ref.ancestor;\n ref.updateDisplay();\n const obj = this.clone();\n obj.$_terms.link = [{\n ref\n }];\n return obj.super.when(...arguments);\n }\n },\n // Build\n build: function build(obj, desc) {\n return obj.ref(desc.link);\n },\n // Errors\n messages: {\n 'link.depth': '\"{{#label}}\" contains link reference \"{{#ref}}\" outside of schema boundaries',\n 'link.loop': '\"{{#label}}\" contains link reference to another link \"{{#ref}}\"',\n 'link.ref': '\"{{#label}}\" contains link reference to non-existing \"{{#ref}}\" schema',\n 'link.uninitialized': 'uninitialized schema'\n }\n});" }, { - "id": 42, + "id": 41, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/number.js", "name": "../lib/types/number.js", "index": 39, "index2": 38, - "size": 8735, + "size": 8636, "cacheable": true, "built": true, "optional": false, @@ -3782,15 +3689,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -3804,7 +3711,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/number", - "loc": "45:12-37" + "loc": "31:12-37" } ], "usedExports": true, @@ -3813,15 +3720,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar internals = {\n numberRx: /^\\s*[+-]?(?:(?:\\d+(?:\\.\\d*)?)|(?:\\.\\d+))(?:e([+-]?\\d+))?\\s*$/i,\n precisionRx: /(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/\n};\nmodule.exports = Any.extend({\n type: 'number',\n // Initialize\n initialize: function initialize(schema) {\n schema._flags.unsafe = false;\n },\n // Coerce\n coerce: {\n from: 'string',\n method: function method(schema, value, _ref) {\n var error = _ref.error;\n var matches = value.match(internals.numberRx);\n\n if (!matches) {\n return;\n }\n\n value = value.trim();\n var result = {\n value: parseFloat(value)\n };\n\n if (!schema._flags.unsafe) {\n if (value.includes('e')) {\n var constructed = internals.normalizeExponent(\"\".concat(result.value / Math.pow(10, matches[1]), \"e\").concat(matches[1]));\n\n if (constructed !== internals.normalizeExponent(value)) {\n result.errors = error('number.unsafe');\n return result;\n }\n } else {\n var string = result.value.toString();\n\n if (string.includes('e')) {\n return result;\n }\n\n if (string !== internals.normalizeDecimal(value)) {\n result.errors = error('number.unsafe');\n return result;\n }\n }\n }\n\n return result;\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n var error = _ref2.error,\n prefs = _ref2.prefs;\n\n if (value === Infinity || value === -Infinity) {\n return {\n value: value,\n errors: error('number.infinity')\n };\n }\n\n if (!Common.isNumber(value)) {\n return {\n value: value,\n errors: error('number.base')\n };\n }\n\n var result = {\n value: value\n };\n\n if (prefs.convert) {\n var rule = schema.$_getRule('precision');\n\n if (rule) {\n var precision = Math.pow(10, rule.args.limit); // This is conceptually equivalent to using toFixed but it should be much faster\n\n result.value = Math.round(result.value * precision) / precision;\n }\n }\n\n if (!schema._flags.unsafe && (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER)) {\n result.errors = error('number.unsafe');\n }\n\n return result;\n },\n // Rules\n rules: {\n compare: {\n method: false,\n validate: function validate(value, helpers, _ref3, _ref4) {\n var limit = _ref3.limit;\n var name = _ref4.name,\n operator = _ref4.operator,\n args = _ref4.args;\n\n if (Common.compare(value, limit, operator)) {\n return value;\n }\n\n return helpers.error('number.' + name, {\n limit: args.limit,\n value: value\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.isNumber,\n message: 'must be a number'\n }]\n },\n greater: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'greater',\n method: 'compare',\n args: {\n limit: limit\n },\n operator: '>'\n });\n }\n },\n integer: {\n method: function method() {\n return this.$_addRule('integer');\n },\n validate: function validate(value, helpers) {\n if (Math.trunc(value) - value === 0) {\n return value;\n }\n\n return helpers.error('number.integer');\n }\n },\n less: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'less',\n method: 'compare',\n args: {\n limit: limit\n },\n operator: '<'\n });\n }\n },\n max: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'max',\n method: 'compare',\n args: {\n limit: limit\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'min',\n method: 'compare',\n args: {\n limit: limit\n },\n operator: '>='\n });\n }\n },\n multiple: {\n method: function method(base) {\n return this.$_addRule({\n name: 'multiple',\n args: {\n base: base\n }\n });\n },\n validate: function validate(value, helpers, _ref5, options) {\n var base = _ref5.base;\n\n if (value % base === 0) {\n return value;\n }\n\n return helpers.error('number.multiple', {\n multiple: options.args.base,\n value: value\n });\n },\n args: [{\n name: 'base',\n ref: true,\n assert: function assert(value) {\n return typeof value === 'number' && isFinite(value) && value > 0;\n },\n message: 'must be a positive number'\n }],\n multi: true\n },\n negative: {\n method: function method() {\n return this.sign('negative');\n }\n },\n port: {\n method: function method() {\n return this.$_addRule('port');\n },\n validate: function validate(value, helpers) {\n if (Number.isSafeInteger(value) && value >= 0 && value <= 65535) {\n return value;\n }\n\n return helpers.error('number.port');\n }\n },\n positive: {\n method: function method() {\n return this.sign('positive');\n }\n },\n precision: {\n method: function method(limit) {\n Assert(Number.isSafeInteger(limit), 'limit must be an integer');\n return this.$_addRule({\n name: 'precision',\n args: {\n limit: limit\n }\n });\n },\n validate: function validate(value, helpers, _ref6) {\n var limit = _ref6.limit;\n var places = value.toString().match(internals.precisionRx);\n var decimals = Math.max((places[1] ? places[1].length : 0) - (places[2] ? parseInt(places[2], 10) : 0), 0);\n\n if (decimals <= limit) {\n return value;\n }\n\n return helpers.error('number.precision', {\n limit: limit,\n value: value\n });\n },\n convert: true\n },\n sign: {\n method: function method(sign) {\n Assert(['negative', 'positive'].includes(sign), 'Invalid sign', sign);\n return this.$_addRule({\n name: 'sign',\n args: {\n sign: sign\n }\n });\n },\n validate: function validate(value, helpers, _ref7) {\n var sign = _ref7.sign;\n\n if (sign === 'negative' && value < 0 || sign === 'positive' && value > 0) {\n return value;\n }\n\n return helpers.error(\"number.\".concat(sign));\n }\n },\n unsafe: {\n method: function method() {\n var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof enabled === 'boolean', 'enabled must be a boolean');\n return this.$_setFlag('unsafe', enabled);\n }\n }\n },\n // Cast\n cast: {\n string: {\n from: function from(value) {\n return typeof value === 'number';\n },\n to: function to(value, helpers) {\n return value.toString();\n }\n }\n },\n // Errors\n messages: {\n 'number.base': '\"{{#label}}\" must be a number',\n 'number.greater': '\"{{#label}}\" must be greater than {{#limit}}',\n 'number.infinity': '\"{{#label}}\" cannot be infinity',\n 'number.integer': '\"{{#label}}\" must be an integer',\n 'number.less': '\"{{#label}}\" must be less than {{#limit}}',\n 'number.max': '\"{{#label}}\" must be less than or equal to {{#limit}}',\n 'number.min': '\"{{#label}}\" must be larger than or equal to {{#limit}}',\n 'number.multiple': '\"{{#label}}\" must be a multiple of {{#multiple}}',\n 'number.negative': '\"{{#label}}\" must be a negative number',\n 'number.port': '\"{{#label}}\" must be a valid port',\n 'number.positive': '\"{{#label}}\" must be a positive number',\n 'number.precision': '\"{{#label}}\" must have no more than {{#limit}} decimal places',\n 'number.unsafe': '\"{{#label}}\" must be a safe number'\n }\n}); // Helpers\n\ninternals.normalizeExponent = function (str) {\n return str.replace(/\\.(\\d*[1-9])?0+e/, '.$1e').replace(/\\.e/, 'e').replace(/e\\+/, 'e').replace(/^\\+/, '').replace(/^(-?)0+([1-9])/, '$1$2');\n};\n\ninternals.normalizeDecimal = function (str) {\n str = str.replace(/^\\+/, '').replace(/\\.0+$/, '').replace(/^(-?)\\.([^\\.]*)$/, '$10.$2').replace(/^(-?)0+([1-9])/, '$1$2');\n\n if (str.includes('.') && str.endsWith('0')) {\n str = str.replace(/0+$/, '');\n }\n\n return str;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst internals = {\n numberRx: /^\\s*[+-]?(?:(?:\\d+(?:\\.\\d*)?)|(?:\\.\\d+))(?:e([+-]?\\d+))?\\s*$/i,\n precisionRx: /(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/\n};\nmodule.exports = Any.extend({\n type: 'number',\n // Initialize\n initialize: function initialize(schema) {\n schema._flags.unsafe = false;\n },\n // Coerce\n coerce: {\n from: 'string',\n method: function method(schema, value, _ref) {\n let {\n error\n } = _ref;\n const matches = value.match(internals.numberRx);\n\n if (!matches) {\n return;\n }\n\n value = value.trim();\n const result = {\n value: parseFloat(value)\n };\n\n if (!schema._flags.unsafe) {\n if (value.includes('e')) {\n const constructed = internals.normalizeExponent(\"\".concat(result.value / Math.pow(10, matches[1]), \"e\").concat(matches[1]));\n\n if (constructed !== internals.normalizeExponent(value)) {\n result.errors = error('number.unsafe');\n return result;\n }\n } else {\n const string = result.value.toString();\n\n if (string.includes('e')) {\n return result;\n }\n\n if (string !== internals.normalizeDecimal(value)) {\n result.errors = error('number.unsafe');\n return result;\n }\n }\n }\n\n return result;\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n let {\n error,\n prefs\n } = _ref2;\n\n if (value === Infinity || value === -Infinity) {\n return {\n value,\n errors: error('number.infinity')\n };\n }\n\n if (!Common.isNumber(value)) {\n return {\n value,\n errors: error('number.base')\n };\n }\n\n const result = {\n value\n };\n\n if (prefs.convert) {\n const rule = schema.$_getRule('precision');\n\n if (rule) {\n const precision = Math.pow(10, rule.args.limit); // This is conceptually equivalent to using toFixed but it should be much faster\n\n result.value = Math.round(result.value * precision) / precision;\n }\n }\n\n if (!schema._flags.unsafe && (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER)) {\n result.errors = error('number.unsafe');\n }\n\n return result;\n },\n // Rules\n rules: {\n compare: {\n method: false,\n validate: function validate(value, helpers, _ref3, _ref4) {\n let {\n limit\n } = _ref3;\n let {\n name,\n operator,\n args\n } = _ref4;\n\n if (Common.compare(value, limit, operator)) {\n return value;\n }\n\n return helpers.error('number.' + name, {\n limit: args.limit,\n value\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.isNumber,\n message: 'must be a number'\n }]\n },\n greater: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'greater',\n method: 'compare',\n args: {\n limit\n },\n operator: '>'\n });\n }\n },\n integer: {\n method: function method() {\n return this.$_addRule('integer');\n },\n validate: function validate(value, helpers) {\n if (Math.trunc(value) - value === 0) {\n return value;\n }\n\n return helpers.error('number.integer');\n }\n },\n less: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'less',\n method: 'compare',\n args: {\n limit\n },\n operator: '<'\n });\n }\n },\n max: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'max',\n method: 'compare',\n args: {\n limit\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'min',\n method: 'compare',\n args: {\n limit\n },\n operator: '>='\n });\n }\n },\n multiple: {\n method: function method(base) {\n return this.$_addRule({\n name: 'multiple',\n args: {\n base\n }\n });\n },\n validate: function validate(value, helpers, _ref5, options) {\n let {\n base\n } = _ref5;\n\n if (value % base === 0) {\n return value;\n }\n\n return helpers.error('number.multiple', {\n multiple: options.args.base,\n value\n });\n },\n args: [{\n name: 'base',\n ref: true,\n assert: value => typeof value === 'number' && isFinite(value) && value > 0,\n message: 'must be a positive number'\n }],\n multi: true\n },\n negative: {\n method: function method() {\n return this.sign('negative');\n }\n },\n port: {\n method: function method() {\n return this.$_addRule('port');\n },\n validate: function validate(value, helpers) {\n if (Number.isSafeInteger(value) && value >= 0 && value <= 65535) {\n return value;\n }\n\n return helpers.error('number.port');\n }\n },\n positive: {\n method: function method() {\n return this.sign('positive');\n }\n },\n precision: {\n method: function method(limit) {\n Assert(Number.isSafeInteger(limit), 'limit must be an integer');\n return this.$_addRule({\n name: 'precision',\n args: {\n limit\n }\n });\n },\n validate: function validate(value, helpers, _ref6) {\n let {\n limit\n } = _ref6;\n const places = value.toString().match(internals.precisionRx);\n const decimals = Math.max((places[1] ? places[1].length : 0) - (places[2] ? parseInt(places[2], 10) : 0), 0);\n\n if (decimals <= limit) {\n return value;\n }\n\n return helpers.error('number.precision', {\n limit,\n value\n });\n },\n convert: true\n },\n sign: {\n method: function method(sign) {\n Assert(['negative', 'positive'].includes(sign), 'Invalid sign', sign);\n return this.$_addRule({\n name: 'sign',\n args: {\n sign\n }\n });\n },\n validate: function validate(value, helpers, _ref7) {\n let {\n sign\n } = _ref7;\n\n if (sign === 'negative' && value < 0 || sign === 'positive' && value > 0) {\n return value;\n }\n\n return helpers.error(\"number.\".concat(sign));\n }\n },\n unsafe: {\n method: function method() {\n let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof enabled === 'boolean', 'enabled must be a boolean');\n return this.$_setFlag('unsafe', enabled);\n }\n }\n },\n // Cast\n cast: {\n string: {\n from: value => typeof value === 'number',\n to: function to(value, helpers) {\n return value.toString();\n }\n }\n },\n // Errors\n messages: {\n 'number.base': '\"{{#label}}\" must be a number',\n 'number.greater': '\"{{#label}}\" must be greater than {{#limit}}',\n 'number.infinity': '\"{{#label}}\" cannot be infinity',\n 'number.integer': '\"{{#label}}\" must be an integer',\n 'number.less': '\"{{#label}}\" must be less than {{#limit}}',\n 'number.max': '\"{{#label}}\" must be less than or equal to {{#limit}}',\n 'number.min': '\"{{#label}}\" must be larger than or equal to {{#limit}}',\n 'number.multiple': '\"{{#label}}\" must be a multiple of {{#multiple}}',\n 'number.negative': '\"{{#label}}\" must be a negative number',\n 'number.port': '\"{{#label}}\" must be a valid port',\n 'number.positive': '\"{{#label}}\" must be a positive number',\n 'number.precision': '\"{{#label}}\" must have no more than {{#limit}} decimal places',\n 'number.unsafe': '\"{{#label}}\" must be a safe number'\n }\n}); // Helpers\n\ninternals.normalizeExponent = function (str) {\n return str.replace(/\\.(\\d*[1-9])?0+e/, '.$1e').replace(/\\.e/, 'e').replace(/e\\+/, 'e').replace(/^\\+/, '').replace(/^(-?)0+([1-9])/, '$1$2');\n};\n\ninternals.normalizeDecimal = function (str) {\n str = str.replace(/^\\+/, '').replace(/\\.0+$/, '').replace(/^(-?)\\.([^\\.]*)$/, '$10.$2').replace(/^(-?)0+([1-9])/, '$1$2');\n\n if (str.includes('.') && str.endsWith('0')) {\n str = str.replace(/0+$/, '');\n }\n\n return str;\n};" }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "index": 40, - "index2": 50, - "size": 31086, + "index2": 49, + "size": 28602, "cacheable": true, "built": true, "optional": false, @@ -3838,15 +3745,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -3860,7 +3767,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/string", - "loc": "47:12-37" + "loc": "33:12-37" } ], "usedExports": true, @@ -3869,15 +3776,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar Address = require('@hapi/address');\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar EscapeRegex = require('@hapi/hoek/lib/escapeRegex');\n\nvar Contain = require('@hapi/hoek/lib/contain');\n\nvar Any = require('../any');\n\nvar Common = require('../../common');\n\nvar Ip = require('./ip');\n\nvar Uri = require('./uri');\n\nvar internals = {\n base64Regex: {\n // paddingRequired\n true: {\n // urlSafe\n true: /^(?:[\\w\\-]{2}[\\w\\-]{2})*(?:[\\w\\-]{2}==|[\\w\\-]{3}=)?$/,\n false: /^(?:[A-Za-z0-9+\\/]{2}[A-Za-z0-9+\\/]{2})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/\n },\n false: {\n true: /^(?:[\\w\\-]{2}[\\w\\-]{2})*(?:[\\w\\-]{2}(==)?|[\\w\\-]{3}=?)?$/,\n false: /^(?:[A-Za-z0-9+\\/]{2}[A-Za-z0-9+\\/]{2})*(?:[A-Za-z0-9+\\/]{2}(==)?|[A-Za-z0-9+\\/]{3}=?)?$/\n }\n },\n dataUriRegex: {\n format: /^data:[\\w+.-]+\\/[\\w+.-]+;((charset=[\\w-]+|base64),)?(.*)$/,\n base64: {\n // paddingRequired\n true: /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/,\n false: /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}(==)?|[A-Za-z0-9+\\/]{3}=?)?$/\n }\n },\n hexRegex: /^[a-f0-9]+$/i,\n hostRegex: /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$/,\n ipRegex: Ip.createIpRegex(['ipv4', 'ipv6', 'ipvfuture'], 'optional'),\n isoDurationRegex: /^P(?!$)(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?$/,\n guidBrackets: {\n '{': '}',\n '[': ']',\n '(': ')',\n '': ''\n },\n guidVersions: {\n uuidv1: '1',\n uuidv2: '2',\n uuidv3: '3',\n uuidv4: '4',\n uuidv5: '5'\n },\n cidrPresences: ['required', 'optional', 'forbidden'],\n normalizationForms: ['NFC', 'NFD', 'NFKC', 'NFKD']\n};\nmodule.exports = Any.extend({\n type: 'string',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.replacements = null;\n },\n // Coerce\n coerce: {\n from: 'string',\n method: function method(schema, value, _ref) {\n var state = _ref.state,\n prefs = _ref.prefs;\n var normalize = schema.$_getRule('normalize');\n\n if (normalize) {\n value = value.normalize(normalize.args.form);\n }\n\n var casing = schema.$_getRule('case');\n\n if (casing) {\n value = casing.args.direction === 'upper' ? value.toLocaleUpperCase() : value.toLocaleLowerCase();\n }\n\n var trim = schema.$_getRule('trim');\n\n if (trim && trim.args.enabled) {\n value = value.trim();\n }\n\n if (schema.$_terms.replacements) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = schema.$_terms.replacements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var replacement = _step.value;\n value = value.replace(replacement.pattern, replacement.replacement);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n\n var hex = schema.$_getRule('hex');\n\n if (hex && hex.args.options.byteAligned && value.length % 2 !== 0) {\n value = \"0\".concat(value);\n }\n\n if (schema.$_getRule('isoDate')) {\n var valid = false;\n\n if (Common.isIsoDate(value)) {\n var date = new Date(value);\n\n if (!isNaN(date.getTime())) {\n value = date.toISOString();\n valid = true;\n }\n }\n\n if (!valid) {\n return {\n value: value,\n errors: schema.$_createError('string.isoDate', value, null, state, prefs)\n };\n }\n }\n\n if (schema._flags.truncate) {\n var rule = schema.$_getRule('max');\n\n if (rule) {\n var limit = rule.args.limit;\n\n if (Common.isResolvable(limit)) {\n limit = limit.resolve(value, state, prefs);\n\n if (!Common.limit(limit)) {\n return {\n value: value,\n errors: schema.$_createError('any.ref', limit, {\n ref: rule.args.limit,\n arg: 'limit',\n reason: 'must be a positive integer'\n }, state, prefs)\n };\n }\n }\n\n value = value.slice(0, limit);\n }\n }\n\n return {\n value: value\n };\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n var error = _ref2.error;\n\n if (typeof value !== 'string') {\n return {\n value: value,\n errors: error('string.base')\n };\n }\n\n if (value === '') {\n return {\n value: value,\n errors: error('string.empty')\n };\n }\n },\n // Rules\n rules: {\n alphanum: {\n method: function method() {\n return this.$_addRule('alphanum');\n },\n validate: function validate(value, helpers) {\n if (/^[a-zA-Z0-9]+$/.test(value)) {\n return value;\n }\n\n return helpers.error('string.alphanum');\n }\n },\n base64: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['paddingRequired', 'urlSafe']);\n options = _objectSpread({\n urlSafe: false,\n paddingRequired: true\n }, options);\n Assert(typeof options.paddingRequired === 'boolean', 'paddingRequired must be boolean');\n Assert(typeof options.urlSafe === 'boolean', 'urlSafe must be boolean');\n return this.$_addRule({\n name: 'base64',\n args: {\n options: options\n }\n });\n },\n validate: function validate(value, helpers, _ref3) {\n var options = _ref3.options;\n var regex = internals.base64Regex[options.paddingRequired][options.urlSafe];\n\n if (regex.test(value)) {\n return value;\n }\n\n return helpers.error('string.base64');\n }\n },\n case: {\n method: function method(direction) {\n Assert(['lower', 'upper'].includes(direction), 'Invalid case:', direction);\n return this.$_addRule({\n name: 'case',\n args: {\n direction: direction\n }\n });\n },\n validate: function validate(value, helpers, _ref4) {\n var direction = _ref4.direction;\n\n if (direction === 'lower' && value === value.toLocaleLowerCase() || direction === 'upper' && value === value.toLocaleUpperCase()) {\n return value;\n }\n\n return helpers.error(\"string.\".concat(direction, \"case\"));\n },\n convert: true\n },\n creditCard: {\n method: function method() {\n return this.$_addRule('creditCard');\n },\n validate: function validate(value, helpers) {\n var i = value.length;\n var sum = 0;\n var mul = 1;\n\n while (i--) {\n var char = value.charAt(i) * mul;\n sum = sum + (char - (char > 9) * 9);\n mul = mul ^ 3;\n }\n\n if (sum > 0 && sum % 10 === 0) {\n return value;\n }\n\n return helpers.error('string.creditCard');\n }\n },\n dataUri: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['paddingRequired']);\n options = _objectSpread({\n paddingRequired: true\n }, options);\n Assert(typeof options.paddingRequired === 'boolean', 'paddingRequired must be boolean');\n return this.$_addRule({\n name: 'dataUri',\n args: {\n options: options\n }\n });\n },\n validate: function validate(value, helpers, _ref5) {\n var options = _ref5.options;\n var matches = value.match(internals.dataUriRegex.format);\n\n if (matches) {\n if (!matches[2]) {\n return value;\n }\n\n if (matches[2] !== 'base64') {\n return value;\n }\n\n var base64regex = internals.dataUriRegex.base64[options.paddingRequired];\n\n if (base64regex.test(matches[3])) {\n return value;\n }\n }\n\n return helpers.error('string.dataUri');\n }\n },\n domain: {\n method: function method(options) {\n if (options) {\n Common.assertOptions(options, ['allowUnicode', 'minDomainSegments', 'tlds']);\n options = internals.addressOptions(options);\n }\n\n return this.$_addRule({\n name: 'domain',\n args: {\n options: options\n }\n });\n },\n validate: function validate(value, helpers, _ref6) {\n var options = _ref6.options;\n\n if (Address.domain.isValid(value, options)) {\n return value;\n }\n\n return helpers.error('string.domain');\n }\n },\n email: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['allowUnicode', 'minDomainSegments', 'multiple', 'separator', 'tlds']);\n Assert(options.multiple === undefined || typeof options.multiple === 'boolean', 'multiple option must be an boolean');\n options = internals.addressOptions(options);\n var regex = new RegExp(\"\\\\s*[\".concat(options.separator ? EscapeRegex(options.separator) : ',', \"]\\\\s*\"));\n return this.$_addRule({\n name: 'email',\n args: {\n options: options\n },\n regex: regex\n });\n },\n validate: function validate(value, helpers, _ref7, _ref8) {\n var options = _ref7.options;\n var regex = _ref8.regex;\n var emails = options.multiple ? value.split(regex) : [value];\n var invalids = [];\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = emails[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var email = _step2.value;\n\n if (!Address.email.isValid(email, options)) {\n invalids.push(email);\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (!invalids.length) {\n return value;\n }\n\n return helpers.error('string.email', {\n value: value,\n invalids: invalids\n });\n }\n },\n guid: {\n alias: 'uuid',\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['version']);\n var versionNumbers = '';\n\n if (options.version) {\n var versions = [].concat(options.version);\n Assert(versions.length >= 1, 'version must have at least 1 valid version specified');\n var set = new Set();\n\n for (var i = 0; i < versions.length; ++i) {\n var version = versions[i];\n Assert(typeof version === 'string', 'version at position ' + i + ' must be a string');\n var versionNumber = internals.guidVersions[version.toLowerCase()];\n Assert(versionNumber, 'version at position ' + i + ' must be one of ' + Object.keys(internals.guidVersions).join(', '));\n Assert(!set.has(versionNumber), 'version at position ' + i + ' must not be a duplicate');\n versionNumbers += versionNumber;\n set.add(versionNumber);\n }\n }\n\n var regex = new RegExp(\"^([\\\\[{\\\\(]?)[0-9A-F]{8}([:-]?)[0-9A-F]{4}\\\\2?[\".concat(versionNumbers || '0-9A-F', \"][0-9A-F]{3}\\\\2?[\").concat(versionNumbers ? '89AB' : '0-9A-F', \"][0-9A-F]{3}\\\\2?[0-9A-F]{12}([\\\\]}\\\\)]?)$\"), 'i');\n return this.$_addRule({\n name: 'guid',\n args: {\n options: options\n },\n regex: regex\n });\n },\n validate: function validate(value, helpers, args, _ref9) {\n var regex = _ref9.regex;\n var results = regex.exec(value);\n\n if (!results) {\n return helpers.error('string.guid');\n } // Matching braces\n\n\n if (internals.guidBrackets[results[1]] !== results[results.length - 1]) {\n return helpers.error('string.guid');\n }\n\n return value;\n }\n },\n hex: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['byteAligned']);\n options = _objectSpread({\n byteAligned: false\n }, options);\n Assert(typeof options.byteAligned === 'boolean', 'byteAligned must be boolean');\n return this.$_addRule({\n name: 'hex',\n args: {\n options: options\n }\n });\n },\n validate: function validate(value, helpers, _ref10) {\n var options = _ref10.options;\n\n if (!internals.hexRegex.test(value)) {\n return helpers.error('string.hex');\n }\n\n if (options.byteAligned && value.length % 2 !== 0) {\n return helpers.error('string.hexAlign');\n }\n\n return value;\n }\n },\n hostname: {\n method: function method() {\n return this.$_addRule('hostname');\n },\n validate: function validate(value, helpers) {\n if (value.length <= 255 && internals.hostRegex.test(value) || internals.ipRegex.test(value)) {\n return value;\n }\n\n return helpers.error('string.hostname');\n }\n },\n insensitive: {\n method: function method() {\n return this.$_setFlag('insensitive', true);\n }\n },\n ip: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['cidr', 'version']);\n options = Object.assign({}, options); // Shallow cloned\n\n var regex = internals.ipRegex;\n\n if (options.cidr) {\n Assert(typeof options.cidr === 'string', 'cidr must be a string');\n options.cidr = options.cidr.toLowerCase();\n Assert(Contain(internals.cidrPresences, options.cidr), 'cidr must be one of ' + internals.cidrPresences.join(', '));\n\n if (!options.version && options.cidr !== 'optional') {\n regex = Ip.createIpRegex(['ipv4', 'ipv6', 'ipvfuture'], options.cidr);\n }\n } else {\n options.cidr = 'optional';\n }\n\n var versions;\n\n if (options.version) {\n if (!Array.isArray(options.version)) {\n options.version = [options.version];\n }\n\n Assert(options.version.length >= 1, 'version must have at least 1 version specified');\n versions = [];\n\n for (var i = 0; i < options.version.length; ++i) {\n var version = options.version[i];\n Assert(typeof version === 'string', 'version at position ' + i + ' must be a string');\n version = version.toLowerCase();\n Assert(Ip.versions[version], 'version at position ' + i + ' must be one of ' + Object.keys(Ip.versions).join(', '));\n versions.push(version);\n }\n\n versions = Array.from(new Set(versions));\n regex = Ip.createIpRegex(versions, options.cidr);\n }\n\n return this.$_addRule({\n name: 'ip',\n args: {\n options: options\n },\n versions: versions,\n regex: regex\n });\n },\n validate: function validate(value, helpers, _ref11, _ref12) {\n var options = _ref11.options;\n var versions = _ref12.versions,\n regex = _ref12.regex;\n\n if (regex.test(value)) {\n return value;\n }\n\n if (versions) {\n return helpers.error('string.ipVersion', {\n value: value,\n cidr: options.cidr,\n version: versions\n });\n }\n\n return helpers.error('string.ip', {\n value: value,\n cidr: options.cidr\n });\n }\n },\n isoDate: {\n method: function method() {\n return this.$_addRule('isoDate');\n },\n validate: function validate(value, _ref13) {\n var error = _ref13.error;\n\n if (Common.isIsoDate(value)) {\n return value;\n }\n\n return error('string.isoDate');\n },\n convert: true\n },\n isoDuration: {\n method: function method() {\n return this.$_addRule('isoDuration');\n },\n validate: function validate(value, helpers) {\n if (internals.isoDurationRegex.test(value)) {\n return value;\n }\n\n return helpers.error('string.isoDuration');\n }\n },\n length: {\n method: function method(limit, encoding) {\n return internals.length(this, 'length', limit, '=', encoding);\n },\n validate: function validate(value, helpers, _ref14, _ref15) {\n var limit = _ref14.limit,\n encoding = _ref14.encoding;\n var name = _ref15.name,\n operator = _ref15.operator,\n args = _ref15.args;\n var length =\n /*encoding ? Buffer.byteLength(value, encoding) :*/\n value.length;\n\n if (Common.compare(length, limit, operator)) {\n return value;\n }\n\n return helpers.error('string.' + name, {\n limit: args.limit,\n value: value,\n encoding: encoding\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.limit,\n message: 'must be a positive integer'\n }, 'encoding']\n },\n lowercase: {\n method: function method() {\n return this.case('lower');\n }\n },\n max: {\n method: function method(limit, encoding) {\n return internals.length(this, 'max', limit, '<=', encoding);\n },\n args: ['limit', 'encoding']\n },\n min: {\n method: function method(limit, encoding) {\n return internals.length(this, 'min', limit, '>=', encoding);\n },\n args: ['limit', 'encoding']\n },\n normalize: {\n method: function method() {\n var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'NFC';\n Assert(Contain(internals.normalizationForms, form), 'normalization form must be one of ' + internals.normalizationForms.join(', '));\n return this.$_addRule({\n name: 'normalize',\n args: {\n form: form\n }\n });\n },\n validate: function validate(value, _ref16, _ref17) {\n var error = _ref16.error;\n var form = _ref17.form;\n\n if (value === value.normalize(form)) {\n return value;\n }\n\n return error('string.normalize', {\n value: value,\n form: form\n });\n },\n convert: true\n },\n pattern: {\n alias: 'regex',\n method: function method(regex) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(regex instanceof RegExp, 'regex must be a RegExp');\n Assert(!regex.flags.includes('g') && !regex.flags.includes('y'), 'regex should not use global or sticky mode');\n\n if (typeof options === 'string') {\n options = {\n name: options\n };\n }\n\n Common.assertOptions(options, ['invert', 'name']);\n var errorCode = ['string.pattern', options.invert ? '.invert' : '', options.name ? '.name' : '.base'].join('');\n return this.$_addRule({\n name: 'pattern',\n args: {\n regex: regex,\n options: options\n },\n errorCode: errorCode\n });\n },\n validate: function validate(value, helpers, _ref18, _ref19) {\n var regex = _ref18.regex,\n options = _ref18.options;\n var errorCode = _ref19.errorCode;\n var patternMatch = regex.test(value);\n\n if (patternMatch ^ options.invert) {\n return value;\n }\n\n return helpers.error(errorCode, {\n name: options.name,\n regex: regex,\n value: value\n });\n },\n args: ['regex', 'options'],\n multi: true\n },\n replace: {\n method: function method(pattern, replacement) {\n if (typeof pattern === 'string') {\n pattern = new RegExp(EscapeRegex(pattern), 'g');\n }\n\n Assert(pattern instanceof RegExp, 'pattern must be a RegExp');\n Assert(typeof replacement === 'string', 'replacement must be a String');\n var obj = this.clone();\n\n if (!obj.$_terms.replacements) {\n obj.$_terms.replacements = [];\n }\n\n obj.$_terms.replacements.push({\n pattern: pattern,\n replacement: replacement\n });\n return obj;\n }\n },\n token: {\n method: function method() {\n return this.$_addRule('token');\n },\n validate: function validate(value, helpers) {\n if (/^\\w+$/.test(value)) {\n return value;\n }\n\n return helpers.error('string.token');\n }\n },\n trim: {\n method: function method() {\n var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof enabled === 'boolean', 'enabled must be a boolean');\n return this.$_addRule({\n name: 'trim',\n args: {\n enabled: enabled\n }\n });\n },\n validate: function validate(value, helpers, _ref20) {\n var enabled = _ref20.enabled;\n\n if (!enabled || value === value.trim()) {\n return value;\n }\n\n return helpers.error('string.trim');\n },\n convert: true\n },\n truncate: {\n method: function method() {\n var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof enabled === 'boolean', 'enabled must be a boolean');\n return this.$_setFlag('truncate', enabled);\n }\n },\n uppercase: {\n method: function method() {\n return this.case('upper');\n }\n },\n uri: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['allowRelative', 'allowQuerySquareBrackets', 'domain', 'relativeOnly', 'scheme']);\n var unknownOptions = Object.keys(options).filter(function (key) {\n return !['scheme', 'allowRelative', 'relativeOnly', 'allowQuerySquareBrackets', 'domain'].includes(key);\n });\n Assert(unknownOptions.length === 0, \"options contain unknown keys: \".concat(unknownOptions));\n\n if (options.domain) {\n options = Object.assign({}, options); // Shallow cloned\n\n options.domain = internals.addressOptions(options.domain);\n }\n\n var regex = Uri.createRegex(options);\n return this.$_addRule({\n name: 'uri',\n args: {\n options: options\n },\n regex: regex\n });\n },\n validate: function validate(value, helpers, _ref21, _ref22) {\n var options = _ref21.options;\n var regex = _ref22.regex;\n\n if (['http:/', 'https:/'].includes(value)) {\n // scheme:/ is technically valid but makes no sense\n return helpers.error('string.uri');\n }\n\n var match = regex.exec(value);\n\n if (match) {\n if (options.domain && !Address.domain.isValid(match[1], options.domain)) {\n return helpers.error('string.domain', {\n value: match[1]\n });\n }\n\n return value;\n }\n\n if (options.relativeOnly) {\n return helpers.error('string.uriRelativeOnly');\n }\n\n if (options.scheme) {\n return helpers.error('string.uriCustomScheme', {\n scheme: regex.scheme,\n value: value\n });\n }\n\n return helpers.error('string.uri');\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = desc.replacements[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var _step3$value = _step3.value,\n pattern = _step3$value.pattern,\n replacement = _step3$value.replacement;\n obj = obj.replace(pattern, replacement);\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n return obj;\n },\n // Errors\n messages: {\n 'string.alphanum': '\"{{#label}}\" must only contain alpha-numeric characters',\n 'string.base': '\"{{#label}}\" must be a string',\n 'string.base64': '\"{{#label}}\" must be a valid base64 string',\n 'string.creditCard': '\"{{#label}}\" must be a credit card',\n 'string.dataUri': '\"{{#label}}\" must be a valid dataUri string',\n 'string.domain': '\"{{#label}}\" must contain a valid domain name',\n 'string.email': '\"{{#label}}\" must be a valid email',\n 'string.empty': '\"{{#label}}\" is not allowed to be empty',\n 'string.guid': '\"{{#label}}\" must be a valid GUID',\n 'string.hex': '\"{{#label}}\" must only contain hexadecimal characters',\n 'string.hexAlign': '\"{{#label}}\" hex decoded representation must be byte aligned',\n 'string.hostname': '\"{{#label}}\" must be a valid hostname',\n 'string.ip': '\"{{#label}}\" must be a valid ip address with a {{#cidr}} CIDR',\n 'string.ipVersion': '\"{{#label}}\" must be a valid ip address of one of the following versions {{#version}} with a {{#cidr}} CIDR',\n 'string.isoDate': '\"{{#label}}\" must be a valid ISO 8601 date',\n 'string.isoDuration': '\"{{#label}}\" must be a valid ISO 8601 duration',\n 'string.length': '\"{{#label}}\" length must be {{#limit}} characters long',\n 'string.lowercase': '\"{{#label}}\" must only contain lowercase characters',\n 'string.max': '\"{{#label}}\" length must be less than or equal to {{#limit}} characters long',\n 'string.min': '\"{{#label}}\" length must be at least {{#limit}} characters long',\n 'string.normalize': '\"{{#label}}\" must be unicode normalized in the {{#form}} form',\n 'string.token': '\"{{#label}}\" must only contain alpha-numeric and underscore characters',\n 'string.pattern.base': '\"{{#label}}\" with value \"{[.]}\" fails to match the required pattern: {{#regex}}',\n 'string.pattern.name': '\"{{#label}}\" with value \"{[.]}\" fails to match the {{#name}} pattern',\n 'string.pattern.invert.base': '\"{{#label}}\" with value \"{[.]}\" matches the inverted pattern: {{#regex}}',\n 'string.pattern.invert.name': '\"{{#label}}\" with value \"{[.]}\" matches the inverted {{#name}} pattern',\n 'string.trim': '\"{{#label}}\" must not have leading or trailing whitespace',\n 'string.uri': '\"{{#label}}\" must be a valid uri',\n 'string.uriCustomScheme': '\"{{#label}}\" must be a valid uri with a scheme matching the {{#scheme}} pattern',\n 'string.uriRelativeOnly': '\"{{#label}}\" must be a valid relative uri',\n 'string.uppercase': '\"{{#label}}\" must only contain uppercase characters'\n }\n}); // Helpers\n\ninternals.addressOptions = function (options) {\n if (options.tlds && _typeof(options.tlds) === 'object') {\n Assert(options.tlds.allow === undefined || options.tlds.allow === false || options.tlds.allow === true || Array.isArray(options.tlds.allow) || options.tlds.allow instanceof Set, 'tlds.allow must be an array, Set, or boolean');\n Assert(options.tlds.deny === undefined || Array.isArray(options.tlds.deny) || options.tlds.deny instanceof Set, 'tlds.deny must be an array or Set');\n\n var normalizeTable = function normalizeTable(table) {\n if (table === undefined || typeof table === 'boolean' || table instanceof Set) {\n return table;\n }\n\n return new Set(table);\n };\n\n options = Object.assign({}, options); // Shallow cloned\n\n options.tlds = {\n allow: normalizeTable(options.tlds.allow),\n deny: normalizeTable(options.tlds.deny)\n };\n }\n\n Assert(options.minDomainSegments === undefined || Number.isSafeInteger(options.minDomainSegments) && options.minDomainSegments > 0, 'minDomainSegments must be a positive integer');\n return options;\n};\n\ninternals.length = function (schema, name, limit, operator, encoding) {\n // Assert(!encoding || Buffer.isEncoding(encoding), 'Invalid encoding:', encoding);\n return schema.$_addRule({\n name: name,\n method: 'length',\n args: {\n limit: limit,\n encoding: encoding\n },\n operator: operator\n });\n};" + "source": "'use strict';\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nconst Address = require('@hapi/address');\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst EscapeRegex = require('@hapi/hoek/lib/escapeRegex');\n\nconst Contain = require('@hapi/hoek/lib/contain');\n\nconst Any = require('../any');\n\nconst Common = require('../../common');\n\nconst Ip = require('./ip');\n\nconst Uri = require('./uri');\n\nconst internals = {\n base64Regex: {\n // paddingRequired\n true: {\n // urlSafe\n true: /^(?:[\\w\\-]{2}[\\w\\-]{2})*(?:[\\w\\-]{2}==|[\\w\\-]{3}=)?$/,\n false: /^(?:[A-Za-z0-9+\\/]{2}[A-Za-z0-9+\\/]{2})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/\n },\n false: {\n true: /^(?:[\\w\\-]{2}[\\w\\-]{2})*(?:[\\w\\-]{2}(==)?|[\\w\\-]{3}=?)?$/,\n false: /^(?:[A-Za-z0-9+\\/]{2}[A-Za-z0-9+\\/]{2})*(?:[A-Za-z0-9+\\/]{2}(==)?|[A-Za-z0-9+\\/]{3}=?)?$/\n }\n },\n dataUriRegex: {\n format: /^data:[\\w+.-]+\\/[\\w+.-]+;((charset=[\\w-]+|base64),)?(.*)$/,\n base64: {\n // paddingRequired\n true: /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/,\n false: /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}(==)?|[A-Za-z0-9+\\/]{3}=?)?$/\n }\n },\n hexRegex: /^[a-f0-9]+$/i,\n hostRegex: /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$/,\n ipRegex: Ip.createIpRegex(['ipv4', 'ipv6', 'ipvfuture'], 'optional'),\n isoDurationRegex: /^P(?!$)(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?$/,\n guidBrackets: {\n '{': '}',\n '[': ']',\n '(': ')',\n '': ''\n },\n guidVersions: {\n uuidv1: '1',\n uuidv2: '2',\n uuidv3: '3',\n uuidv4: '4',\n uuidv5: '5'\n },\n cidrPresences: ['required', 'optional', 'forbidden'],\n normalizationForms: ['NFC', 'NFD', 'NFKC', 'NFKD']\n};\nmodule.exports = Any.extend({\n type: 'string',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.replacements = null;\n },\n // Coerce\n coerce: {\n from: 'string',\n method: function method(schema, value, _ref) {\n let {\n state,\n prefs\n } = _ref;\n const normalize = schema.$_getRule('normalize');\n\n if (normalize) {\n value = value.normalize(normalize.args.form);\n }\n\n const casing = schema.$_getRule('case');\n\n if (casing) {\n value = casing.args.direction === 'upper' ? value.toLocaleUpperCase() : value.toLocaleLowerCase();\n }\n\n const trim = schema.$_getRule('trim');\n\n if (trim && trim.args.enabled) {\n value = value.trim();\n }\n\n if (schema.$_terms.replacements) {\n for (const replacement of schema.$_terms.replacements) {\n value = value.replace(replacement.pattern, replacement.replacement);\n }\n }\n\n const hex = schema.$_getRule('hex');\n\n if (hex && hex.args.options.byteAligned && value.length % 2 !== 0) {\n value = \"0\".concat(value);\n }\n\n if (schema.$_getRule('isoDate')) {\n let valid = false;\n\n if (Common.isIsoDate(value)) {\n const date = new Date(value);\n\n if (!isNaN(date.getTime())) {\n value = date.toISOString();\n valid = true;\n }\n }\n\n if (!valid) {\n return {\n value,\n errors: schema.$_createError('string.isoDate', value, null, state, prefs)\n };\n }\n }\n\n if (schema._flags.truncate) {\n const rule = schema.$_getRule('max');\n\n if (rule) {\n let limit = rule.args.limit;\n\n if (Common.isResolvable(limit)) {\n limit = limit.resolve(value, state, prefs);\n\n if (!Common.limit(limit)) {\n return {\n value,\n errors: schema.$_createError('any.ref', limit, {\n ref: rule.args.limit,\n arg: 'limit',\n reason: 'must be a positive integer'\n }, state, prefs)\n };\n }\n }\n\n value = value.slice(0, limit);\n }\n }\n\n return {\n value\n };\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n let {\n error\n } = _ref2;\n\n if (typeof value !== 'string') {\n return {\n value,\n errors: error('string.base')\n };\n }\n\n if (value === '') {\n return {\n value,\n errors: error('string.empty')\n };\n }\n },\n // Rules\n rules: {\n alphanum: {\n method: function method() {\n return this.$_addRule('alphanum');\n },\n validate: function validate(value, helpers) {\n if (/^[a-zA-Z0-9]+$/.test(value)) {\n return value;\n }\n\n return helpers.error('string.alphanum');\n }\n },\n base64: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['paddingRequired', 'urlSafe']);\n options = _objectSpread({\n urlSafe: false,\n paddingRequired: true\n }, options);\n Assert(typeof options.paddingRequired === 'boolean', 'paddingRequired must be boolean');\n Assert(typeof options.urlSafe === 'boolean', 'urlSafe must be boolean');\n return this.$_addRule({\n name: 'base64',\n args: {\n options\n }\n });\n },\n validate: function validate(value, helpers, _ref3) {\n let {\n options\n } = _ref3;\n const regex = internals.base64Regex[options.paddingRequired][options.urlSafe];\n\n if (regex.test(value)) {\n return value;\n }\n\n return helpers.error('string.base64');\n }\n },\n case: {\n method: function method(direction) {\n Assert(['lower', 'upper'].includes(direction), 'Invalid case:', direction);\n return this.$_addRule({\n name: 'case',\n args: {\n direction\n }\n });\n },\n validate: function validate(value, helpers, _ref4) {\n let {\n direction\n } = _ref4;\n\n if (direction === 'lower' && value === value.toLocaleLowerCase() || direction === 'upper' && value === value.toLocaleUpperCase()) {\n return value;\n }\n\n return helpers.error(\"string.\".concat(direction, \"case\"));\n },\n convert: true\n },\n creditCard: {\n method: function method() {\n return this.$_addRule('creditCard');\n },\n validate: function validate(value, helpers) {\n let i = value.length;\n let sum = 0;\n let mul = 1;\n\n while (i--) {\n const char = value.charAt(i) * mul;\n sum = sum + (char - (char > 9) * 9);\n mul = mul ^ 3;\n }\n\n if (sum > 0 && sum % 10 === 0) {\n return value;\n }\n\n return helpers.error('string.creditCard');\n }\n },\n dataUri: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['paddingRequired']);\n options = _objectSpread({\n paddingRequired: true\n }, options);\n Assert(typeof options.paddingRequired === 'boolean', 'paddingRequired must be boolean');\n return this.$_addRule({\n name: 'dataUri',\n args: {\n options\n }\n });\n },\n validate: function validate(value, helpers, _ref5) {\n let {\n options\n } = _ref5;\n const matches = value.match(internals.dataUriRegex.format);\n\n if (matches) {\n if (!matches[2]) {\n return value;\n }\n\n if (matches[2] !== 'base64') {\n return value;\n }\n\n const base64regex = internals.dataUriRegex.base64[options.paddingRequired];\n\n if (base64regex.test(matches[3])) {\n return value;\n }\n }\n\n return helpers.error('string.dataUri');\n }\n },\n domain: {\n method: function method(options) {\n if (options) {\n Common.assertOptions(options, ['allowUnicode', 'minDomainSegments', 'tlds']);\n options = internals.addressOptions(options);\n }\n\n return this.$_addRule({\n name: 'domain',\n args: {\n options\n }\n });\n },\n validate: function validate(value, helpers, _ref6) {\n let {\n options\n } = _ref6;\n\n if (Address.domain.isValid(value, options)) {\n return value;\n }\n\n return helpers.error('string.domain');\n }\n },\n email: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['allowUnicode', 'minDomainSegments', 'multiple', 'separator', 'tlds']);\n Assert(options.multiple === undefined || typeof options.multiple === 'boolean', 'multiple option must be an boolean');\n options = internals.addressOptions(options);\n const regex = new RegExp(\"\\\\s*[\".concat(options.separator ? EscapeRegex(options.separator) : ',', \"]\\\\s*\"));\n return this.$_addRule({\n name: 'email',\n args: {\n options\n },\n regex\n });\n },\n validate: function validate(value, helpers, _ref7, _ref8) {\n let {\n options\n } = _ref7;\n let {\n regex\n } = _ref8;\n const emails = options.multiple ? value.split(regex) : [value];\n const invalids = [];\n\n for (const email of emails) {\n if (!Address.email.isValid(email, options)) {\n invalids.push(email);\n }\n }\n\n if (!invalids.length) {\n return value;\n }\n\n return helpers.error('string.email', {\n value,\n invalids\n });\n }\n },\n guid: {\n alias: 'uuid',\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['version']);\n let versionNumbers = '';\n\n if (options.version) {\n const versions = [].concat(options.version);\n Assert(versions.length >= 1, 'version must have at least 1 valid version specified');\n const set = new Set();\n\n for (let i = 0; i < versions.length; ++i) {\n const version = versions[i];\n Assert(typeof version === 'string', 'version at position ' + i + ' must be a string');\n const versionNumber = internals.guidVersions[version.toLowerCase()];\n Assert(versionNumber, 'version at position ' + i + ' must be one of ' + Object.keys(internals.guidVersions).join(', '));\n Assert(!set.has(versionNumber), 'version at position ' + i + ' must not be a duplicate');\n versionNumbers += versionNumber;\n set.add(versionNumber);\n }\n }\n\n const regex = new RegExp(\"^([\\\\[{\\\\(]?)[0-9A-F]{8}([:-]?)[0-9A-F]{4}\\\\2?[\".concat(versionNumbers || '0-9A-F', \"][0-9A-F]{3}\\\\2?[\").concat(versionNumbers ? '89AB' : '0-9A-F', \"][0-9A-F]{3}\\\\2?[0-9A-F]{12}([\\\\]}\\\\)]?)$\"), 'i');\n return this.$_addRule({\n name: 'guid',\n args: {\n options\n },\n regex\n });\n },\n validate: function validate(value, helpers, args, _ref9) {\n let {\n regex\n } = _ref9;\n const results = regex.exec(value);\n\n if (!results) {\n return helpers.error('string.guid');\n } // Matching braces\n\n\n if (internals.guidBrackets[results[1]] !== results[results.length - 1]) {\n return helpers.error('string.guid');\n }\n\n return value;\n }\n },\n hex: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['byteAligned']);\n options = _objectSpread({\n byteAligned: false\n }, options);\n Assert(typeof options.byteAligned === 'boolean', 'byteAligned must be boolean');\n return this.$_addRule({\n name: 'hex',\n args: {\n options\n }\n });\n },\n validate: function validate(value, helpers, _ref10) {\n let {\n options\n } = _ref10;\n\n if (!internals.hexRegex.test(value)) {\n return helpers.error('string.hex');\n }\n\n if (options.byteAligned && value.length % 2 !== 0) {\n return helpers.error('string.hexAlign');\n }\n\n return value;\n }\n },\n hostname: {\n method: function method() {\n return this.$_addRule('hostname');\n },\n validate: function validate(value, helpers) {\n if (value.length <= 255 && internals.hostRegex.test(value) || internals.ipRegex.test(value)) {\n return value;\n }\n\n return helpers.error('string.hostname');\n }\n },\n insensitive: {\n method: function method() {\n return this.$_setFlag('insensitive', true);\n }\n },\n ip: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['cidr', 'version']);\n options = Object.assign({}, options); // Shallow cloned\n\n let regex = internals.ipRegex;\n\n if (options.cidr) {\n Assert(typeof options.cidr === 'string', 'cidr must be a string');\n options.cidr = options.cidr.toLowerCase();\n Assert(Contain(internals.cidrPresences, options.cidr), 'cidr must be one of ' + internals.cidrPresences.join(', '));\n\n if (!options.version && options.cidr !== 'optional') {\n regex = Ip.createIpRegex(['ipv4', 'ipv6', 'ipvfuture'], options.cidr);\n }\n } else {\n options.cidr = 'optional';\n }\n\n let versions;\n\n if (options.version) {\n if (!Array.isArray(options.version)) {\n options.version = [options.version];\n }\n\n Assert(options.version.length >= 1, 'version must have at least 1 version specified');\n versions = [];\n\n for (let i = 0; i < options.version.length; ++i) {\n let version = options.version[i];\n Assert(typeof version === 'string', 'version at position ' + i + ' must be a string');\n version = version.toLowerCase();\n Assert(Ip.versions[version], 'version at position ' + i + ' must be one of ' + Object.keys(Ip.versions).join(', '));\n versions.push(version);\n }\n\n versions = Array.from(new Set(versions));\n regex = Ip.createIpRegex(versions, options.cidr);\n }\n\n return this.$_addRule({\n name: 'ip',\n args: {\n options\n },\n versions,\n regex\n });\n },\n validate: function validate(value, helpers, _ref11, _ref12) {\n let {\n options\n } = _ref11;\n let {\n versions,\n regex\n } = _ref12;\n\n if (regex.test(value)) {\n return value;\n }\n\n if (versions) {\n return helpers.error('string.ipVersion', {\n value,\n cidr: options.cidr,\n version: versions\n });\n }\n\n return helpers.error('string.ip', {\n value,\n cidr: options.cidr\n });\n }\n },\n isoDate: {\n method: function method() {\n return this.$_addRule('isoDate');\n },\n validate: function validate(value, _ref13) {\n let {\n error\n } = _ref13;\n\n if (Common.isIsoDate(value)) {\n return value;\n }\n\n return error('string.isoDate');\n },\n convert: true\n },\n isoDuration: {\n method: function method() {\n return this.$_addRule('isoDuration');\n },\n validate: function validate(value, helpers) {\n if (internals.isoDurationRegex.test(value)) {\n return value;\n }\n\n return helpers.error('string.isoDuration');\n }\n },\n length: {\n method: function method(limit, encoding) {\n return internals.length(this, 'length', limit, '=', encoding);\n },\n validate: function validate(value, helpers, _ref14, _ref15) {\n let {\n limit,\n encoding\n } = _ref14;\n let {\n name,\n operator,\n args\n } = _ref15;\n const length = encoding ? Buffer && Buffer.byteLength(value, encoding) : value.length; // $lab:coverage:ignore$\n\n if (Common.compare(length, limit, operator)) {\n return value;\n }\n\n return helpers.error('string.' + name, {\n limit: args.limit,\n value,\n encoding\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.limit,\n message: 'must be a positive integer'\n }, 'encoding']\n },\n lowercase: {\n method: function method() {\n return this.case('lower');\n }\n },\n max: {\n method: function method(limit, encoding) {\n return internals.length(this, 'max', limit, '<=', encoding);\n },\n args: ['limit', 'encoding']\n },\n min: {\n method: function method(limit, encoding) {\n return internals.length(this, 'min', limit, '>=', encoding);\n },\n args: ['limit', 'encoding']\n },\n normalize: {\n method: function method() {\n let form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'NFC';\n Assert(Contain(internals.normalizationForms, form), 'normalization form must be one of ' + internals.normalizationForms.join(', '));\n return this.$_addRule({\n name: 'normalize',\n args: {\n form\n }\n });\n },\n validate: function validate(value, _ref16, _ref17) {\n let {\n error\n } = _ref16;\n let {\n form\n } = _ref17;\n\n if (value === value.normalize(form)) {\n return value;\n }\n\n return error('string.normalize', {\n value,\n form\n });\n },\n convert: true\n },\n pattern: {\n alias: 'regex',\n method: function method(regex) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(regex instanceof RegExp, 'regex must be a RegExp');\n Assert(!regex.flags.includes('g') && !regex.flags.includes('y'), 'regex should not use global or sticky mode');\n\n if (typeof options === 'string') {\n options = {\n name: options\n };\n }\n\n Common.assertOptions(options, ['invert', 'name']);\n const errorCode = ['string.pattern', options.invert ? '.invert' : '', options.name ? '.name' : '.base'].join('');\n return this.$_addRule({\n name: 'pattern',\n args: {\n regex,\n options\n },\n errorCode\n });\n },\n validate: function validate(value, helpers, _ref18, _ref19) {\n let {\n regex,\n options\n } = _ref18;\n let {\n errorCode\n } = _ref19;\n const patternMatch = regex.test(value);\n\n if (patternMatch ^ options.invert) {\n return value;\n }\n\n return helpers.error(errorCode, {\n name: options.name,\n regex,\n value\n });\n },\n args: ['regex', 'options'],\n multi: true\n },\n replace: {\n method: function method(pattern, replacement) {\n if (typeof pattern === 'string') {\n pattern = new RegExp(EscapeRegex(pattern), 'g');\n }\n\n Assert(pattern instanceof RegExp, 'pattern must be a RegExp');\n Assert(typeof replacement === 'string', 'replacement must be a String');\n const obj = this.clone();\n\n if (!obj.$_terms.replacements) {\n obj.$_terms.replacements = [];\n }\n\n obj.$_terms.replacements.push({\n pattern,\n replacement\n });\n return obj;\n }\n },\n token: {\n method: function method() {\n return this.$_addRule('token');\n },\n validate: function validate(value, helpers) {\n if (/^\\w+$/.test(value)) {\n return value;\n }\n\n return helpers.error('string.token');\n }\n },\n trim: {\n method: function method() {\n let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof enabled === 'boolean', 'enabled must be a boolean');\n return this.$_addRule({\n name: 'trim',\n args: {\n enabled\n }\n });\n },\n validate: function validate(value, helpers, _ref20) {\n let {\n enabled\n } = _ref20;\n\n if (!enabled || value === value.trim()) {\n return value;\n }\n\n return helpers.error('string.trim');\n },\n convert: true\n },\n truncate: {\n method: function method() {\n let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof enabled === 'boolean', 'enabled must be a boolean');\n return this.$_setFlag('truncate', enabled);\n }\n },\n uppercase: {\n method: function method() {\n return this.case('upper');\n }\n },\n uri: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['allowRelative', 'allowQuerySquareBrackets', 'domain', 'relativeOnly', 'scheme']);\n const unknownOptions = Object.keys(options).filter(key => !['scheme', 'allowRelative', 'relativeOnly', 'allowQuerySquareBrackets', 'domain'].includes(key));\n Assert(unknownOptions.length === 0, \"options contain unknown keys: \".concat(unknownOptions));\n\n if (options.domain) {\n options = Object.assign({}, options); // Shallow cloned\n\n options.domain = internals.addressOptions(options.domain);\n }\n\n const regex = Uri.createRegex(options);\n return this.$_addRule({\n name: 'uri',\n args: {\n options\n },\n regex\n });\n },\n validate: function validate(value, helpers, _ref21, _ref22) {\n let {\n options\n } = _ref21;\n let {\n regex\n } = _ref22;\n\n if (['http:/', 'https:/'].includes(value)) {\n // scheme:/ is technically valid but makes no sense\n return helpers.error('string.uri');\n }\n\n const match = regex.exec(value);\n\n if (match) {\n if (options.domain && !Address.domain.isValid(match[1], options.domain)) {\n return helpers.error('string.domain', {\n value: match[1]\n });\n }\n\n return value;\n }\n\n if (options.relativeOnly) {\n return helpers.error('string.uriRelativeOnly');\n }\n\n if (options.scheme) {\n return helpers.error('string.uriCustomScheme', {\n scheme: regex.scheme,\n value\n });\n }\n\n return helpers.error('string.uri');\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n for (const _ref23 of desc.replacements) {\n const {\n pattern,\n replacement\n } = _ref23;\n obj = obj.replace(pattern, replacement);\n }\n\n return obj;\n },\n // Errors\n messages: {\n 'string.alphanum': '\"{{#label}}\" must only contain alpha-numeric characters',\n 'string.base': '\"{{#label}}\" must be a string',\n 'string.base64': '\"{{#label}}\" must be a valid base64 string',\n 'string.creditCard': '\"{{#label}}\" must be a credit card',\n 'string.dataUri': '\"{{#label}}\" must be a valid dataUri string',\n 'string.domain': '\"{{#label}}\" must contain a valid domain name',\n 'string.email': '\"{{#label}}\" must be a valid email',\n 'string.empty': '\"{{#label}}\" is not allowed to be empty',\n 'string.guid': '\"{{#label}}\" must be a valid GUID',\n 'string.hex': '\"{{#label}}\" must only contain hexadecimal characters',\n 'string.hexAlign': '\"{{#label}}\" hex decoded representation must be byte aligned',\n 'string.hostname': '\"{{#label}}\" must be a valid hostname',\n 'string.ip': '\"{{#label}}\" must be a valid ip address with a {{#cidr}} CIDR',\n 'string.ipVersion': '\"{{#label}}\" must be a valid ip address of one of the following versions {{#version}} with a {{#cidr}} CIDR',\n 'string.isoDate': '\"{{#label}}\" must be a valid ISO 8601 date',\n 'string.isoDuration': '\"{{#label}}\" must be a valid ISO 8601 duration',\n 'string.length': '\"{{#label}}\" length must be {{#limit}} characters long',\n 'string.lowercase': '\"{{#label}}\" must only contain lowercase characters',\n 'string.max': '\"{{#label}}\" length must be less than or equal to {{#limit}} characters long',\n 'string.min': '\"{{#label}}\" length must be at least {{#limit}} characters long',\n 'string.normalize': '\"{{#label}}\" must be unicode normalized in the {{#form}} form',\n 'string.token': '\"{{#label}}\" must only contain alpha-numeric and underscore characters',\n 'string.pattern.base': '\"{{#label}}\" with value \"{[.]}\" fails to match the required pattern: {{#regex}}',\n 'string.pattern.name': '\"{{#label}}\" with value \"{[.]}\" fails to match the {{#name}} pattern',\n 'string.pattern.invert.base': '\"{{#label}}\" with value \"{[.]}\" matches the inverted pattern: {{#regex}}',\n 'string.pattern.invert.name': '\"{{#label}}\" with value \"{[.]}\" matches the inverted {{#name}} pattern',\n 'string.trim': '\"{{#label}}\" must not have leading or trailing whitespace',\n 'string.uri': '\"{{#label}}\" must be a valid uri',\n 'string.uriCustomScheme': '\"{{#label}}\" must be a valid uri with a scheme matching the {{#scheme}} pattern',\n 'string.uriRelativeOnly': '\"{{#label}}\" must be a valid relative uri',\n 'string.uppercase': '\"{{#label}}\" must only contain uppercase characters'\n }\n}); // Helpers\n\ninternals.addressOptions = function (options) {\n if (options.tlds && typeof options.tlds === 'object') {\n Assert(options.tlds.allow === undefined || options.tlds.allow === false || options.tlds.allow === true || Array.isArray(options.tlds.allow) || options.tlds.allow instanceof Set, 'tlds.allow must be an array, Set, or boolean');\n Assert(options.tlds.deny === undefined || Array.isArray(options.tlds.deny) || options.tlds.deny instanceof Set, 'tlds.deny must be an array or Set');\n\n const normalizeTable = table => {\n if (table === undefined || typeof table === 'boolean' || table instanceof Set) {\n return table;\n }\n\n return new Set(table);\n };\n\n options = Object.assign({}, options); // Shallow cloned\n\n options.tlds = {\n allow: normalizeTable(options.tlds.allow),\n deny: normalizeTable(options.tlds.deny)\n };\n }\n\n Assert(options.minDomainSegments === undefined || Number.isSafeInteger(options.minDomainSegments) && options.minDomainSegments > 0, 'minDomainSegments must be a positive integer');\n return options;\n};\n\ninternals.length = function (schema, name, limit, operator, encoding) {\n Assert(!encoding || Buffer && Buffer.isEncoding(encoding), 'Invalid encoding:', encoding); // $lab:coverage:ignore$\n\n return schema.$_addRule({\n name,\n method: 'length',\n args: {\n limit,\n encoding\n },\n operator\n });\n};" }, { - "id": 44, + "id": 43, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "name": "../node_modules/@hapi/address/lib/index.js", "index": 41, - "index2": 45, - "size": 7870, + "index2": 44, + "size": 6236, "cacheable": true, "built": true, "optional": false, @@ -3886,7 +3793,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", - "issuerId": 43, + "issuerId": 42, "issuerName": "../lib/types/string/index.js", "issuerPath": [ { @@ -3894,25 +3801,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 }, "failed": false, "errors": 0, @@ -3920,13 +3827,13 @@ "assets": [], "reasons": [ { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "@hapi/address", - "loc": "11:14-38" + "loc": "9:16-40" } ], "usedExports": true, @@ -3935,15 +3842,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Punycode = require('punycode');\n\nvar Abnf = require('./abnf');\n\nvar Tlds = require('./tlds');\n\nvar internals = {\n nonAsciiRx: /[^\\x00-\\x7f]/,\n minDomainSegments: 2,\n defaultTlds: {\n allow: Tlds,\n deny: null\n }\n};\nmodule.exports = {\n email: {\n analyze: function analyze(email, options) {\n return internals.email(email, options);\n },\n isValid: function isValid(email, options) {\n return !internals.email(email, options);\n }\n },\n domain: {\n analyze: function analyze(domain) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n internals.options(domain, options);\n\n if (!domain) {\n return internals.error('Domain must be a non-empty string');\n }\n\n if (domain.length > 256) {\n return internals.error('Domain too long');\n }\n\n var ascii = !internals.nonAsciiRx.test(domain);\n\n if (!ascii) {\n if (options.allowUnicode === false) {\n // Defaults to true\n return internals.error('Domain contains forbidden Unicode characters');\n }\n\n var normalized = domain.normalize('NFC');\n domain = Punycode.toASCII(normalized);\n }\n\n return internals.domain(domain, options);\n },\n isValid: function isValid(domain, options) {\n return !module.exports.domain.analyze(domain, options);\n }\n }\n};\n\ninternals.email = function (email) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n internals.options(email, options);\n\n if (!email) {\n return internals.error('Address must be a non-empty string');\n } // Unicode\n\n\n var ascii = !internals.nonAsciiRx.test(email);\n\n if (!ascii) {\n if (options.allowUnicode === false) {\n // Defaults to true\n return internals.error('Address contains forbidden Unicode characters');\n }\n\n var normalized = email.normalize('NFC');\n email = Punycode.toASCII(normalized);\n } // Basic structure\n\n\n var parts = email.split('@');\n\n if (parts.length !== 2) {\n return internals.error(parts.length > 2 ? 'Address cannot contain more than one @ character' : 'Address must contain one @ character');\n }\n\n var local = parts[0];\n var domain = parts[1];\n\n if (!local) {\n return internals.error('Address local part cannot be empty');\n }\n\n if (!domain) {\n return internals.error('Domain cannot be empty');\n }\n\n if (email.length > 254) {\n // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.3\n return internals.error('Address too long');\n }\n\n if (Buffer.byteLength(local, 'utf-8') > 64) {\n // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.1\n return internals.error('Address local part too long');\n } // Validate parts\n\n\n return internals.local(local, ascii) || internals.domain(domain, options);\n};\n\ninternals.options = function (value, options) {\n // Options validation\n if (options.tlds && options.tlds !== true) {\n if (_typeof(options.tlds) !== 'object') {\n throw new Error('Invalid options: tlds must be a boolean or an object');\n }\n\n if (options.tlds.allow !== undefined && options.tlds.allow !== true && options.tlds.allow instanceof Set === false) {\n throw new Error('Invalid options: tlds.allow must be a Set object or true');\n }\n\n if (options.tlds.deny) {\n if (options.tlds.deny instanceof Set === false) {\n throw new Error('Invalid options: tlds.deny must be a Set object');\n }\n\n if (options.tlds.allow instanceof Set) {\n throw new Error('Invalid options: cannot specify both tlds.allow and tlds.deny lists');\n }\n }\n } // Input validation\n\n\n if (typeof value !== 'string') {\n throw new Error('Invalid input: value must be a string');\n }\n};\n\ninternals.local = function (local, ascii) {\n var segments = local.split('.');\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = segments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var segment = _step.value;\n\n if (!segment.length) {\n return internals.error('Address local part contains empty dot-separated segment');\n }\n\n if (ascii) {\n if (!Abnf.atextRx.test(segment)) {\n return internals.error('Address local part contains invalid character');\n }\n } else {\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = segment[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var char = _step2.value;\n var binary = Buffer.from(char).toString('binary');\n\n if (!Abnf.atomRx.test(binary)) {\n return internals.error('Address local part contains invalid character');\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n};\n\ninternals.tldSegmentRx = /^[a-zA-Z](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?$/;\ninternals.domainSegmentRx = /^[a-zA-Z0-9](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?$/;\n\ninternals.domain = function (domain, options) {\n // https://tools.ietf.org/html/rfc1035 section 2.3.1\n var minDomainSegments = options.minDomainSegments || internals.minDomainSegments;\n var segments = domain.split('.');\n\n if (segments.length < minDomainSegments) {\n return internals.error('Domain lacks the minimum required number of segments');\n }\n\n var tlds = internals.tlds(options);\n\n if (tlds) {\n var tld = segments[segments.length - 1].toLowerCase();\n\n if (tlds.deny && tlds.deny.has(tld) || tlds.allow && !tlds.allow.has(tld)) {\n return internals.error('Domain uses forbidden TLD');\n }\n }\n\n for (var i = 0; i < segments.length; ++i) {\n var segment = segments[i];\n\n if (!segment.length) {\n return internals.error('Domain contains empty dot-separated segment');\n }\n\n if (segment.length > 63) {\n return internals.error('Domain contains dot-separated segment that is too long');\n }\n\n if (i < segments.length - 1) {\n if (!internals.domainSegmentRx.test(segment)) {\n return internals.error('Domain contains invalid character');\n }\n } else {\n if (!internals.tldSegmentRx.test(segment)) {\n return internals.error('Domain contains invalid tld character');\n }\n }\n }\n};\n\ninternals.tlds = function (options) {\n if (options.tlds === false) {\n // Defaults to true\n return null;\n }\n\n if (!options.tlds || options.tlds === true) {\n return internals.defaultTlds;\n }\n\n return {\n allow: options.tlds.allow === true ? null : options.tlds.allow || Tlds,\n deny: options.tlds.deny || null\n };\n};\n\ninternals.error = function (reason) {\n return {\n error: reason\n };\n};" + "source": "'use strict';\n\nconst Punycode = require('punycode');\n\nconst Abnf = require('./abnf');\n\nconst Tlds = require('./tlds');\n\nconst internals = {\n nonAsciiRx: /[^\\x00-\\x7f]/,\n minDomainSegments: 2,\n defaultTlds: {\n allow: Tlds,\n deny: null\n }\n};\nmodule.exports = {\n email: {\n analyze: function analyze(email, options) {\n return internals.email(email, options);\n },\n isValid: function isValid(email, options) {\n return !internals.email(email, options);\n }\n },\n domain: {\n analyze: function analyze(domain) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n internals.options(domain, options);\n\n if (!domain) {\n return internals.error('Domain must be a non-empty string');\n }\n\n if (domain.length > 256) {\n return internals.error('Domain too long');\n }\n\n const ascii = !internals.nonAsciiRx.test(domain);\n\n if (!ascii) {\n if (options.allowUnicode === false) {\n // Defaults to true\n return internals.error('Domain contains forbidden Unicode characters');\n }\n\n const normalized = domain.normalize('NFC');\n domain = Punycode.toASCII(normalized);\n }\n\n return internals.domain(domain, options);\n },\n isValid: function isValid(domain, options) {\n return !module.exports.domain.analyze(domain, options);\n }\n }\n};\n\ninternals.email = function (email) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n internals.options(email, options);\n\n if (!email) {\n return internals.error('Address must be a non-empty string');\n } // Unicode\n\n\n const ascii = !internals.nonAsciiRx.test(email);\n\n if (!ascii) {\n if (options.allowUnicode === false) {\n // Defaults to true\n return internals.error('Address contains forbidden Unicode characters');\n }\n\n const normalized = email.normalize('NFC');\n email = Punycode.toASCII(normalized);\n } // Basic structure\n\n\n const parts = email.split('@');\n\n if (parts.length !== 2) {\n return internals.error(parts.length > 2 ? 'Address cannot contain more than one @ character' : 'Address must contain one @ character');\n }\n\n const local = parts[0];\n const domain = parts[1];\n\n if (!local) {\n return internals.error('Address local part cannot be empty');\n }\n\n if (!domain) {\n return internals.error('Domain cannot be empty');\n }\n\n if (email.length > 254) {\n // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.3\n return internals.error('Address too long');\n }\n\n if (Buffer.byteLength(local, 'utf-8') > 64) {\n // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.1\n return internals.error('Address local part too long');\n } // Validate parts\n\n\n return internals.local(local, ascii) || internals.domain(domain, options);\n};\n\ninternals.options = function (value, options) {\n // Options validation\n if (options.tlds && options.tlds !== true) {\n if (typeof options.tlds !== 'object') {\n throw new Error('Invalid options: tlds must be a boolean or an object');\n }\n\n if (options.tlds.allow !== undefined && options.tlds.allow !== true && options.tlds.allow instanceof Set === false) {\n throw new Error('Invalid options: tlds.allow must be a Set object or true');\n }\n\n if (options.tlds.deny) {\n if (options.tlds.deny instanceof Set === false) {\n throw new Error('Invalid options: tlds.deny must be a Set object');\n }\n\n if (options.tlds.allow instanceof Set) {\n throw new Error('Invalid options: cannot specify both tlds.allow and tlds.deny lists');\n }\n }\n } // Input validation\n\n\n if (typeof value !== 'string') {\n throw new Error('Invalid input: value must be a string');\n }\n};\n\ninternals.local = function (local, ascii) {\n const segments = local.split('.');\n\n for (const segment of segments) {\n if (!segment.length) {\n return internals.error('Address local part contains empty dot-separated segment');\n }\n\n if (ascii) {\n if (!Abnf.atextRx.test(segment)) {\n return internals.error('Address local part contains invalid character');\n }\n } else {\n for (const char of segment) {\n const binary = Buffer.from(char).toString('binary');\n\n if (!Abnf.atomRx.test(binary)) {\n return internals.error('Address local part contains invalid character');\n }\n }\n }\n }\n};\n\ninternals.tldSegmentRx = /^[a-zA-Z](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?$/;\ninternals.domainSegmentRx = /^[a-zA-Z0-9](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?$/;\n\ninternals.domain = function (domain, options) {\n // https://tools.ietf.org/html/rfc1035 section 2.3.1\n const minDomainSegments = options.minDomainSegments || internals.minDomainSegments;\n const segments = domain.split('.');\n\n if (segments.length < minDomainSegments) {\n return internals.error('Domain lacks the minimum required number of segments');\n }\n\n const tlds = internals.tlds(options);\n\n if (tlds) {\n const tld = segments[segments.length - 1].toLowerCase();\n\n if (tlds.deny && tlds.deny.has(tld) || tlds.allow && !tlds.allow.has(tld)) {\n return internals.error('Domain uses forbidden TLD');\n }\n }\n\n for (let i = 0; i < segments.length; ++i) {\n const segment = segments[i];\n\n if (!segment.length) {\n return internals.error('Domain contains empty dot-separated segment');\n }\n\n if (segment.length > 63) {\n return internals.error('Domain contains dot-separated segment that is too long');\n }\n\n if (i < segments.length - 1) {\n if (!internals.domainSegmentRx.test(segment)) {\n return internals.error('Domain contains invalid character');\n }\n } else {\n if (!internals.tldSegmentRx.test(segment)) {\n return internals.error('Domain contains invalid tld character');\n }\n }\n }\n};\n\ninternals.tlds = function (options) {\n if (options.tlds === false) {\n // Defaults to true\n return null;\n }\n\n if (!options.tlds || options.tlds === true) {\n return internals.defaultTlds;\n }\n\n return {\n allow: options.tlds.allow === true ? null : options.tlds.allow || Tlds,\n deny: options.tlds.deny || null\n };\n};\n\ninternals.error = function (reason) {\n return {\n error: reason\n };\n};" }, { - "id": 45, + "id": 44, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", "name": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "index": 42, - "index2": 42, - "size": 16159, + "index2": 41, + "size": 15653, "cacheable": true, "built": true, "optional": false, @@ -3952,7 +3859,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", - "issuerId": 44, + "issuerId": 43, "issuerName": "../node_modules/@hapi/address/lib/index.js", "issuerPath": [ { @@ -3960,34 +3867,34 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 44, + "id": 43, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "name": "../node_modules/@hapi/address/lib/index.js", "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 } } ], "profile": { - "factory": 4, - "building": 95 + "factory": 3, + "building": 94 }, "failed": false, "errors": 0, @@ -3995,13 +3902,13 @@ "assets": [], "reasons": [ { - "moduleId": 44, + "moduleId": 43, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "module": "../node_modules/@hapi/address/lib/index.js", "moduleName": "../node_modules/@hapi/address/lib/index.js", "type": "cjs require", "userRequest": "punycode", - "loc": "5:15-34" + "loc": "3:17-36" } ], "usedExports": true, @@ -4010,10 +3917,10 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n/*! https://mths.be/punycode v1.4.1 by @mathias */\n;\n\n(function (root) {\n /** Detect free variables */\n var freeExports = (typeof exports === \"undefined\" ? \"undefined\" : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports;\n var freeModule = (typeof module === \"undefined\" ? \"undefined\" : _typeof(module)) == 'object' && module && !module.nodeType && module;\n var freeGlobal = (typeof global === \"undefined\" ? \"undefined\" : _typeof(global)) == 'object' && global;\n\n if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {\n root = freeGlobal;\n }\n /**\n * The `punycode` object.\n * @name punycode\n * @type Object\n */\n\n\n var punycode,\n\n /** Highest positive signed 32-bit float value */\n maxInt = 2147483647,\n // aka. 0x7FFFFFFF or 2^31-1\n\n /** Bootstring parameters */\n base = 36,\n tMin = 1,\n tMax = 26,\n skew = 38,\n damp = 700,\n initialBias = 72,\n initialN = 128,\n // 0x80\n delimiter = '-',\n // '\\x2D'\n\n /** Regular expressions */\n regexPunycode = /^xn--/,\n regexNonASCII = /[^\\x20-\\x7E]/,\n // unprintable ASCII chars + non-ASCII chars\n regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g,\n // RFC 3490 separators\n\n /** Error messages */\n errors = {\n 'overflow': 'Overflow: input needs wider integers to process',\n 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',\n 'invalid-input': 'Invalid input'\n },\n\n /** Convenience shortcuts */\n baseMinusTMin = base - tMin,\n floor = Math.floor,\n stringFromCharCode = String.fromCharCode,\n\n /** Temporary variable */\n key;\n /*--------------------------------------------------------------------------*/\n\n /**\n * A generic error utility function.\n * @private\n * @param {String} type The error type.\n * @returns {Error} Throws a `RangeError` with the applicable error message.\n */\n\n function error(type) {\n throw new RangeError(errors[type]);\n }\n /**\n * A generic `Array#map` utility function.\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} callback The function that gets called for every array\n * item.\n * @returns {Array} A new array of values returned by the callback function.\n */\n\n\n function map(array, fn) {\n var length = array.length;\n var result = [];\n\n while (length--) {\n result[length] = fn(array[length]);\n }\n\n return result;\n }\n /**\n * A simple `Array#map`-like wrapper to work with domain name strings or email\n * addresses.\n * @private\n * @param {String} domain The domain name or email address.\n * @param {Function} callback The function that gets called for every\n * character.\n * @returns {Array} A new string of characters returned by the callback\n * function.\n */\n\n\n function mapDomain(string, fn) {\n var parts = string.split('@');\n var result = '';\n\n if (parts.length > 1) {\n // In email addresses, only the domain name should be punycoded. Leave\n // the local part (i.e. everything up to `@`) intact.\n result = parts[0] + '@';\n string = parts[1];\n } // Avoid `split(regex)` for IE8 compatibility. See #17.\n\n\n string = string.replace(regexSeparators, '\\x2E');\n var labels = string.split('.');\n var encoded = map(labels, fn).join('.');\n return result + encoded;\n }\n /**\n * Creates an array containing the numeric code points of each Unicode\n * character in the string. While JavaScript uses UCS-2 internally,\n * this function will convert a pair of surrogate halves (each of which\n * UCS-2 exposes as separate characters) into a single code point,\n * matching UTF-16.\n * @see `punycode.ucs2.encode`\n * @see \n * @memberOf punycode.ucs2\n * @name decode\n * @param {String} string The Unicode input string (UCS-2).\n * @returns {Array} The new array of code points.\n */\n\n\n function ucs2decode(string) {\n var output = [],\n counter = 0,\n length = string.length,\n value,\n extra;\n\n while (counter < length) {\n value = string.charCodeAt(counter++);\n\n if (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n // high surrogate, and there is a next character\n extra = string.charCodeAt(counter++);\n\n if ((extra & 0xFC00) == 0xDC00) {\n // low surrogate\n output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n } else {\n // unmatched surrogate; only append this code unit, in case the next\n // code unit is the high surrogate of a surrogate pair\n output.push(value);\n counter--;\n }\n } else {\n output.push(value);\n }\n }\n\n return output;\n }\n /**\n * Creates a string based on an array of numeric code points.\n * @see `punycode.ucs2.decode`\n * @memberOf punycode.ucs2\n * @name encode\n * @param {Array} codePoints The array of numeric code points.\n * @returns {String} The new Unicode string (UCS-2).\n */\n\n\n function ucs2encode(array) {\n return map(array, function (value) {\n var output = '';\n\n if (value > 0xFFFF) {\n value -= 0x10000;\n output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);\n value = 0xDC00 | value & 0x3FF;\n }\n\n output += stringFromCharCode(value);\n return output;\n }).join('');\n }\n /**\n * Converts a basic code point into a digit/integer.\n * @see `digitToBasic()`\n * @private\n * @param {Number} codePoint The basic numeric code point value.\n * @returns {Number} The numeric value of a basic code point (for use in\n * representing integers) in the range `0` to `base - 1`, or `base` if\n * the code point does not represent a value.\n */\n\n\n function basicToDigit(codePoint) {\n if (codePoint - 48 < 10) {\n return codePoint - 22;\n }\n\n if (codePoint - 65 < 26) {\n return codePoint - 65;\n }\n\n if (codePoint - 97 < 26) {\n return codePoint - 97;\n }\n\n return base;\n }\n /**\n * Converts a digit/integer into a basic code point.\n * @see `basicToDigit()`\n * @private\n * @param {Number} digit The numeric value of a basic code point.\n * @returns {Number} The basic code point whose value (when used for\n * representing integers) is `digit`, which needs to be in the range\n * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is\n * used; else, the lowercase form is used. The behavior is undefined\n * if `flag` is non-zero and `digit` has no uppercase form.\n */\n\n\n function digitToBasic(digit, flag) {\n // 0..25 map to ASCII a..z or A..Z\n // 26..35 map to ASCII 0..9\n return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);\n }\n /**\n * Bias adaptation function as per section 3.4 of RFC 3492.\n * https://tools.ietf.org/html/rfc3492#section-3.4\n * @private\n */\n\n\n function adapt(delta, numPoints, firstTime) {\n var k = 0;\n delta = firstTime ? floor(delta / damp) : delta >> 1;\n delta += floor(delta / numPoints);\n\n for (;\n /* no initialization */\n delta > baseMinusTMin * tMax >> 1; k += base) {\n delta = floor(delta / baseMinusTMin);\n }\n\n return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n }\n /**\n * Converts a Punycode string of ASCII-only symbols to a string of Unicode\n * symbols.\n * @memberOf punycode\n * @param {String} input The Punycode string of ASCII-only symbols.\n * @returns {String} The resulting string of Unicode symbols.\n */\n\n\n function decode(input) {\n // Don't use UCS-2\n var output = [],\n inputLength = input.length,\n out,\n i = 0,\n n = initialN,\n bias = initialBias,\n basic,\n j,\n index,\n oldi,\n w,\n k,\n digit,\n t,\n\n /** Cached calculation results */\n baseMinusT; // Handle the basic code points: let `basic` be the number of input code\n // points before the last delimiter, or `0` if there is none, then copy\n // the first basic code points to the output.\n\n basic = input.lastIndexOf(delimiter);\n\n if (basic < 0) {\n basic = 0;\n }\n\n for (j = 0; j < basic; ++j) {\n // if it's not a basic code point\n if (input.charCodeAt(j) >= 0x80) {\n error('not-basic');\n }\n\n output.push(input.charCodeAt(j));\n } // Main decoding loop: start just after the last delimiter if any basic code\n // points were copied; start at the beginning otherwise.\n\n\n for (index = basic > 0 ? basic + 1 : 0; index < inputLength;)\n /* no final expression */\n {\n // `index` is the index of the next character to be consumed.\n // Decode a generalized variable-length integer into `delta`,\n // which gets added to `i`. The overflow checking is easier\n // if we increase `i` as we go, then subtract off its starting\n // value at the end to obtain `delta`.\n for (oldi = i, w = 1, k = base;;\n /* no condition */\n k += base) {\n if (index >= inputLength) {\n error('invalid-input');\n }\n\n digit = basicToDigit(input.charCodeAt(index++));\n\n if (digit >= base || digit > floor((maxInt - i) / w)) {\n error('overflow');\n }\n\n i += digit * w;\n t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n\n if (digit < t) {\n break;\n }\n\n baseMinusT = base - t;\n\n if (w > floor(maxInt / baseMinusT)) {\n error('overflow');\n }\n\n w *= baseMinusT;\n }\n\n out = output.length + 1;\n bias = adapt(i - oldi, out, oldi == 0); // `i` was supposed to wrap around from `out` to `0`,\n // incrementing `n` each time, so we'll fix that now:\n\n if (floor(i / out) > maxInt - n) {\n error('overflow');\n }\n\n n += floor(i / out);\n i %= out; // Insert `n` at position `i` of the output\n\n output.splice(i++, 0, n);\n }\n\n return ucs2encode(output);\n }\n /**\n * Converts a string of Unicode symbols (e.g. a domain name label) to a\n * Punycode string of ASCII-only symbols.\n * @memberOf punycode\n * @param {String} input The string of Unicode symbols.\n * @returns {String} The resulting Punycode string of ASCII-only symbols.\n */\n\n\n function encode(input) {\n var n,\n delta,\n handledCPCount,\n basicLength,\n bias,\n j,\n m,\n q,\n k,\n t,\n currentValue,\n output = [],\n\n /** `inputLength` will hold the number of code points in `input`. */\n inputLength,\n\n /** Cached calculation results */\n handledCPCountPlusOne,\n baseMinusT,\n qMinusT; // Convert the input in UCS-2 to Unicode\n\n input = ucs2decode(input); // Cache the length\n\n inputLength = input.length; // Initialize the state\n\n n = initialN;\n delta = 0;\n bias = initialBias; // Handle the basic code points\n\n for (j = 0; j < inputLength; ++j) {\n currentValue = input[j];\n\n if (currentValue < 0x80) {\n output.push(stringFromCharCode(currentValue));\n }\n }\n\n handledCPCount = basicLength = output.length; // `handledCPCount` is the number of code points that have been handled;\n // `basicLength` is the number of basic code points.\n // Finish the basic string - if it is not empty - with a delimiter\n\n if (basicLength) {\n output.push(delimiter);\n } // Main encoding loop:\n\n\n while (handledCPCount < inputLength) {\n // All non-basic code points < n have been handled already. Find the next\n // larger one:\n for (m = maxInt, j = 0; j < inputLength; ++j) {\n currentValue = input[j];\n\n if (currentValue >= n && currentValue < m) {\n m = currentValue;\n }\n } // Increase `delta` enough to advance the decoder's state to ,\n // but guard against overflow\n\n\n handledCPCountPlusOne = handledCPCount + 1;\n\n if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n error('overflow');\n }\n\n delta += (m - n) * handledCPCountPlusOne;\n n = m;\n\n for (j = 0; j < inputLength; ++j) {\n currentValue = input[j];\n\n if (currentValue < n && ++delta > maxInt) {\n error('overflow');\n }\n\n if (currentValue == n) {\n // Represent delta as a generalized variable-length integer\n for (q = delta, k = base;;\n /* no condition */\n k += base) {\n t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n\n if (q < t) {\n break;\n }\n\n qMinusT = q - t;\n baseMinusT = base - t;\n output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));\n q = floor(qMinusT / baseMinusT);\n }\n\n output.push(stringFromCharCode(digitToBasic(q, 0)));\n bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);\n delta = 0;\n ++handledCPCount;\n }\n }\n\n ++delta;\n ++n;\n }\n\n return output.join('');\n }\n /**\n * Converts a Punycode string representing a domain name or an email address\n * to Unicode. Only the Punycoded parts of the input will be converted, i.e.\n * it doesn't matter if you call it on a string that has already been\n * converted to Unicode.\n * @memberOf punycode\n * @param {String} input The Punycoded domain name or email address to\n * convert to Unicode.\n * @returns {String} The Unicode representation of the given Punycode\n * string.\n */\n\n\n function toUnicode(input) {\n return mapDomain(input, function (string) {\n return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;\n });\n }\n /**\n * Converts a Unicode string representing a domain name or an email address to\n * Punycode. Only the non-ASCII parts of the domain name will be converted,\n * i.e. it doesn't matter if you call it with a domain that's already in\n * ASCII.\n * @memberOf punycode\n * @param {String} input The domain name or email address to convert, as a\n * Unicode string.\n * @returns {String} The Punycode representation of the given domain name or\n * email address.\n */\n\n\n function toASCII(input) {\n return mapDomain(input, function (string) {\n return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;\n });\n }\n /*--------------------------------------------------------------------------*/\n\n /** Define the public API */\n\n\n punycode = {\n /**\n * A string representing the current Punycode.js version number.\n * @memberOf punycode\n * @type String\n */\n 'version': '1.4.1',\n\n /**\n * An object of methods to convert from JavaScript's internal character\n * representation (UCS-2) to Unicode code points, and back.\n * @see \n * @memberOf punycode\n * @type Object\n */\n 'ucs2': {\n 'decode': ucs2decode,\n 'encode': ucs2encode\n },\n 'decode': decode,\n 'encode': encode,\n 'toASCII': toASCII,\n 'toUnicode': toUnicode\n };\n /** Expose `punycode` */\n // Some AMD build optimizers, like r.js, check for specific condition patterns\n // like the following:\n\n if (typeof define == 'function' && _typeof(define.amd) == 'object' && define.amd) {\n define('punycode', function () {\n return punycode;\n });\n } else if (freeExports && freeModule) {\n if (module.exports == freeExports) {\n // in Node.js, io.js, or RingoJS v0.8.0+\n freeModule.exports = punycode;\n } else {\n // in Narwhal or RingoJS v0.7.0-\n for (key in punycode) {\n punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);\n }\n }\n } else {\n // in Rhino or a web browser\n root.punycode = punycode;\n }\n})(this);" + "source": "/*! https://mths.be/punycode v1.4.1 by @mathias */\n;\n\n(function (root) {\n /** Detect free variables */\n var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n var freeModule = typeof module == 'object' && module && !module.nodeType && module;\n var freeGlobal = typeof global == 'object' && global;\n\n if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {\n root = freeGlobal;\n }\n /**\n * The `punycode` object.\n * @name punycode\n * @type Object\n */\n\n\n var punycode,\n\n /** Highest positive signed 32-bit float value */\n maxInt = 2147483647,\n // aka. 0x7FFFFFFF or 2^31-1\n\n /** Bootstring parameters */\n base = 36,\n tMin = 1,\n tMax = 26,\n skew = 38,\n damp = 700,\n initialBias = 72,\n initialN = 128,\n // 0x80\n delimiter = '-',\n // '\\x2D'\n\n /** Regular expressions */\n regexPunycode = /^xn--/,\n regexNonASCII = /[^\\x20-\\x7E]/,\n // unprintable ASCII chars + non-ASCII chars\n regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g,\n // RFC 3490 separators\n\n /** Error messages */\n errors = {\n 'overflow': 'Overflow: input needs wider integers to process',\n 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',\n 'invalid-input': 'Invalid input'\n },\n\n /** Convenience shortcuts */\n baseMinusTMin = base - tMin,\n floor = Math.floor,\n stringFromCharCode = String.fromCharCode,\n\n /** Temporary variable */\n key;\n /*--------------------------------------------------------------------------*/\n\n /**\n * A generic error utility function.\n * @private\n * @param {String} type The error type.\n * @returns {Error} Throws a `RangeError` with the applicable error message.\n */\n\n function error(type) {\n throw new RangeError(errors[type]);\n }\n /**\n * A generic `Array#map` utility function.\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} callback The function that gets called for every array\n * item.\n * @returns {Array} A new array of values returned by the callback function.\n */\n\n\n function map(array, fn) {\n var length = array.length;\n var result = [];\n\n while (length--) {\n result[length] = fn(array[length]);\n }\n\n return result;\n }\n /**\n * A simple `Array#map`-like wrapper to work with domain name strings or email\n * addresses.\n * @private\n * @param {String} domain The domain name or email address.\n * @param {Function} callback The function that gets called for every\n * character.\n * @returns {Array} A new string of characters returned by the callback\n * function.\n */\n\n\n function mapDomain(string, fn) {\n var parts = string.split('@');\n var result = '';\n\n if (parts.length > 1) {\n // In email addresses, only the domain name should be punycoded. Leave\n // the local part (i.e. everything up to `@`) intact.\n result = parts[0] + '@';\n string = parts[1];\n } // Avoid `split(regex)` for IE8 compatibility. See #17.\n\n\n string = string.replace(regexSeparators, '\\x2E');\n var labels = string.split('.');\n var encoded = map(labels, fn).join('.');\n return result + encoded;\n }\n /**\n * Creates an array containing the numeric code points of each Unicode\n * character in the string. While JavaScript uses UCS-2 internally,\n * this function will convert a pair of surrogate halves (each of which\n * UCS-2 exposes as separate characters) into a single code point,\n * matching UTF-16.\n * @see `punycode.ucs2.encode`\n * @see \n * @memberOf punycode.ucs2\n * @name decode\n * @param {String} string The Unicode input string (UCS-2).\n * @returns {Array} The new array of code points.\n */\n\n\n function ucs2decode(string) {\n var output = [],\n counter = 0,\n length = string.length,\n value,\n extra;\n\n while (counter < length) {\n value = string.charCodeAt(counter++);\n\n if (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n // high surrogate, and there is a next character\n extra = string.charCodeAt(counter++);\n\n if ((extra & 0xFC00) == 0xDC00) {\n // low surrogate\n output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n } else {\n // unmatched surrogate; only append this code unit, in case the next\n // code unit is the high surrogate of a surrogate pair\n output.push(value);\n counter--;\n }\n } else {\n output.push(value);\n }\n }\n\n return output;\n }\n /**\n * Creates a string based on an array of numeric code points.\n * @see `punycode.ucs2.decode`\n * @memberOf punycode.ucs2\n * @name encode\n * @param {Array} codePoints The array of numeric code points.\n * @returns {String} The new Unicode string (UCS-2).\n */\n\n\n function ucs2encode(array) {\n return map(array, function (value) {\n var output = '';\n\n if (value > 0xFFFF) {\n value -= 0x10000;\n output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);\n value = 0xDC00 | value & 0x3FF;\n }\n\n output += stringFromCharCode(value);\n return output;\n }).join('');\n }\n /**\n * Converts a basic code point into a digit/integer.\n * @see `digitToBasic()`\n * @private\n * @param {Number} codePoint The basic numeric code point value.\n * @returns {Number} The numeric value of a basic code point (for use in\n * representing integers) in the range `0` to `base - 1`, or `base` if\n * the code point does not represent a value.\n */\n\n\n function basicToDigit(codePoint) {\n if (codePoint - 48 < 10) {\n return codePoint - 22;\n }\n\n if (codePoint - 65 < 26) {\n return codePoint - 65;\n }\n\n if (codePoint - 97 < 26) {\n return codePoint - 97;\n }\n\n return base;\n }\n /**\n * Converts a digit/integer into a basic code point.\n * @see `basicToDigit()`\n * @private\n * @param {Number} digit The numeric value of a basic code point.\n * @returns {Number} The basic code point whose value (when used for\n * representing integers) is `digit`, which needs to be in the range\n * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is\n * used; else, the lowercase form is used. The behavior is undefined\n * if `flag` is non-zero and `digit` has no uppercase form.\n */\n\n\n function digitToBasic(digit, flag) {\n // 0..25 map to ASCII a..z or A..Z\n // 26..35 map to ASCII 0..9\n return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);\n }\n /**\n * Bias adaptation function as per section 3.4 of RFC 3492.\n * https://tools.ietf.org/html/rfc3492#section-3.4\n * @private\n */\n\n\n function adapt(delta, numPoints, firstTime) {\n var k = 0;\n delta = firstTime ? floor(delta / damp) : delta >> 1;\n delta += floor(delta / numPoints);\n\n for (;\n /* no initialization */\n delta > baseMinusTMin * tMax >> 1; k += base) {\n delta = floor(delta / baseMinusTMin);\n }\n\n return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n }\n /**\n * Converts a Punycode string of ASCII-only symbols to a string of Unicode\n * symbols.\n * @memberOf punycode\n * @param {String} input The Punycode string of ASCII-only symbols.\n * @returns {String} The resulting string of Unicode symbols.\n */\n\n\n function decode(input) {\n // Don't use UCS-2\n var output = [],\n inputLength = input.length,\n out,\n i = 0,\n n = initialN,\n bias = initialBias,\n basic,\n j,\n index,\n oldi,\n w,\n k,\n digit,\n t,\n\n /** Cached calculation results */\n baseMinusT; // Handle the basic code points: let `basic` be the number of input code\n // points before the last delimiter, or `0` if there is none, then copy\n // the first basic code points to the output.\n\n basic = input.lastIndexOf(delimiter);\n\n if (basic < 0) {\n basic = 0;\n }\n\n for (j = 0; j < basic; ++j) {\n // if it's not a basic code point\n if (input.charCodeAt(j) >= 0x80) {\n error('not-basic');\n }\n\n output.push(input.charCodeAt(j));\n } // Main decoding loop: start just after the last delimiter if any basic code\n // points were copied; start at the beginning otherwise.\n\n\n for (index = basic > 0 ? basic + 1 : 0; index < inputLength;)\n /* no final expression */\n {\n // `index` is the index of the next character to be consumed.\n // Decode a generalized variable-length integer into `delta`,\n // which gets added to `i`. The overflow checking is easier\n // if we increase `i` as we go, then subtract off its starting\n // value at the end to obtain `delta`.\n for (oldi = i, w = 1, k = base;;\n /* no condition */\n k += base) {\n if (index >= inputLength) {\n error('invalid-input');\n }\n\n digit = basicToDigit(input.charCodeAt(index++));\n\n if (digit >= base || digit > floor((maxInt - i) / w)) {\n error('overflow');\n }\n\n i += digit * w;\n t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n\n if (digit < t) {\n break;\n }\n\n baseMinusT = base - t;\n\n if (w > floor(maxInt / baseMinusT)) {\n error('overflow');\n }\n\n w *= baseMinusT;\n }\n\n out = output.length + 1;\n bias = adapt(i - oldi, out, oldi == 0); // `i` was supposed to wrap around from `out` to `0`,\n // incrementing `n` each time, so we'll fix that now:\n\n if (floor(i / out) > maxInt - n) {\n error('overflow');\n }\n\n n += floor(i / out);\n i %= out; // Insert `n` at position `i` of the output\n\n output.splice(i++, 0, n);\n }\n\n return ucs2encode(output);\n }\n /**\n * Converts a string of Unicode symbols (e.g. a domain name label) to a\n * Punycode string of ASCII-only symbols.\n * @memberOf punycode\n * @param {String} input The string of Unicode symbols.\n * @returns {String} The resulting Punycode string of ASCII-only symbols.\n */\n\n\n function encode(input) {\n var n,\n delta,\n handledCPCount,\n basicLength,\n bias,\n j,\n m,\n q,\n k,\n t,\n currentValue,\n output = [],\n\n /** `inputLength` will hold the number of code points in `input`. */\n inputLength,\n\n /** Cached calculation results */\n handledCPCountPlusOne,\n baseMinusT,\n qMinusT; // Convert the input in UCS-2 to Unicode\n\n input = ucs2decode(input); // Cache the length\n\n inputLength = input.length; // Initialize the state\n\n n = initialN;\n delta = 0;\n bias = initialBias; // Handle the basic code points\n\n for (j = 0; j < inputLength; ++j) {\n currentValue = input[j];\n\n if (currentValue < 0x80) {\n output.push(stringFromCharCode(currentValue));\n }\n }\n\n handledCPCount = basicLength = output.length; // `handledCPCount` is the number of code points that have been handled;\n // `basicLength` is the number of basic code points.\n // Finish the basic string - if it is not empty - with a delimiter\n\n if (basicLength) {\n output.push(delimiter);\n } // Main encoding loop:\n\n\n while (handledCPCount < inputLength) {\n // All non-basic code points < n have been handled already. Find the next\n // larger one:\n for (m = maxInt, j = 0; j < inputLength; ++j) {\n currentValue = input[j];\n\n if (currentValue >= n && currentValue < m) {\n m = currentValue;\n }\n } // Increase `delta` enough to advance the decoder's state to ,\n // but guard against overflow\n\n\n handledCPCountPlusOne = handledCPCount + 1;\n\n if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n error('overflow');\n }\n\n delta += (m - n) * handledCPCountPlusOne;\n n = m;\n\n for (j = 0; j < inputLength; ++j) {\n currentValue = input[j];\n\n if (currentValue < n && ++delta > maxInt) {\n error('overflow');\n }\n\n if (currentValue == n) {\n // Represent delta as a generalized variable-length integer\n for (q = delta, k = base;;\n /* no condition */\n k += base) {\n t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n\n if (q < t) {\n break;\n }\n\n qMinusT = q - t;\n baseMinusT = base - t;\n output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));\n q = floor(qMinusT / baseMinusT);\n }\n\n output.push(stringFromCharCode(digitToBasic(q, 0)));\n bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);\n delta = 0;\n ++handledCPCount;\n }\n }\n\n ++delta;\n ++n;\n }\n\n return output.join('');\n }\n /**\n * Converts a Punycode string representing a domain name or an email address\n * to Unicode. Only the Punycoded parts of the input will be converted, i.e.\n * it doesn't matter if you call it on a string that has already been\n * converted to Unicode.\n * @memberOf punycode\n * @param {String} input The Punycoded domain name or email address to\n * convert to Unicode.\n * @returns {String} The Unicode representation of the given Punycode\n * string.\n */\n\n\n function toUnicode(input) {\n return mapDomain(input, function (string) {\n return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;\n });\n }\n /**\n * Converts a Unicode string representing a domain name or an email address to\n * Punycode. Only the non-ASCII parts of the domain name will be converted,\n * i.e. it doesn't matter if you call it with a domain that's already in\n * ASCII.\n * @memberOf punycode\n * @param {String} input The domain name or email address to convert, as a\n * Unicode string.\n * @returns {String} The Punycode representation of the given domain name or\n * email address.\n */\n\n\n function toASCII(input) {\n return mapDomain(input, function (string) {\n return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;\n });\n }\n /*--------------------------------------------------------------------------*/\n\n /** Define the public API */\n\n\n punycode = {\n /**\n * A string representing the current Punycode.js version number.\n * @memberOf punycode\n * @type String\n */\n 'version': '1.4.1',\n\n /**\n * An object of methods to convert from JavaScript's internal character\n * representation (UCS-2) to Unicode code points, and back.\n * @see \n * @memberOf punycode\n * @type Object\n */\n 'ucs2': {\n 'decode': ucs2decode,\n 'encode': ucs2encode\n },\n 'decode': decode,\n 'encode': encode,\n 'toASCII': toASCII,\n 'toUnicode': toUnicode\n };\n /** Expose `punycode` */\n // Some AMD build optimizers, like r.js, check for specific condition patterns\n // like the following:\n\n if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {\n define('punycode', function () {\n return punycode;\n });\n } else if (freeExports && freeModule) {\n if (module.exports == freeExports) {\n // in Node.js, io.js, or RingoJS v0.8.0+\n freeModule.exports = punycode;\n } else {\n // in Narwhal or RingoJS v0.7.0-\n for (key in punycode) {\n punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);\n }\n }\n } else {\n // in Rhino or a web browser\n root.punycode = punycode;\n }\n})(this);" }, { - "id": 46, + "id": 45, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/webpack/buildin/module.js", "name": "(webpack)/buildin/module.js", "index": 43, @@ -4027,7 +3934,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "issuerId": 45, + "issuerId": 44, "issuerName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "issuerPath": [ { @@ -4035,43 +3942,43 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 44, + "id": 43, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "name": "../node_modules/@hapi/address/lib/index.js", "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 } }, { - "id": 45, + "id": 44, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", "name": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "profile": { - "factory": 4, - "building": 95 + "factory": 3, + "building": 94 } } ], "profile": { - "factory": 56, - "building": 8 + "factory": 55, + "building": 5 }, "failed": false, "errors": 0, @@ -4079,7 +3986,7 @@ "assets": [], "reasons": [ { - "moduleId": 45, + "moduleId": 44, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", "module": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "moduleName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", @@ -4097,12 +4004,12 @@ "source": "module.exports = function (module) {\n if (!module.webpackPolyfill) {\n module.deprecate = function () {};\n\n module.paths = []; // module.parent = undefined by default\n\n if (!module.children) module.children = [];\n Object.defineProperty(module, \"loaded\", {\n enumerable: true,\n get: function get() {\n return module.l;\n }\n });\n Object.defineProperty(module, \"id\", {\n enumerable: true,\n get: function get() {\n return module.i;\n }\n });\n module.webpackPolyfill = 1;\n }\n\n return module;\n};" }, { - "id": 47, + "id": 46, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/webpack/buildin/global.js", "name": "(webpack)/buildin/global.js", "index": 44, "index2": 40, - "size": 878, + "size": 475, "cacheable": true, "built": true, "optional": false, @@ -4111,7 +4018,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "issuerId": 45, + "issuerId": 44, "issuerName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "issuerPath": [ { @@ -4119,43 +4026,43 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 44, + "id": 43, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "name": "../node_modules/@hapi/address/lib/index.js", "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 } }, { - "id": 45, + "id": 44, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", "name": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "profile": { - "factory": 4, - "building": 95 + "factory": 3, + "building": 94 } } ], "profile": { - "factory": 56, - "building": 8 + "factory": 55, + "building": 5 }, "failed": false, "errors": 0, @@ -4163,7 +4070,7 @@ "assets": [], "reasons": [ { - "moduleId": 45, + "moduleId": 44, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", "module": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "moduleName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", @@ -4178,15 +4085,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 4, - "source": "function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar g; // This works in non-strict mode\n\ng = function () {\n return this;\n}();\n\ntry {\n // This works if eval is allowed (see CSP)\n g = g || new Function(\"return this\")();\n} catch (e) {\n // This works if the window reference is available\n if ((typeof window === \"undefined\" ? \"undefined\" : _typeof(window)) === \"object\") g = window;\n} // g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\n\nmodule.exports = g;" + "source": "var g; // This works in non-strict mode\n\ng = function () {\n return this;\n}();\n\ntry {\n // This works if eval is allowed (see CSP)\n g = g || new Function(\"return this\")();\n} catch (e) {\n // This works if the window reference is available\n if (typeof window === \"object\") g = window;\n} // g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\n\nmodule.exports = g;" }, { - "id": 48, + "id": 47, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/abnf.js", "name": "../node_modules/@hapi/address/lib/abnf.js", - "index": 46, - "index2": 43, - "size": 2297, + "index": 45, + "index2": 42, + "size": 2299, "cacheable": true, "built": true, "optional": false, @@ -4195,7 +4102,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", - "issuerId": 44, + "issuerId": 43, "issuerName": "../node_modules/@hapi/address/lib/index.js", "issuerPath": [ { @@ -4203,34 +4110,34 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 44, + "id": 43, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "name": "../node_modules/@hapi/address/lib/index.js", "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 } } ], "profile": { - "factory": 4, - "building": 95 + "factory": 3, + "building": 94 }, "failed": false, "errors": 0, @@ -4238,13 +4145,13 @@ "assets": [], "reasons": [ { - "moduleId": 44, + "moduleId": 43, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "module": "../node_modules/@hapi/address/lib/index.js", "moduleName": "../node_modules/@hapi/address/lib/index.js", "type": "cjs require", "userRequest": "./abnf", - "loc": "7:11-28" + "loc": "5:13-30" } ], "usedExports": true, @@ -4253,15 +4160,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nvar internals = {};\n/*\r\n From RFC 5321:\r\n\r\n Mailbox = Local-part \"@\" ( Domain / address-literal )\r\n\r\n Local-part = Dot-string / Quoted-string\r\n Dot-string = Atom *(\".\" Atom)\r\n Atom = 1*atext\r\n atext = ALPHA / DIGIT / \"!\" / \"#\" / \"$\" / \"%\" / \"&\" / \"'\" / \"*\" / \"+\" / \"-\" / \"/\" / \"=\" / \"?\" / \"^\" / \"_\" / \"`\" / \"{\" / \"|\" / \"}\" / \"~\"\r\n\r\n Domain = sub-domain *(\".\" sub-domain)\r\n sub-domain = Let-dig [Ldh-str]\r\n Let-dig = ALPHA / DIGIT\r\n Ldh-str = *( ALPHA / DIGIT / \"-\" ) Let-dig\r\n\r\n ALPHA = %x41-5A / %x61-7A ; a-z, A-Z\r\n DIGIT = %x30-39 ; 0-9\r\n\r\n From RFC 6531:\r\n\r\n sub-domain =/ U-label\r\n atext =/ UTF8-non-ascii\r\n\r\n UTF8-non-ascii = UTF8-2 / UTF8-3 / UTF8-4\r\n\r\n UTF8-2 = %xC2-DF UTF8-tail\r\n UTF8-3 = %xE0 %xA0-BF UTF8-tail /\r\n %xE1-EC 2( UTF8-tail ) /\r\n %xED %x80-9F UTF8-tail /\r\n %xEE-EF 2( UTF8-tail )\r\n UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) /\r\n %xF1-F3 3( UTF8-tail ) /\r\n %xF4 %x80-8F 2( UTF8-tail )\r\n\r\n UTF8-tail = %x80-BF\r\n\r\n Note: The following are not supported:\r\n\r\n RFC 5321: address-literal, Quoted-string\r\n RFC 5322: obs-*, CFWS\r\n*/\n\ninternals.atext = '[\\\\w!#\\\\$%&\\'\\\\*\\\\+\\\\-/=\\\\?\\\\^`\\\\{\\\\|\\\\}~]'; // _ included in \\w\n\nexports.atextRx = new RegExp(\"^\".concat(internals.atext, \"+$\"));\nexports.atomRx = new RegExp([internals.atext, // %xC2-DF UTF8-tail\n'(?:[\\\\xc2-\\\\xdf][\\\\x80-\\\\xbf])', // %xE0 %xA0-BF UTF8-tail %xE1-EC 2( UTF8-tail ) %xED %x80-9F UTF8-tail %xEE-EF 2( UTF8-tail )\n'(?:\\\\xe0[\\\\xa0-\\\\xbf][\\\\x80-\\\\xbf])|(?:[\\\\xe1-\\\\xec][\\\\x80-\\\\xbf]{2})|(?:\\\\xed[\\\\x80-\\\\x9f][\\\\x80-\\\\xbf])|(?:[\\\\xee-\\\\xef][\\\\x80-\\\\xbf]{2})', // %xF0 %x90-BF 2( UTF8-tail ) %xF1-F3 3( UTF8-tail ) %xF4 %x80-8F 2( UTF8-tail )\n'(?:\\\\xf0[\\\\x90-\\\\xbf][\\\\x80-\\\\xbf]{2})|(?:[\\\\xf1-\\\\xf3][\\\\x80-\\\\xbf]{3})|(?:\\\\xf4[\\\\x80-\\\\x8f][\\\\x80-\\\\xbf]{2})'].join('|'));" + "source": "'use strict';\n\nconst internals = {};\n/*\r\n From RFC 5321:\r\n\r\n Mailbox = Local-part \"@\" ( Domain / address-literal )\r\n\r\n Local-part = Dot-string / Quoted-string\r\n Dot-string = Atom *(\".\" Atom)\r\n Atom = 1*atext\r\n atext = ALPHA / DIGIT / \"!\" / \"#\" / \"$\" / \"%\" / \"&\" / \"'\" / \"*\" / \"+\" / \"-\" / \"/\" / \"=\" / \"?\" / \"^\" / \"_\" / \"`\" / \"{\" / \"|\" / \"}\" / \"~\"\r\n\r\n Domain = sub-domain *(\".\" sub-domain)\r\n sub-domain = Let-dig [Ldh-str]\r\n Let-dig = ALPHA / DIGIT\r\n Ldh-str = *( ALPHA / DIGIT / \"-\" ) Let-dig\r\n\r\n ALPHA = %x41-5A / %x61-7A ; a-z, A-Z\r\n DIGIT = %x30-39 ; 0-9\r\n\r\n From RFC 6531:\r\n\r\n sub-domain =/ U-label\r\n atext =/ UTF8-non-ascii\r\n\r\n UTF8-non-ascii = UTF8-2 / UTF8-3 / UTF8-4\r\n\r\n UTF8-2 = %xC2-DF UTF8-tail\r\n UTF8-3 = %xE0 %xA0-BF UTF8-tail /\r\n %xE1-EC 2( UTF8-tail ) /\r\n %xED %x80-9F UTF8-tail /\r\n %xEE-EF 2( UTF8-tail )\r\n UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) /\r\n %xF1-F3 3( UTF8-tail ) /\r\n %xF4 %x80-8F 2( UTF8-tail )\r\n\r\n UTF8-tail = %x80-BF\r\n\r\n Note: The following are not supported:\r\n\r\n RFC 5321: address-literal, Quoted-string\r\n RFC 5322: obs-*, CFWS\r\n*/\n\ninternals.atext = '[\\\\w!#\\\\$%&\\'\\\\*\\\\+\\\\-/=\\\\?\\\\^`\\\\{\\\\|\\\\}~]'; // _ included in \\w\n\nexports.atextRx = new RegExp(\"^\".concat(internals.atext, \"+$\"));\nexports.atomRx = new RegExp([internals.atext, // %xC2-DF UTF8-tail\n'(?:[\\\\xc2-\\\\xdf][\\\\x80-\\\\xbf])', // %xE0 %xA0-BF UTF8-tail %xE1-EC 2( UTF8-tail ) %xED %x80-9F UTF8-tail %xEE-EF 2( UTF8-tail )\n'(?:\\\\xe0[\\\\xa0-\\\\xbf][\\\\x80-\\\\xbf])|(?:[\\\\xe1-\\\\xec][\\\\x80-\\\\xbf]{2})|(?:\\\\xed[\\\\x80-\\\\x9f][\\\\x80-\\\\xbf])|(?:[\\\\xee-\\\\xef][\\\\x80-\\\\xbf]{2})', // %xF0 %x90-BF 2( UTF8-tail ) %xF1-F3 3( UTF8-tail ) %xF4 %x80-8F 2( UTF8-tail )\n'(?:\\\\xf0[\\\\x90-\\\\xbf][\\\\x80-\\\\xbf]{2})|(?:[\\\\xf1-\\\\xf3][\\\\x80-\\\\xbf]{3})|(?:\\\\xf4[\\\\x80-\\\\x8f][\\\\x80-\\\\xbf]{2})'].join('|'));" }, { - "id": 49, + "id": 48, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/tlds.js", "name": "../node_modules/@hapi/address/lib/tlds.js", - "index": 47, - "index2": 44, - "size": 15195, + "index": 46, + "index2": 43, + "size": 15175, "cacheable": true, "built": true, "optional": false, @@ -4270,7 +4177,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", - "issuerId": 44, + "issuerId": 43, "issuerName": "../node_modules/@hapi/address/lib/index.js", "issuerPath": [ { @@ -4278,34 +4185,34 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 44, + "id": 43, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "name": "../node_modules/@hapi/address/lib/index.js", "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 } } ], "profile": { - "factory": 4, - "building": 95 + "factory": 3, + "building": 94 }, "failed": false, "errors": 0, @@ -4313,13 +4220,13 @@ "assets": [], "reasons": [ { - "moduleId": 44, + "moduleId": 43, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "module": "../node_modules/@hapi/address/lib/index.js", "moduleName": "../node_modules/@hapi/address/lib/index.js", "type": "cjs require", "userRequest": "./tlds", - "loc": "9:11-28" + "loc": "7:13-30" } ], "usedExports": true, @@ -4328,15 +4235,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nvar internals = {}; // http://data.iana.org/TLD/tlds-alpha-by-domain.txt\n// # Version 2019032300, Last Updated Sat Mar 23 07:07:02 2019 UTC\n\ninternals.tlds = ['AAA', 'AARP', 'ABARTH', 'ABB', 'ABBOTT', 'ABBVIE', 'ABC', 'ABLE', 'ABOGADO', 'ABUDHABI', 'AC', 'ACADEMY', 'ACCENTURE', 'ACCOUNTANT', 'ACCOUNTANTS', 'ACO', 'ACTOR', 'AD', 'ADAC', 'ADS', 'ADULT', 'AE', 'AEG', 'AERO', 'AETNA', 'AF', 'AFAMILYCOMPANY', 'AFL', 'AFRICA', 'AG', 'AGAKHAN', 'AGENCY', 'AI', 'AIG', 'AIGO', 'AIRBUS', 'AIRFORCE', 'AIRTEL', 'AKDN', 'AL', 'ALFAROMEO', 'ALIBABA', 'ALIPAY', 'ALLFINANZ', 'ALLSTATE', 'ALLY', 'ALSACE', 'ALSTOM', 'AM', 'AMERICANEXPRESS', 'AMERICANFAMILY', 'AMEX', 'AMFAM', 'AMICA', 'AMSTERDAM', 'ANALYTICS', 'ANDROID', 'ANQUAN', 'ANZ', 'AO', 'AOL', 'APARTMENTS', 'APP', 'APPLE', 'AQ', 'AQUARELLE', 'AR', 'ARAB', 'ARAMCO', 'ARCHI', 'ARMY', 'ARPA', 'ART', 'ARTE', 'AS', 'ASDA', 'ASIA', 'ASSOCIATES', 'AT', 'ATHLETA', 'ATTORNEY', 'AU', 'AUCTION', 'AUDI', 'AUDIBLE', 'AUDIO', 'AUSPOST', 'AUTHOR', 'AUTO', 'AUTOS', 'AVIANCA', 'AW', 'AWS', 'AX', 'AXA', 'AZ', 'AZURE', 'BA', 'BABY', 'BAIDU', 'BANAMEX', 'BANANAREPUBLIC', 'BAND', 'BANK', 'BAR', 'BARCELONA', 'BARCLAYCARD', 'BARCLAYS', 'BAREFOOT', 'BARGAINS', 'BASEBALL', 'BASKETBALL', 'BAUHAUS', 'BAYERN', 'BB', 'BBC', 'BBT', 'BBVA', 'BCG', 'BCN', 'BD', 'BE', 'BEATS', 'BEAUTY', 'BEER', 'BENTLEY', 'BERLIN', 'BEST', 'BESTBUY', 'BET', 'BF', 'BG', 'BH', 'BHARTI', 'BI', 'BIBLE', 'BID', 'BIKE', 'BING', 'BINGO', 'BIO', 'BIZ', 'BJ', 'BLACK', 'BLACKFRIDAY', 'BLOCKBUSTER', 'BLOG', 'BLOOMBERG', 'BLUE', 'BM', 'BMS', 'BMW', 'BN', 'BNL', 'BNPPARIBAS', 'BO', 'BOATS', 'BOEHRINGER', 'BOFA', 'BOM', 'BOND', 'BOO', 'BOOK', 'BOOKING', 'BOSCH', 'BOSTIK', 'BOSTON', 'BOT', 'BOUTIQUE', 'BOX', 'BR', 'BRADESCO', 'BRIDGESTONE', 'BROADWAY', 'BROKER', 'BROTHER', 'BRUSSELS', 'BS', 'BT', 'BUDAPEST', 'BUGATTI', 'BUILD', 'BUILDERS', 'BUSINESS', 'BUY', 'BUZZ', 'BV', 'BW', 'BY', 'BZ', 'BZH', 'CA', 'CAB', 'CAFE', 'CAL', 'CALL', 'CALVINKLEIN', 'CAM', 'CAMERA', 'CAMP', 'CANCERRESEARCH', 'CANON', 'CAPETOWN', 'CAPITAL', 'CAPITALONE', 'CAR', 'CARAVAN', 'CARDS', 'CARE', 'CAREER', 'CAREERS', 'CARS', 'CARTIER', 'CASA', 'CASE', 'CASEIH', 'CASH', 'CASINO', 'CAT', 'CATERING', 'CATHOLIC', 'CBA', 'CBN', 'CBRE', 'CBS', 'CC', 'CD', 'CEB', 'CENTER', 'CEO', 'CERN', 'CF', 'CFA', 'CFD', 'CG', 'CH', 'CHANEL', 'CHANNEL', 'CHARITY', 'CHASE', 'CHAT', 'CHEAP', 'CHINTAI', 'CHRISTMAS', 'CHROME', 'CHRYSLER', 'CHURCH', 'CI', 'CIPRIANI', 'CIRCLE', 'CISCO', 'CITADEL', 'CITI', 'CITIC', 'CITY', 'CITYEATS', 'CK', 'CL', 'CLAIMS', 'CLEANING', 'CLICK', 'CLINIC', 'CLINIQUE', 'CLOTHING', 'CLOUD', 'CLUB', 'CLUBMED', 'CM', 'CN', 'CO', 'COACH', 'CODES', 'COFFEE', 'COLLEGE', 'COLOGNE', 'COM', 'COMCAST', 'COMMBANK', 'COMMUNITY', 'COMPANY', 'COMPARE', 'COMPUTER', 'COMSEC', 'CONDOS', 'CONSTRUCTION', 'CONSULTING', 'CONTACT', 'CONTRACTORS', 'COOKING', 'COOKINGCHANNEL', 'COOL', 'COOP', 'CORSICA', 'COUNTRY', 'COUPON', 'COUPONS', 'COURSES', 'CR', 'CREDIT', 'CREDITCARD', 'CREDITUNION', 'CRICKET', 'CROWN', 'CRS', 'CRUISE', 'CRUISES', 'CSC', 'CU', 'CUISINELLA', 'CV', 'CW', 'CX', 'CY', 'CYMRU', 'CYOU', 'CZ', 'DABUR', 'DAD', 'DANCE', 'DATA', 'DATE', 'DATING', 'DATSUN', 'DAY', 'DCLK', 'DDS', 'DE', 'DEAL', 'DEALER', 'DEALS', 'DEGREE', 'DELIVERY', 'DELL', 'DELOITTE', 'DELTA', 'DEMOCRAT', 'DENTAL', 'DENTIST', 'DESI', 'DESIGN', 'DEV', 'DHL', 'DIAMONDS', 'DIET', 'DIGITAL', 'DIRECT', 'DIRECTORY', 'DISCOUNT', 'DISCOVER', 'DISH', 'DIY', 'DJ', 'DK', 'DM', 'DNP', 'DO', 'DOCS', 'DOCTOR', 'DODGE', 'DOG', 'DOHA', 'DOMAINS', 'DOT', 'DOWNLOAD', 'DRIVE', 'DTV', 'DUBAI', 'DUCK', 'DUNLOP', 'DUNS', 'DUPONT', 'DURBAN', 'DVAG', 'DVR', 'DZ', 'EARTH', 'EAT', 'EC', 'ECO', 'EDEKA', 'EDU', 'EDUCATION', 'EE', 'EG', 'EMAIL', 'EMERCK', 'ENERGY', 'ENGINEER', 'ENGINEERING', 'ENTERPRISES', 'EPSON', 'EQUIPMENT', 'ER', 'ERICSSON', 'ERNI', 'ES', 'ESQ', 'ESTATE', 'ESURANCE', 'ET', 'ETISALAT', 'EU', 'EUROVISION', 'EUS', 'EVENTS', 'EVERBANK', 'EXCHANGE', 'EXPERT', 'EXPOSED', 'EXPRESS', 'EXTRASPACE', 'FAGE', 'FAIL', 'FAIRWINDS', 'FAITH', 'FAMILY', 'FAN', 'FANS', 'FARM', 'FARMERS', 'FASHION', 'FAST', 'FEDEX', 'FEEDBACK', 'FERRARI', 'FERRERO', 'FI', 'FIAT', 'FIDELITY', 'FIDO', 'FILM', 'FINAL', 'FINANCE', 'FINANCIAL', 'FIRE', 'FIRESTONE', 'FIRMDALE', 'FISH', 'FISHING', 'FIT', 'FITNESS', 'FJ', 'FK', 'FLICKR', 'FLIGHTS', 'FLIR', 'FLORIST', 'FLOWERS', 'FLY', 'FM', 'FO', 'FOO', 'FOOD', 'FOODNETWORK', 'FOOTBALL', 'FORD', 'FOREX', 'FORSALE', 'FORUM', 'FOUNDATION', 'FOX', 'FR', 'FREE', 'FRESENIUS', 'FRL', 'FROGANS', 'FRONTDOOR', 'FRONTIER', 'FTR', 'FUJITSU', 'FUJIXEROX', 'FUN', 'FUND', 'FURNITURE', 'FUTBOL', 'FYI', 'GA', 'GAL', 'GALLERY', 'GALLO', 'GALLUP', 'GAME', 'GAMES', 'GAP', 'GARDEN', 'GB', 'GBIZ', 'GD', 'GDN', 'GE', 'GEA', 'GENT', 'GENTING', 'GEORGE', 'GF', 'GG', 'GGEE', 'GH', 'GI', 'GIFT', 'GIFTS', 'GIVES', 'GIVING', 'GL', 'GLADE', 'GLASS', 'GLE', 'GLOBAL', 'GLOBO', 'GM', 'GMAIL', 'GMBH', 'GMO', 'GMX', 'GN', 'GODADDY', 'GOLD', 'GOLDPOINT', 'GOLF', 'GOO', 'GOODYEAR', 'GOOG', 'GOOGLE', 'GOP', 'GOT', 'GOV', 'GP', 'GQ', 'GR', 'GRAINGER', 'GRAPHICS', 'GRATIS', 'GREEN', 'GRIPE', 'GROCERY', 'GROUP', 'GS', 'GT', 'GU', 'GUARDIAN', 'GUCCI', 'GUGE', 'GUIDE', 'GUITARS', 'GURU', 'GW', 'GY', 'HAIR', 'HAMBURG', 'HANGOUT', 'HAUS', 'HBO', 'HDFC', 'HDFCBANK', 'HEALTH', 'HEALTHCARE', 'HELP', 'HELSINKI', 'HERE', 'HERMES', 'HGTV', 'HIPHOP', 'HISAMITSU', 'HITACHI', 'HIV', 'HK', 'HKT', 'HM', 'HN', 'HOCKEY', 'HOLDINGS', 'HOLIDAY', 'HOMEDEPOT', 'HOMEGOODS', 'HOMES', 'HOMESENSE', 'HONDA', 'HONEYWELL', 'HORSE', 'HOSPITAL', 'HOST', 'HOSTING', 'HOT', 'HOTELES', 'HOTELS', 'HOTMAIL', 'HOUSE', 'HOW', 'HR', 'HSBC', 'HT', 'HU', 'HUGHES', 'HYATT', 'HYUNDAI', 'IBM', 'ICBC', 'ICE', 'ICU', 'ID', 'IE', 'IEEE', 'IFM', 'IKANO', 'IL', 'IM', 'IMAMAT', 'IMDB', 'IMMO', 'IMMOBILIEN', 'IN', 'INC', 'INDUSTRIES', 'INFINITI', 'INFO', 'ING', 'INK', 'INSTITUTE', 'INSURANCE', 'INSURE', 'INT', 'INTEL', 'INTERNATIONAL', 'INTUIT', 'INVESTMENTS', 'IO', 'IPIRANGA', 'IQ', 'IR', 'IRISH', 'IS', 'ISELECT', 'ISMAILI', 'IST', 'ISTANBUL', 'IT', 'ITAU', 'ITV', 'IVECO', 'JAGUAR', 'JAVA', 'JCB', 'JCP', 'JE', 'JEEP', 'JETZT', 'JEWELRY', 'JIO', 'JLL', 'JM', 'JMP', 'JNJ', 'JO', 'JOBS', 'JOBURG', 'JOT', 'JOY', 'JP', 'JPMORGAN', 'JPRS', 'JUEGOS', 'JUNIPER', 'KAUFEN', 'KDDI', 'KE', 'KERRYHOTELS', 'KERRYLOGISTICS', 'KERRYPROPERTIES', 'KFH', 'KG', 'KH', 'KI', 'KIA', 'KIM', 'KINDER', 'KINDLE', 'KITCHEN', 'KIWI', 'KM', 'KN', 'KOELN', 'KOMATSU', 'KOSHER', 'KP', 'KPMG', 'KPN', 'KR', 'KRD', 'KRED', 'KUOKGROUP', 'KW', 'KY', 'KYOTO', 'KZ', 'LA', 'LACAIXA', 'LADBROKES', 'LAMBORGHINI', 'LAMER', 'LANCASTER', 'LANCIA', 'LANCOME', 'LAND', 'LANDROVER', 'LANXESS', 'LASALLE', 'LAT', 'LATINO', 'LATROBE', 'LAW', 'LAWYER', 'LB', 'LC', 'LDS', 'LEASE', 'LECLERC', 'LEFRAK', 'LEGAL', 'LEGO', 'LEXUS', 'LGBT', 'LI', 'LIAISON', 'LIDL', 'LIFE', 'LIFEINSURANCE', 'LIFESTYLE', 'LIGHTING', 'LIKE', 'LILLY', 'LIMITED', 'LIMO', 'LINCOLN', 'LINDE', 'LINK', 'LIPSY', 'LIVE', 'LIVING', 'LIXIL', 'LK', 'LLC', 'LOAN', 'LOANS', 'LOCKER', 'LOCUS', 'LOFT', 'LOL', 'LONDON', 'LOTTE', 'LOTTO', 'LOVE', 'LPL', 'LPLFINANCIAL', 'LR', 'LS', 'LT', 'LTD', 'LTDA', 'LU', 'LUNDBECK', 'LUPIN', 'LUXE', 'LUXURY', 'LV', 'LY', 'MA', 'MACYS', 'MADRID', 'MAIF', 'MAISON', 'MAKEUP', 'MAN', 'MANAGEMENT', 'MANGO', 'MAP', 'MARKET', 'MARKETING', 'MARKETS', 'MARRIOTT', 'MARSHALLS', 'MASERATI', 'MATTEL', 'MBA', 'MC', 'MCKINSEY', 'MD', 'ME', 'MED', 'MEDIA', 'MEET', 'MELBOURNE', 'MEME', 'MEMORIAL', 'MEN', 'MENU', 'MERCKMSD', 'METLIFE', 'MG', 'MH', 'MIAMI', 'MICROSOFT', 'MIL', 'MINI', 'MINT', 'MIT', 'MITSUBISHI', 'MK', 'ML', 'MLB', 'MLS', 'MM', 'MMA', 'MN', 'MO', 'MOBI', 'MOBILE', 'MOBILY', 'MODA', 'MOE', 'MOI', 'MOM', 'MONASH', 'MONEY', 'MONSTER', 'MOPAR', 'MORMON', 'MORTGAGE', 'MOSCOW', 'MOTO', 'MOTORCYCLES', 'MOV', 'MOVIE', 'MOVISTAR', 'MP', 'MQ', 'MR', 'MS', 'MSD', 'MT', 'MTN', 'MTR', 'MU', 'MUSEUM', 'MUTUAL', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NAB', 'NADEX', 'NAGOYA', 'NAME', 'NATIONWIDE', 'NATURA', 'NAVY', 'NBA', 'NC', 'NE', 'NEC', 'NET', 'NETBANK', 'NETFLIX', 'NETWORK', 'NEUSTAR', 'NEW', 'NEWHOLLAND', 'NEWS', 'NEXT', 'NEXTDIRECT', 'NEXUS', 'NF', 'NFL', 'NG', 'NGO', 'NHK', 'NI', 'NICO', 'NIKE', 'NIKON', 'NINJA', 'NISSAN', 'NISSAY', 'NL', 'NO', 'NOKIA', 'NORTHWESTERNMUTUAL', 'NORTON', 'NOW', 'NOWRUZ', 'NOWTV', 'NP', 'NR', 'NRA', 'NRW', 'NTT', 'NU', 'NYC', 'NZ', 'OBI', 'OBSERVER', 'OFF', 'OFFICE', 'OKINAWA', 'OLAYAN', 'OLAYANGROUP', 'OLDNAVY', 'OLLO', 'OM', 'OMEGA', 'ONE', 'ONG', 'ONL', 'ONLINE', 'ONYOURSIDE', 'OOO', 'OPEN', 'ORACLE', 'ORANGE', 'ORG', 'ORGANIC', 'ORIGINS', 'OSAKA', 'OTSUKA', 'OTT', 'OVH', 'PA', 'PAGE', 'PANASONIC', 'PARIS', 'PARS', 'PARTNERS', 'PARTS', 'PARTY', 'PASSAGENS', 'PAY', 'PCCW', 'PE', 'PET', 'PF', 'PFIZER', 'PG', 'PH', 'PHARMACY', 'PHD', 'PHILIPS', 'PHONE', 'PHOTO', 'PHOTOGRAPHY', 'PHOTOS', 'PHYSIO', 'PIAGET', 'PICS', 'PICTET', 'PICTURES', 'PID', 'PIN', 'PING', 'PINK', 'PIONEER', 'PIZZA', 'PK', 'PL', 'PLACE', 'PLAY', 'PLAYSTATION', 'PLUMBING', 'PLUS', 'PM', 'PN', 'PNC', 'POHL', 'POKER', 'POLITIE', 'PORN', 'POST', 'PR', 'PRAMERICA', 'PRAXI', 'PRESS', 'PRIME', 'PRO', 'PROD', 'PRODUCTIONS', 'PROF', 'PROGRESSIVE', 'PROMO', 'PROPERTIES', 'PROPERTY', 'PROTECTION', 'PRU', 'PRUDENTIAL', 'PS', 'PT', 'PUB', 'PW', 'PWC', 'PY', 'QA', 'QPON', 'QUEBEC', 'QUEST', 'QVC', 'RACING', 'RADIO', 'RAID', 'RE', 'READ', 'REALESTATE', 'REALTOR', 'REALTY', 'RECIPES', 'RED', 'REDSTONE', 'REDUMBRELLA', 'REHAB', 'REISE', 'REISEN', 'REIT', 'RELIANCE', 'REN', 'RENT', 'RENTALS', 'REPAIR', 'REPORT', 'REPUBLICAN', 'REST', 'RESTAURANT', 'REVIEW', 'REVIEWS', 'REXROTH', 'RICH', 'RICHARDLI', 'RICOH', 'RIGHTATHOME', 'RIL', 'RIO', 'RIP', 'RMIT', 'RO', 'ROCHER', 'ROCKS', 'RODEO', 'ROGERS', 'ROOM', 'RS', 'RSVP', 'RU', 'RUGBY', 'RUHR', 'RUN', 'RW', 'RWE', 'RYUKYU', 'SA', 'SAARLAND', 'SAFE', 'SAFETY', 'SAKURA', 'SALE', 'SALON', 'SAMSCLUB', 'SAMSUNG', 'SANDVIK', 'SANDVIKCOROMANT', 'SANOFI', 'SAP', 'SARL', 'SAS', 'SAVE', 'SAXO', 'SB', 'SBI', 'SBS', 'SC', 'SCA', 'SCB', 'SCHAEFFLER', 'SCHMIDT', 'SCHOLARSHIPS', 'SCHOOL', 'SCHULE', 'SCHWARZ', 'SCIENCE', 'SCJOHNSON', 'SCOR', 'SCOT', 'SD', 'SE', 'SEARCH', 'SEAT', 'SECURE', 'SECURITY', 'SEEK', 'SELECT', 'SENER', 'SERVICES', 'SES', 'SEVEN', 'SEW', 'SEX', 'SEXY', 'SFR', 'SG', 'SH', 'SHANGRILA', 'SHARP', 'SHAW', 'SHELL', 'SHIA', 'SHIKSHA', 'SHOES', 'SHOP', 'SHOPPING', 'SHOUJI', 'SHOW', 'SHOWTIME', 'SHRIRAM', 'SI', 'SILK', 'SINA', 'SINGLES', 'SITE', 'SJ', 'SK', 'SKI', 'SKIN', 'SKY', 'SKYPE', 'SL', 'SLING', 'SM', 'SMART', 'SMILE', 'SN', 'SNCF', 'SO', 'SOCCER', 'SOCIAL', 'SOFTBANK', 'SOFTWARE', 'SOHU', 'SOLAR', 'SOLUTIONS', 'SONG', 'SONY', 'SOY', 'SPACE', 'SPORT', 'SPOT', 'SPREADBETTING', 'SR', 'SRL', 'SRT', 'SS', 'ST', 'STADA', 'STAPLES', 'STAR', 'STARHUB', 'STATEBANK', 'STATEFARM', 'STC', 'STCGROUP', 'STOCKHOLM', 'STORAGE', 'STORE', 'STREAM', 'STUDIO', 'STUDY', 'STYLE', 'SU', 'SUCKS', 'SUPPLIES', 'SUPPLY', 'SUPPORT', 'SURF', 'SURGERY', 'SUZUKI', 'SV', 'SWATCH', 'SWIFTCOVER', 'SWISS', 'SX', 'SY', 'SYDNEY', 'SYMANTEC', 'SYSTEMS', 'SZ', 'TAB', 'TAIPEI', 'TALK', 'TAOBAO', 'TARGET', 'TATAMOTORS', 'TATAR', 'TATTOO', 'TAX', 'TAXI', 'TC', 'TCI', 'TD', 'TDK', 'TEAM', 'TECH', 'TECHNOLOGY', 'TEL', 'TELEFONICA', 'TEMASEK', 'TENNIS', 'TEVA', 'TF', 'TG', 'TH', 'THD', 'THEATER', 'THEATRE', 'TIAA', 'TICKETS', 'TIENDA', 'TIFFANY', 'TIPS', 'TIRES', 'TIROL', 'TJ', 'TJMAXX', 'TJX', 'TK', 'TKMAXX', 'TL', 'TM', 'TMALL', 'TN', 'TO', 'TODAY', 'TOKYO', 'TOOLS', 'TOP', 'TORAY', 'TOSHIBA', 'TOTAL', 'TOURS', 'TOWN', 'TOYOTA', 'TOYS', 'TR', 'TRADE', 'TRADING', 'TRAINING', 'TRAVEL', 'TRAVELCHANNEL', 'TRAVELERS', 'TRAVELERSINSURANCE', 'TRUST', 'TRV', 'TT', 'TUBE', 'TUI', 'TUNES', 'TUSHU', 'TV', 'TVS', 'TW', 'TZ', 'UA', 'UBANK', 'UBS', 'UCONNECT', 'UG', 'UK', 'UNICOM', 'UNIVERSITY', 'UNO', 'UOL', 'UPS', 'US', 'UY', 'UZ', 'VA', 'VACATIONS', 'VANA', 'VANGUARD', 'VC', 'VE', 'VEGAS', 'VENTURES', 'VERISIGN', 'VERSICHERUNG', 'VET', 'VG', 'VI', 'VIAJES', 'VIDEO', 'VIG', 'VIKING', 'VILLAS', 'VIN', 'VIP', 'VIRGIN', 'VISA', 'VISION', 'VISTAPRINT', 'VIVA', 'VIVO', 'VLAANDEREN', 'VN', 'VODKA', 'VOLKSWAGEN', 'VOLVO', 'VOTE', 'VOTING', 'VOTO', 'VOYAGE', 'VU', 'VUELOS', 'WALES', 'WALMART', 'WALTER', 'WANG', 'WANGGOU', 'WARMAN', 'WATCH', 'WATCHES', 'WEATHER', 'WEATHERCHANNEL', 'WEBCAM', 'WEBER', 'WEBSITE', 'WED', 'WEDDING', 'WEIBO', 'WEIR', 'WF', 'WHOSWHO', 'WIEN', 'WIKI', 'WILLIAMHILL', 'WIN', 'WINDOWS', 'WINE', 'WINNERS', 'WME', 'WOLTERSKLUWER', 'WOODSIDE', 'WORK', 'WORKS', 'WORLD', 'WOW', 'WS', 'WTC', 'WTF', 'XBOX', 'XEROX', 'XFINITY', 'XIHUAN', 'XIN', 'XN--11B4C3D', 'XN--1CK2E1B', 'XN--1QQW23A', 'XN--2SCRJ9C', 'XN--30RR7Y', 'XN--3BST00M', 'XN--3DS443G', 'XN--3E0B707E', 'XN--3HCRJ9C', 'XN--3OQ18VL8PN36A', 'XN--3PXU8K', 'XN--42C2D9A', 'XN--45BR5CYL', 'XN--45BRJ9C', 'XN--45Q11C', 'XN--4GBRIM', 'XN--54B7FTA0CC', 'XN--55QW42G', 'XN--55QX5D', 'XN--5SU34J936BGSG', 'XN--5TZM5G', 'XN--6FRZ82G', 'XN--6QQ986B3XL', 'XN--80ADXHKS', 'XN--80AO21A', 'XN--80AQECDR1A', 'XN--80ASEHDB', 'XN--80ASWG', 'XN--8Y0A063A', 'XN--90A3AC', 'XN--90AE', 'XN--90AIS', 'XN--9DBQ2A', 'XN--9ET52U', 'XN--9KRT00A', 'XN--B4W605FERD', 'XN--BCK1B9A5DRE4C', 'XN--C1AVG', 'XN--C2BR7G', 'XN--CCK2B3B', 'XN--CG4BKI', 'XN--CLCHC0EA0B2G2A9GCD', 'XN--CZR694B', 'XN--CZRS0T', 'XN--CZRU2D', 'XN--D1ACJ3B', 'XN--D1ALF', 'XN--E1A4C', 'XN--ECKVDTC9D', 'XN--EFVY88H', 'XN--ESTV75G', 'XN--FCT429K', 'XN--FHBEI', 'XN--FIQ228C5HS', 'XN--FIQ64B', 'XN--FIQS8S', 'XN--FIQZ9S', 'XN--FJQ720A', 'XN--FLW351E', 'XN--FPCRJ9C3D', 'XN--FZC2C9E2C', 'XN--FZYS8D69UVGM', 'XN--G2XX48C', 'XN--GCKR3F0F', 'XN--GECRJ9C', 'XN--GK3AT1E', 'XN--H2BREG3EVE', 'XN--H2BRJ9C', 'XN--H2BRJ9C8C', 'XN--HXT814E', 'XN--I1B6B1A6A2E', 'XN--IMR513N', 'XN--IO0A7I', 'XN--J1AEF', 'XN--J1AMH', 'XN--J6W193G', 'XN--JLQ61U9W7B', 'XN--JVR189M', 'XN--KCRX77D1X4A', 'XN--KPRW13D', 'XN--KPRY57D', 'XN--KPU716F', 'XN--KPUT3I', 'XN--L1ACC', 'XN--LGBBAT1AD8J', 'XN--MGB9AWBF', 'XN--MGBA3A3EJT', 'XN--MGBA3A4F16A', 'XN--MGBA7C0BBN0A', 'XN--MGBAAKC7DVF', 'XN--MGBAAM7A8H', 'XN--MGBAB2BD', 'XN--MGBAH1A3HJKRD', 'XN--MGBAI9AZGQP6J', 'XN--MGBAYH7GPA', 'XN--MGBB9FBPOB', 'XN--MGBBH1A', 'XN--MGBBH1A71E', 'XN--MGBC0A9AZCG', 'XN--MGBCA7DZDO', 'XN--MGBERP4A5D4AR', 'XN--MGBGU82A', 'XN--MGBI4ECEXP', 'XN--MGBPL2FH', 'XN--MGBT3DHD', 'XN--MGBTX2B', 'XN--MGBX4CD0AB', 'XN--MIX891F', 'XN--MK1BU44C', 'XN--MXTQ1M', 'XN--NGBC5AZD', 'XN--NGBE9E0A', 'XN--NGBRX', 'XN--NODE', 'XN--NQV7F', 'XN--NQV7FS00EMA', 'XN--NYQY26A', 'XN--O3CW4H', 'XN--OGBPF8FL', 'XN--OTU796D', 'XN--P1ACF', 'XN--P1AI', 'XN--PBT977C', 'XN--PGBS0DH', 'XN--PSSY2U', 'XN--Q9JYB4C', 'XN--QCKA1PMC', 'XN--QXAM', 'XN--RHQV96G', 'XN--ROVU88B', 'XN--RVC1E0AM3E', 'XN--S9BRJ9C', 'XN--SES554G', 'XN--T60B56A', 'XN--TCKWE', 'XN--TIQ49XQYJ', 'XN--UNUP4Y', 'XN--VERMGENSBERATER-CTB', 'XN--VERMGENSBERATUNG-PWB', 'XN--VHQUV', 'XN--VUQ861B', 'XN--W4R85EL8FHU5DNRA', 'XN--W4RS40L', 'XN--WGBH1C', 'XN--WGBL6A', 'XN--XHQ521B', 'XN--XKC2AL3HYE2A', 'XN--XKC2DL3A5EE0H', 'XN--Y9A3AQ', 'XN--YFRO4I67O', 'XN--YGBI2AMMX', 'XN--ZFR164B', 'XXX', 'XYZ', 'YACHTS', 'YAHOO', 'YAMAXUN', 'YANDEX', 'YE', 'YODOBASHI', 'YOGA', 'YOKOHAMA', 'YOU', 'YOUTUBE', 'YT', 'YUN', 'ZA', 'ZAPPOS', 'ZARA', 'ZERO', 'ZIP', 'ZM', 'ZONE', 'ZUERICH', 'ZW']; // Keep as upper-case to make updating from source easier\n\nmodule.exports = new Set(internals.tlds.map(function (tld) {\n return tld.toLowerCase();\n}));" + "source": "'use strict';\n\nconst internals = {}; // http://data.iana.org/TLD/tlds-alpha-by-domain.txt\n// # Version 2019032300, Last Updated Sat Mar 23 07:07:02 2019 UTC\n\ninternals.tlds = ['AAA', 'AARP', 'ABARTH', 'ABB', 'ABBOTT', 'ABBVIE', 'ABC', 'ABLE', 'ABOGADO', 'ABUDHABI', 'AC', 'ACADEMY', 'ACCENTURE', 'ACCOUNTANT', 'ACCOUNTANTS', 'ACO', 'ACTOR', 'AD', 'ADAC', 'ADS', 'ADULT', 'AE', 'AEG', 'AERO', 'AETNA', 'AF', 'AFAMILYCOMPANY', 'AFL', 'AFRICA', 'AG', 'AGAKHAN', 'AGENCY', 'AI', 'AIG', 'AIGO', 'AIRBUS', 'AIRFORCE', 'AIRTEL', 'AKDN', 'AL', 'ALFAROMEO', 'ALIBABA', 'ALIPAY', 'ALLFINANZ', 'ALLSTATE', 'ALLY', 'ALSACE', 'ALSTOM', 'AM', 'AMERICANEXPRESS', 'AMERICANFAMILY', 'AMEX', 'AMFAM', 'AMICA', 'AMSTERDAM', 'ANALYTICS', 'ANDROID', 'ANQUAN', 'ANZ', 'AO', 'AOL', 'APARTMENTS', 'APP', 'APPLE', 'AQ', 'AQUARELLE', 'AR', 'ARAB', 'ARAMCO', 'ARCHI', 'ARMY', 'ARPA', 'ART', 'ARTE', 'AS', 'ASDA', 'ASIA', 'ASSOCIATES', 'AT', 'ATHLETA', 'ATTORNEY', 'AU', 'AUCTION', 'AUDI', 'AUDIBLE', 'AUDIO', 'AUSPOST', 'AUTHOR', 'AUTO', 'AUTOS', 'AVIANCA', 'AW', 'AWS', 'AX', 'AXA', 'AZ', 'AZURE', 'BA', 'BABY', 'BAIDU', 'BANAMEX', 'BANANAREPUBLIC', 'BAND', 'BANK', 'BAR', 'BARCELONA', 'BARCLAYCARD', 'BARCLAYS', 'BAREFOOT', 'BARGAINS', 'BASEBALL', 'BASKETBALL', 'BAUHAUS', 'BAYERN', 'BB', 'BBC', 'BBT', 'BBVA', 'BCG', 'BCN', 'BD', 'BE', 'BEATS', 'BEAUTY', 'BEER', 'BENTLEY', 'BERLIN', 'BEST', 'BESTBUY', 'BET', 'BF', 'BG', 'BH', 'BHARTI', 'BI', 'BIBLE', 'BID', 'BIKE', 'BING', 'BINGO', 'BIO', 'BIZ', 'BJ', 'BLACK', 'BLACKFRIDAY', 'BLOCKBUSTER', 'BLOG', 'BLOOMBERG', 'BLUE', 'BM', 'BMS', 'BMW', 'BN', 'BNL', 'BNPPARIBAS', 'BO', 'BOATS', 'BOEHRINGER', 'BOFA', 'BOM', 'BOND', 'BOO', 'BOOK', 'BOOKING', 'BOSCH', 'BOSTIK', 'BOSTON', 'BOT', 'BOUTIQUE', 'BOX', 'BR', 'BRADESCO', 'BRIDGESTONE', 'BROADWAY', 'BROKER', 'BROTHER', 'BRUSSELS', 'BS', 'BT', 'BUDAPEST', 'BUGATTI', 'BUILD', 'BUILDERS', 'BUSINESS', 'BUY', 'BUZZ', 'BV', 'BW', 'BY', 'BZ', 'BZH', 'CA', 'CAB', 'CAFE', 'CAL', 'CALL', 'CALVINKLEIN', 'CAM', 'CAMERA', 'CAMP', 'CANCERRESEARCH', 'CANON', 'CAPETOWN', 'CAPITAL', 'CAPITALONE', 'CAR', 'CARAVAN', 'CARDS', 'CARE', 'CAREER', 'CAREERS', 'CARS', 'CARTIER', 'CASA', 'CASE', 'CASEIH', 'CASH', 'CASINO', 'CAT', 'CATERING', 'CATHOLIC', 'CBA', 'CBN', 'CBRE', 'CBS', 'CC', 'CD', 'CEB', 'CENTER', 'CEO', 'CERN', 'CF', 'CFA', 'CFD', 'CG', 'CH', 'CHANEL', 'CHANNEL', 'CHARITY', 'CHASE', 'CHAT', 'CHEAP', 'CHINTAI', 'CHRISTMAS', 'CHROME', 'CHRYSLER', 'CHURCH', 'CI', 'CIPRIANI', 'CIRCLE', 'CISCO', 'CITADEL', 'CITI', 'CITIC', 'CITY', 'CITYEATS', 'CK', 'CL', 'CLAIMS', 'CLEANING', 'CLICK', 'CLINIC', 'CLINIQUE', 'CLOTHING', 'CLOUD', 'CLUB', 'CLUBMED', 'CM', 'CN', 'CO', 'COACH', 'CODES', 'COFFEE', 'COLLEGE', 'COLOGNE', 'COM', 'COMCAST', 'COMMBANK', 'COMMUNITY', 'COMPANY', 'COMPARE', 'COMPUTER', 'COMSEC', 'CONDOS', 'CONSTRUCTION', 'CONSULTING', 'CONTACT', 'CONTRACTORS', 'COOKING', 'COOKINGCHANNEL', 'COOL', 'COOP', 'CORSICA', 'COUNTRY', 'COUPON', 'COUPONS', 'COURSES', 'CR', 'CREDIT', 'CREDITCARD', 'CREDITUNION', 'CRICKET', 'CROWN', 'CRS', 'CRUISE', 'CRUISES', 'CSC', 'CU', 'CUISINELLA', 'CV', 'CW', 'CX', 'CY', 'CYMRU', 'CYOU', 'CZ', 'DABUR', 'DAD', 'DANCE', 'DATA', 'DATE', 'DATING', 'DATSUN', 'DAY', 'DCLK', 'DDS', 'DE', 'DEAL', 'DEALER', 'DEALS', 'DEGREE', 'DELIVERY', 'DELL', 'DELOITTE', 'DELTA', 'DEMOCRAT', 'DENTAL', 'DENTIST', 'DESI', 'DESIGN', 'DEV', 'DHL', 'DIAMONDS', 'DIET', 'DIGITAL', 'DIRECT', 'DIRECTORY', 'DISCOUNT', 'DISCOVER', 'DISH', 'DIY', 'DJ', 'DK', 'DM', 'DNP', 'DO', 'DOCS', 'DOCTOR', 'DODGE', 'DOG', 'DOHA', 'DOMAINS', 'DOT', 'DOWNLOAD', 'DRIVE', 'DTV', 'DUBAI', 'DUCK', 'DUNLOP', 'DUNS', 'DUPONT', 'DURBAN', 'DVAG', 'DVR', 'DZ', 'EARTH', 'EAT', 'EC', 'ECO', 'EDEKA', 'EDU', 'EDUCATION', 'EE', 'EG', 'EMAIL', 'EMERCK', 'ENERGY', 'ENGINEER', 'ENGINEERING', 'ENTERPRISES', 'EPSON', 'EQUIPMENT', 'ER', 'ERICSSON', 'ERNI', 'ES', 'ESQ', 'ESTATE', 'ESURANCE', 'ET', 'ETISALAT', 'EU', 'EUROVISION', 'EUS', 'EVENTS', 'EVERBANK', 'EXCHANGE', 'EXPERT', 'EXPOSED', 'EXPRESS', 'EXTRASPACE', 'FAGE', 'FAIL', 'FAIRWINDS', 'FAITH', 'FAMILY', 'FAN', 'FANS', 'FARM', 'FARMERS', 'FASHION', 'FAST', 'FEDEX', 'FEEDBACK', 'FERRARI', 'FERRERO', 'FI', 'FIAT', 'FIDELITY', 'FIDO', 'FILM', 'FINAL', 'FINANCE', 'FINANCIAL', 'FIRE', 'FIRESTONE', 'FIRMDALE', 'FISH', 'FISHING', 'FIT', 'FITNESS', 'FJ', 'FK', 'FLICKR', 'FLIGHTS', 'FLIR', 'FLORIST', 'FLOWERS', 'FLY', 'FM', 'FO', 'FOO', 'FOOD', 'FOODNETWORK', 'FOOTBALL', 'FORD', 'FOREX', 'FORSALE', 'FORUM', 'FOUNDATION', 'FOX', 'FR', 'FREE', 'FRESENIUS', 'FRL', 'FROGANS', 'FRONTDOOR', 'FRONTIER', 'FTR', 'FUJITSU', 'FUJIXEROX', 'FUN', 'FUND', 'FURNITURE', 'FUTBOL', 'FYI', 'GA', 'GAL', 'GALLERY', 'GALLO', 'GALLUP', 'GAME', 'GAMES', 'GAP', 'GARDEN', 'GB', 'GBIZ', 'GD', 'GDN', 'GE', 'GEA', 'GENT', 'GENTING', 'GEORGE', 'GF', 'GG', 'GGEE', 'GH', 'GI', 'GIFT', 'GIFTS', 'GIVES', 'GIVING', 'GL', 'GLADE', 'GLASS', 'GLE', 'GLOBAL', 'GLOBO', 'GM', 'GMAIL', 'GMBH', 'GMO', 'GMX', 'GN', 'GODADDY', 'GOLD', 'GOLDPOINT', 'GOLF', 'GOO', 'GOODYEAR', 'GOOG', 'GOOGLE', 'GOP', 'GOT', 'GOV', 'GP', 'GQ', 'GR', 'GRAINGER', 'GRAPHICS', 'GRATIS', 'GREEN', 'GRIPE', 'GROCERY', 'GROUP', 'GS', 'GT', 'GU', 'GUARDIAN', 'GUCCI', 'GUGE', 'GUIDE', 'GUITARS', 'GURU', 'GW', 'GY', 'HAIR', 'HAMBURG', 'HANGOUT', 'HAUS', 'HBO', 'HDFC', 'HDFCBANK', 'HEALTH', 'HEALTHCARE', 'HELP', 'HELSINKI', 'HERE', 'HERMES', 'HGTV', 'HIPHOP', 'HISAMITSU', 'HITACHI', 'HIV', 'HK', 'HKT', 'HM', 'HN', 'HOCKEY', 'HOLDINGS', 'HOLIDAY', 'HOMEDEPOT', 'HOMEGOODS', 'HOMES', 'HOMESENSE', 'HONDA', 'HONEYWELL', 'HORSE', 'HOSPITAL', 'HOST', 'HOSTING', 'HOT', 'HOTELES', 'HOTELS', 'HOTMAIL', 'HOUSE', 'HOW', 'HR', 'HSBC', 'HT', 'HU', 'HUGHES', 'HYATT', 'HYUNDAI', 'IBM', 'ICBC', 'ICE', 'ICU', 'ID', 'IE', 'IEEE', 'IFM', 'IKANO', 'IL', 'IM', 'IMAMAT', 'IMDB', 'IMMO', 'IMMOBILIEN', 'IN', 'INC', 'INDUSTRIES', 'INFINITI', 'INFO', 'ING', 'INK', 'INSTITUTE', 'INSURANCE', 'INSURE', 'INT', 'INTEL', 'INTERNATIONAL', 'INTUIT', 'INVESTMENTS', 'IO', 'IPIRANGA', 'IQ', 'IR', 'IRISH', 'IS', 'ISELECT', 'ISMAILI', 'IST', 'ISTANBUL', 'IT', 'ITAU', 'ITV', 'IVECO', 'JAGUAR', 'JAVA', 'JCB', 'JCP', 'JE', 'JEEP', 'JETZT', 'JEWELRY', 'JIO', 'JLL', 'JM', 'JMP', 'JNJ', 'JO', 'JOBS', 'JOBURG', 'JOT', 'JOY', 'JP', 'JPMORGAN', 'JPRS', 'JUEGOS', 'JUNIPER', 'KAUFEN', 'KDDI', 'KE', 'KERRYHOTELS', 'KERRYLOGISTICS', 'KERRYPROPERTIES', 'KFH', 'KG', 'KH', 'KI', 'KIA', 'KIM', 'KINDER', 'KINDLE', 'KITCHEN', 'KIWI', 'KM', 'KN', 'KOELN', 'KOMATSU', 'KOSHER', 'KP', 'KPMG', 'KPN', 'KR', 'KRD', 'KRED', 'KUOKGROUP', 'KW', 'KY', 'KYOTO', 'KZ', 'LA', 'LACAIXA', 'LADBROKES', 'LAMBORGHINI', 'LAMER', 'LANCASTER', 'LANCIA', 'LANCOME', 'LAND', 'LANDROVER', 'LANXESS', 'LASALLE', 'LAT', 'LATINO', 'LATROBE', 'LAW', 'LAWYER', 'LB', 'LC', 'LDS', 'LEASE', 'LECLERC', 'LEFRAK', 'LEGAL', 'LEGO', 'LEXUS', 'LGBT', 'LI', 'LIAISON', 'LIDL', 'LIFE', 'LIFEINSURANCE', 'LIFESTYLE', 'LIGHTING', 'LIKE', 'LILLY', 'LIMITED', 'LIMO', 'LINCOLN', 'LINDE', 'LINK', 'LIPSY', 'LIVE', 'LIVING', 'LIXIL', 'LK', 'LLC', 'LOAN', 'LOANS', 'LOCKER', 'LOCUS', 'LOFT', 'LOL', 'LONDON', 'LOTTE', 'LOTTO', 'LOVE', 'LPL', 'LPLFINANCIAL', 'LR', 'LS', 'LT', 'LTD', 'LTDA', 'LU', 'LUNDBECK', 'LUPIN', 'LUXE', 'LUXURY', 'LV', 'LY', 'MA', 'MACYS', 'MADRID', 'MAIF', 'MAISON', 'MAKEUP', 'MAN', 'MANAGEMENT', 'MANGO', 'MAP', 'MARKET', 'MARKETING', 'MARKETS', 'MARRIOTT', 'MARSHALLS', 'MASERATI', 'MATTEL', 'MBA', 'MC', 'MCKINSEY', 'MD', 'ME', 'MED', 'MEDIA', 'MEET', 'MELBOURNE', 'MEME', 'MEMORIAL', 'MEN', 'MENU', 'MERCKMSD', 'METLIFE', 'MG', 'MH', 'MIAMI', 'MICROSOFT', 'MIL', 'MINI', 'MINT', 'MIT', 'MITSUBISHI', 'MK', 'ML', 'MLB', 'MLS', 'MM', 'MMA', 'MN', 'MO', 'MOBI', 'MOBILE', 'MOBILY', 'MODA', 'MOE', 'MOI', 'MOM', 'MONASH', 'MONEY', 'MONSTER', 'MOPAR', 'MORMON', 'MORTGAGE', 'MOSCOW', 'MOTO', 'MOTORCYCLES', 'MOV', 'MOVIE', 'MOVISTAR', 'MP', 'MQ', 'MR', 'MS', 'MSD', 'MT', 'MTN', 'MTR', 'MU', 'MUSEUM', 'MUTUAL', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NAB', 'NADEX', 'NAGOYA', 'NAME', 'NATIONWIDE', 'NATURA', 'NAVY', 'NBA', 'NC', 'NE', 'NEC', 'NET', 'NETBANK', 'NETFLIX', 'NETWORK', 'NEUSTAR', 'NEW', 'NEWHOLLAND', 'NEWS', 'NEXT', 'NEXTDIRECT', 'NEXUS', 'NF', 'NFL', 'NG', 'NGO', 'NHK', 'NI', 'NICO', 'NIKE', 'NIKON', 'NINJA', 'NISSAN', 'NISSAY', 'NL', 'NO', 'NOKIA', 'NORTHWESTERNMUTUAL', 'NORTON', 'NOW', 'NOWRUZ', 'NOWTV', 'NP', 'NR', 'NRA', 'NRW', 'NTT', 'NU', 'NYC', 'NZ', 'OBI', 'OBSERVER', 'OFF', 'OFFICE', 'OKINAWA', 'OLAYAN', 'OLAYANGROUP', 'OLDNAVY', 'OLLO', 'OM', 'OMEGA', 'ONE', 'ONG', 'ONL', 'ONLINE', 'ONYOURSIDE', 'OOO', 'OPEN', 'ORACLE', 'ORANGE', 'ORG', 'ORGANIC', 'ORIGINS', 'OSAKA', 'OTSUKA', 'OTT', 'OVH', 'PA', 'PAGE', 'PANASONIC', 'PARIS', 'PARS', 'PARTNERS', 'PARTS', 'PARTY', 'PASSAGENS', 'PAY', 'PCCW', 'PE', 'PET', 'PF', 'PFIZER', 'PG', 'PH', 'PHARMACY', 'PHD', 'PHILIPS', 'PHONE', 'PHOTO', 'PHOTOGRAPHY', 'PHOTOS', 'PHYSIO', 'PIAGET', 'PICS', 'PICTET', 'PICTURES', 'PID', 'PIN', 'PING', 'PINK', 'PIONEER', 'PIZZA', 'PK', 'PL', 'PLACE', 'PLAY', 'PLAYSTATION', 'PLUMBING', 'PLUS', 'PM', 'PN', 'PNC', 'POHL', 'POKER', 'POLITIE', 'PORN', 'POST', 'PR', 'PRAMERICA', 'PRAXI', 'PRESS', 'PRIME', 'PRO', 'PROD', 'PRODUCTIONS', 'PROF', 'PROGRESSIVE', 'PROMO', 'PROPERTIES', 'PROPERTY', 'PROTECTION', 'PRU', 'PRUDENTIAL', 'PS', 'PT', 'PUB', 'PW', 'PWC', 'PY', 'QA', 'QPON', 'QUEBEC', 'QUEST', 'QVC', 'RACING', 'RADIO', 'RAID', 'RE', 'READ', 'REALESTATE', 'REALTOR', 'REALTY', 'RECIPES', 'RED', 'REDSTONE', 'REDUMBRELLA', 'REHAB', 'REISE', 'REISEN', 'REIT', 'RELIANCE', 'REN', 'RENT', 'RENTALS', 'REPAIR', 'REPORT', 'REPUBLICAN', 'REST', 'RESTAURANT', 'REVIEW', 'REVIEWS', 'REXROTH', 'RICH', 'RICHARDLI', 'RICOH', 'RIGHTATHOME', 'RIL', 'RIO', 'RIP', 'RMIT', 'RO', 'ROCHER', 'ROCKS', 'RODEO', 'ROGERS', 'ROOM', 'RS', 'RSVP', 'RU', 'RUGBY', 'RUHR', 'RUN', 'RW', 'RWE', 'RYUKYU', 'SA', 'SAARLAND', 'SAFE', 'SAFETY', 'SAKURA', 'SALE', 'SALON', 'SAMSCLUB', 'SAMSUNG', 'SANDVIK', 'SANDVIKCOROMANT', 'SANOFI', 'SAP', 'SARL', 'SAS', 'SAVE', 'SAXO', 'SB', 'SBI', 'SBS', 'SC', 'SCA', 'SCB', 'SCHAEFFLER', 'SCHMIDT', 'SCHOLARSHIPS', 'SCHOOL', 'SCHULE', 'SCHWARZ', 'SCIENCE', 'SCJOHNSON', 'SCOR', 'SCOT', 'SD', 'SE', 'SEARCH', 'SEAT', 'SECURE', 'SECURITY', 'SEEK', 'SELECT', 'SENER', 'SERVICES', 'SES', 'SEVEN', 'SEW', 'SEX', 'SEXY', 'SFR', 'SG', 'SH', 'SHANGRILA', 'SHARP', 'SHAW', 'SHELL', 'SHIA', 'SHIKSHA', 'SHOES', 'SHOP', 'SHOPPING', 'SHOUJI', 'SHOW', 'SHOWTIME', 'SHRIRAM', 'SI', 'SILK', 'SINA', 'SINGLES', 'SITE', 'SJ', 'SK', 'SKI', 'SKIN', 'SKY', 'SKYPE', 'SL', 'SLING', 'SM', 'SMART', 'SMILE', 'SN', 'SNCF', 'SO', 'SOCCER', 'SOCIAL', 'SOFTBANK', 'SOFTWARE', 'SOHU', 'SOLAR', 'SOLUTIONS', 'SONG', 'SONY', 'SOY', 'SPACE', 'SPORT', 'SPOT', 'SPREADBETTING', 'SR', 'SRL', 'SRT', 'SS', 'ST', 'STADA', 'STAPLES', 'STAR', 'STARHUB', 'STATEBANK', 'STATEFARM', 'STC', 'STCGROUP', 'STOCKHOLM', 'STORAGE', 'STORE', 'STREAM', 'STUDIO', 'STUDY', 'STYLE', 'SU', 'SUCKS', 'SUPPLIES', 'SUPPLY', 'SUPPORT', 'SURF', 'SURGERY', 'SUZUKI', 'SV', 'SWATCH', 'SWIFTCOVER', 'SWISS', 'SX', 'SY', 'SYDNEY', 'SYMANTEC', 'SYSTEMS', 'SZ', 'TAB', 'TAIPEI', 'TALK', 'TAOBAO', 'TARGET', 'TATAMOTORS', 'TATAR', 'TATTOO', 'TAX', 'TAXI', 'TC', 'TCI', 'TD', 'TDK', 'TEAM', 'TECH', 'TECHNOLOGY', 'TEL', 'TELEFONICA', 'TEMASEK', 'TENNIS', 'TEVA', 'TF', 'TG', 'TH', 'THD', 'THEATER', 'THEATRE', 'TIAA', 'TICKETS', 'TIENDA', 'TIFFANY', 'TIPS', 'TIRES', 'TIROL', 'TJ', 'TJMAXX', 'TJX', 'TK', 'TKMAXX', 'TL', 'TM', 'TMALL', 'TN', 'TO', 'TODAY', 'TOKYO', 'TOOLS', 'TOP', 'TORAY', 'TOSHIBA', 'TOTAL', 'TOURS', 'TOWN', 'TOYOTA', 'TOYS', 'TR', 'TRADE', 'TRADING', 'TRAINING', 'TRAVEL', 'TRAVELCHANNEL', 'TRAVELERS', 'TRAVELERSINSURANCE', 'TRUST', 'TRV', 'TT', 'TUBE', 'TUI', 'TUNES', 'TUSHU', 'TV', 'TVS', 'TW', 'TZ', 'UA', 'UBANK', 'UBS', 'UCONNECT', 'UG', 'UK', 'UNICOM', 'UNIVERSITY', 'UNO', 'UOL', 'UPS', 'US', 'UY', 'UZ', 'VA', 'VACATIONS', 'VANA', 'VANGUARD', 'VC', 'VE', 'VEGAS', 'VENTURES', 'VERISIGN', 'VERSICHERUNG', 'VET', 'VG', 'VI', 'VIAJES', 'VIDEO', 'VIG', 'VIKING', 'VILLAS', 'VIN', 'VIP', 'VIRGIN', 'VISA', 'VISION', 'VISTAPRINT', 'VIVA', 'VIVO', 'VLAANDEREN', 'VN', 'VODKA', 'VOLKSWAGEN', 'VOLVO', 'VOTE', 'VOTING', 'VOTO', 'VOYAGE', 'VU', 'VUELOS', 'WALES', 'WALMART', 'WALTER', 'WANG', 'WANGGOU', 'WARMAN', 'WATCH', 'WATCHES', 'WEATHER', 'WEATHERCHANNEL', 'WEBCAM', 'WEBER', 'WEBSITE', 'WED', 'WEDDING', 'WEIBO', 'WEIR', 'WF', 'WHOSWHO', 'WIEN', 'WIKI', 'WILLIAMHILL', 'WIN', 'WINDOWS', 'WINE', 'WINNERS', 'WME', 'WOLTERSKLUWER', 'WOODSIDE', 'WORK', 'WORKS', 'WORLD', 'WOW', 'WS', 'WTC', 'WTF', 'XBOX', 'XEROX', 'XFINITY', 'XIHUAN', 'XIN', 'XN--11B4C3D', 'XN--1CK2E1B', 'XN--1QQW23A', 'XN--2SCRJ9C', 'XN--30RR7Y', 'XN--3BST00M', 'XN--3DS443G', 'XN--3E0B707E', 'XN--3HCRJ9C', 'XN--3OQ18VL8PN36A', 'XN--3PXU8K', 'XN--42C2D9A', 'XN--45BR5CYL', 'XN--45BRJ9C', 'XN--45Q11C', 'XN--4GBRIM', 'XN--54B7FTA0CC', 'XN--55QW42G', 'XN--55QX5D', 'XN--5SU34J936BGSG', 'XN--5TZM5G', 'XN--6FRZ82G', 'XN--6QQ986B3XL', 'XN--80ADXHKS', 'XN--80AO21A', 'XN--80AQECDR1A', 'XN--80ASEHDB', 'XN--80ASWG', 'XN--8Y0A063A', 'XN--90A3AC', 'XN--90AE', 'XN--90AIS', 'XN--9DBQ2A', 'XN--9ET52U', 'XN--9KRT00A', 'XN--B4W605FERD', 'XN--BCK1B9A5DRE4C', 'XN--C1AVG', 'XN--C2BR7G', 'XN--CCK2B3B', 'XN--CG4BKI', 'XN--CLCHC0EA0B2G2A9GCD', 'XN--CZR694B', 'XN--CZRS0T', 'XN--CZRU2D', 'XN--D1ACJ3B', 'XN--D1ALF', 'XN--E1A4C', 'XN--ECKVDTC9D', 'XN--EFVY88H', 'XN--ESTV75G', 'XN--FCT429K', 'XN--FHBEI', 'XN--FIQ228C5HS', 'XN--FIQ64B', 'XN--FIQS8S', 'XN--FIQZ9S', 'XN--FJQ720A', 'XN--FLW351E', 'XN--FPCRJ9C3D', 'XN--FZC2C9E2C', 'XN--FZYS8D69UVGM', 'XN--G2XX48C', 'XN--GCKR3F0F', 'XN--GECRJ9C', 'XN--GK3AT1E', 'XN--H2BREG3EVE', 'XN--H2BRJ9C', 'XN--H2BRJ9C8C', 'XN--HXT814E', 'XN--I1B6B1A6A2E', 'XN--IMR513N', 'XN--IO0A7I', 'XN--J1AEF', 'XN--J1AMH', 'XN--J6W193G', 'XN--JLQ61U9W7B', 'XN--JVR189M', 'XN--KCRX77D1X4A', 'XN--KPRW13D', 'XN--KPRY57D', 'XN--KPU716F', 'XN--KPUT3I', 'XN--L1ACC', 'XN--LGBBAT1AD8J', 'XN--MGB9AWBF', 'XN--MGBA3A3EJT', 'XN--MGBA3A4F16A', 'XN--MGBA7C0BBN0A', 'XN--MGBAAKC7DVF', 'XN--MGBAAM7A8H', 'XN--MGBAB2BD', 'XN--MGBAH1A3HJKRD', 'XN--MGBAI9AZGQP6J', 'XN--MGBAYH7GPA', 'XN--MGBB9FBPOB', 'XN--MGBBH1A', 'XN--MGBBH1A71E', 'XN--MGBC0A9AZCG', 'XN--MGBCA7DZDO', 'XN--MGBERP4A5D4AR', 'XN--MGBGU82A', 'XN--MGBI4ECEXP', 'XN--MGBPL2FH', 'XN--MGBT3DHD', 'XN--MGBTX2B', 'XN--MGBX4CD0AB', 'XN--MIX891F', 'XN--MK1BU44C', 'XN--MXTQ1M', 'XN--NGBC5AZD', 'XN--NGBE9E0A', 'XN--NGBRX', 'XN--NODE', 'XN--NQV7F', 'XN--NQV7FS00EMA', 'XN--NYQY26A', 'XN--O3CW4H', 'XN--OGBPF8FL', 'XN--OTU796D', 'XN--P1ACF', 'XN--P1AI', 'XN--PBT977C', 'XN--PGBS0DH', 'XN--PSSY2U', 'XN--Q9JYB4C', 'XN--QCKA1PMC', 'XN--QXAM', 'XN--RHQV96G', 'XN--ROVU88B', 'XN--RVC1E0AM3E', 'XN--S9BRJ9C', 'XN--SES554G', 'XN--T60B56A', 'XN--TCKWE', 'XN--TIQ49XQYJ', 'XN--UNUP4Y', 'XN--VERMGENSBERATER-CTB', 'XN--VERMGENSBERATUNG-PWB', 'XN--VHQUV', 'XN--VUQ861B', 'XN--W4R85EL8FHU5DNRA', 'XN--W4RS40L', 'XN--WGBH1C', 'XN--WGBL6A', 'XN--XHQ521B', 'XN--XKC2AL3HYE2A', 'XN--XKC2DL3A5EE0H', 'XN--Y9A3AQ', 'XN--YFRO4I67O', 'XN--YGBI2AMMX', 'XN--ZFR164B', 'XXX', 'XYZ', 'YACHTS', 'YAHOO', 'YAMAXUN', 'YANDEX', 'YE', 'YODOBASHI', 'YOGA', 'YOKOHAMA', 'YOU', 'YOUTUBE', 'YT', 'YUN', 'ZA', 'ZAPPOS', 'ZARA', 'ZERO', 'ZIP', 'ZM', 'ZONE', 'ZUERICH', 'ZW']; // Keep as upper-case to make updating from source easier\n\nmodule.exports = new Set(internals.tlds.map(tld => tld.toLowerCase()));" }, { - "id": 50, + "id": 49, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/contain.js", "name": "../node_modules/@hapi/hoek/lib/contain.js", - "index": 49, - "index2": 47, - "size": 4364, + "index": 48, + "index2": 46, + "size": 3364, "cacheable": true, "built": true, "optional": false, @@ -4345,7 +4252,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", - "issuerId": 43, + "issuerId": 42, "issuerName": "../lib/types/string/index.js", "issuerPath": [ { @@ -4353,25 +4260,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 }, "failed": false, "errors": 0, @@ -4379,13 +4286,13 @@ "assets": [], "reasons": [ { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/contain", - "loc": "17:14-47" + "loc": "15:16-49" } ], "usedExports": true, @@ -4394,15 +4301,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('./assert');\n\nvar DeepEqual = require('./deepEqual');\n\nvar EscapeRegex = require('./escapeRegex');\n\nvar Utils = require('./utils');\n\nvar internals = {};\n\nmodule.exports = function (ref, values) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n // options: { deep, once, only, part, symbols }\n\n /*\n string -> string(s)\n array -> item(s)\n object -> key(s)\n object -> object (key:value)\n */\n var valuePairs = null;\n\n if (_typeof(ref) === 'object' && _typeof(values) === 'object' && !Array.isArray(ref) && !Array.isArray(values)) {\n valuePairs = values;\n var symbols = Object.getOwnPropertySymbols(values).filter(Object.prototype.propertyIsEnumerable.bind(values));\n values = [].concat(_toConsumableArray(Object.keys(values)), _toConsumableArray(symbols));\n } else {\n values = [].concat(values);\n }\n\n Assert(typeof ref === 'string' || _typeof(ref) === 'object', 'Reference must be string or an object');\n Assert(values.length, 'Values array cannot be empty');\n var compare;\n var compareFlags;\n\n if (options.deep) {\n compare = DeepEqual;\n var hasOnly = options.only !== undefined;\n var hasPart = options.part !== undefined;\n compareFlags = {\n prototype: hasOnly ? options.only : hasPart ? !options.part : false,\n part: hasOnly ? !options.only : hasPart ? options.part : false\n };\n } else {\n compare = function compare(a, b) {\n return a === b;\n };\n }\n\n var misses = false;\n var matches = new Array(values.length);\n\n for (var i = 0; i < matches.length; ++i) {\n matches[i] = 0;\n }\n\n if (typeof ref === 'string') {\n var pattern = '(';\n\n for (var _i = 0; _i < values.length; ++_i) {\n var value = values[_i];\n Assert(typeof value === 'string', 'Cannot compare string reference to non-string value');\n pattern += (_i ? '|' : '') + EscapeRegex(value);\n }\n\n var regex = new RegExp(pattern + ')', 'g');\n var leftovers = ref.replace(regex, function ($0, $1) {\n var index = values.indexOf($1);\n ++matches[index];\n return ''; // Remove from string\n });\n misses = !!leftovers;\n } else if (Array.isArray(ref)) {\n var onlyOnce = !!(options.only && options.once);\n\n if (onlyOnce && ref.length !== values.length) {\n return false;\n }\n\n for (var _i2 = 0; _i2 < ref.length; ++_i2) {\n var matched = false;\n\n for (var j = 0; j < values.length && matched === false; ++j) {\n if (!onlyOnce || matches[j] === 0) {\n matched = compare(values[j], ref[_i2], compareFlags) && j;\n }\n }\n\n if (matched !== false) {\n ++matches[matched];\n } else {\n misses = true;\n }\n }\n } else {\n var keys = Utils.keys(ref, options);\n\n for (var _i3 = 0; _i3 < keys.length; ++_i3) {\n var key = keys[_i3];\n var pos = values.indexOf(key);\n\n if (pos !== -1) {\n if (valuePairs && !compare(valuePairs[key], ref[key], compareFlags)) {\n return false;\n }\n\n ++matches[pos];\n } else {\n misses = true;\n }\n }\n }\n\n if (options.only) {\n if (misses || !options.once) {\n return !misses;\n }\n }\n\n var result = false;\n\n for (var _i4 = 0; _i4 < matches.length; ++_i4) {\n result = result || !!matches[_i4];\n\n if (options.once && matches[_i4] > 1 || !options.part && !matches[_i4]) {\n return false;\n }\n }\n\n return result;\n};" + "source": "'use strict';\n\nconst Assert = require('./assert');\n\nconst DeepEqual = require('./deepEqual');\n\nconst EscapeRegex = require('./escapeRegex');\n\nconst Utils = require('./utils');\n\nconst internals = {};\n\nmodule.exports = function (ref, values) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n // options: { deep, once, only, part, symbols }\n\n /*\n string -> string(s)\n array -> item(s)\n object -> key(s)\n object -> object (key:value)\n */\n let valuePairs = null;\n\n if (typeof ref === 'object' && typeof values === 'object' && !Array.isArray(ref) && !Array.isArray(values)) {\n valuePairs = values;\n const symbols = Object.getOwnPropertySymbols(values).filter(Object.prototype.propertyIsEnumerable.bind(values));\n values = [...Object.keys(values), ...symbols];\n } else {\n values = [].concat(values);\n }\n\n Assert(typeof ref === 'string' || typeof ref === 'object', 'Reference must be string or an object');\n Assert(values.length, 'Values array cannot be empty');\n let compare;\n let compareFlags;\n\n if (options.deep) {\n compare = DeepEqual;\n const hasOnly = options.only !== undefined;\n const hasPart = options.part !== undefined;\n compareFlags = {\n prototype: hasOnly ? options.only : hasPart ? !options.part : false,\n part: hasOnly ? !options.only : hasPart ? options.part : false\n };\n } else {\n compare = (a, b) => a === b;\n }\n\n let misses = false;\n const matches = new Array(values.length);\n\n for (let i = 0; i < matches.length; ++i) {\n matches[i] = 0;\n }\n\n if (typeof ref === 'string') {\n let pattern = '(';\n\n for (let i = 0; i < values.length; ++i) {\n const value = values[i];\n Assert(typeof value === 'string', 'Cannot compare string reference to non-string value');\n pattern += (i ? '|' : '') + EscapeRegex(value);\n }\n\n const regex = new RegExp(pattern + ')', 'g');\n const leftovers = ref.replace(regex, ($0, $1) => {\n const index = values.indexOf($1);\n ++matches[index];\n return ''; // Remove from string\n });\n misses = !!leftovers;\n } else if (Array.isArray(ref)) {\n const onlyOnce = !!(options.only && options.once);\n\n if (onlyOnce && ref.length !== values.length) {\n return false;\n }\n\n for (let i = 0; i < ref.length; ++i) {\n let matched = false;\n\n for (let j = 0; j < values.length && matched === false; ++j) {\n if (!onlyOnce || matches[j] === 0) {\n matched = compare(values[j], ref[i], compareFlags) && j;\n }\n }\n\n if (matched !== false) {\n ++matches[matched];\n } else {\n misses = true;\n }\n }\n } else {\n const keys = Utils.keys(ref, options);\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n const pos = values.indexOf(key);\n\n if (pos !== -1) {\n if (valuePairs && !compare(valuePairs[key], ref[key], compareFlags)) {\n return false;\n }\n\n ++matches[pos];\n } else {\n misses = true;\n }\n }\n }\n\n if (options.only) {\n if (misses || !options.once) {\n return !misses;\n }\n }\n\n let result = false;\n\n for (let i = 0; i < matches.length; ++i) {\n result = result || !!matches[i];\n\n if (options.once && matches[i] > 1 || !options.part && !matches[i]) {\n return false;\n }\n }\n\n return result;\n};" }, { - "id": 51, + "id": 50, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/ip.js", "name": "../lib/types/string/ip.js", - "index": 50, - "index2": 49, - "size": 780, + "index": 49, + "index2": 48, + "size": 760, "cacheable": true, "built": true, "optional": false, @@ -4411,7 +4318,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", - "issuerId": 43, + "issuerId": 42, "issuerName": "../lib/types/string/index.js", "issuerPath": [ { @@ -4419,25 +4326,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 }, "failed": false, "errors": 0, @@ -4445,13 +4352,13 @@ "assets": [], "reasons": [ { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "./ip", - "loc": "23:9-24" + "loc": "21:11-26" } ], "usedExports": true, @@ -4460,15 +4367,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nvar Uri = require('./uri');\n\nvar internals = {};\nexports.cidrs = {\n ipv4: {\n required: '\\\\/(?:' + Uri.ipv4Cidr + ')',\n optional: '(?:\\\\/(?:' + Uri.ipv4Cidr + '))?',\n forbidden: ''\n },\n ipv6: {\n required: '\\\\/' + Uri.ipv6Cidr,\n optional: '(?:\\\\/' + Uri.ipv6Cidr + ')?',\n forbidden: ''\n },\n ipvfuture: {\n required: '\\\\/' + Uri.ipv6Cidr,\n optional: '(?:\\\\/' + Uri.ipv6Cidr + ')?',\n forbidden: ''\n }\n};\nexports.versions = {\n ipv4: Uri.ipv4address,\n ipv6: Uri.ipv6address,\n ipvfuture: Uri.ipvFuture\n};\n\nexports.createIpRegex = function (versions, cidr) {\n var parts = versions.map(function (version) {\n return exports.versions[version] + exports.cidrs[version][cidr];\n });\n return new RegExp('^(?:' + parts.join('|') + ')$');\n};" + "source": "'use strict';\n\nconst Uri = require('./uri');\n\nconst internals = {};\nexports.cidrs = {\n ipv4: {\n required: '\\\\/(?:' + Uri.ipv4Cidr + ')',\n optional: '(?:\\\\/(?:' + Uri.ipv4Cidr + '))?',\n forbidden: ''\n },\n ipv6: {\n required: '\\\\/' + Uri.ipv6Cidr,\n optional: '(?:\\\\/' + Uri.ipv6Cidr + ')?',\n forbidden: ''\n },\n ipvfuture: {\n required: '\\\\/' + Uri.ipv6Cidr,\n optional: '(?:\\\\/' + Uri.ipv6Cidr + ')?',\n forbidden: ''\n }\n};\nexports.versions = {\n ipv4: Uri.ipv4address,\n ipv6: Uri.ipv6address,\n ipvfuture: Uri.ipvFuture\n};\n\nexports.createIpRegex = function (versions, cidr) {\n const parts = versions.map(version => exports.versions[version] + exports.cidrs[version][cidr]);\n return new RegExp('^(?:' + parts.join('|') + ')$');\n};" }, { - "id": 52, + "id": 51, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/symbol.js", "name": "../lib/types/symbol.js", - "index": 52, - "index2": 51, - "size": 7798, + "index": 51, + "index2": 50, + "size": 2221, "cacheable": true, "built": true, "optional": false, @@ -4485,15 +4392,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -4507,7 +4414,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/symbol", - "loc": "48:12-37" + "loc": "34:12-37" } ], "usedExports": true, @@ -4516,14 +4423,14 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Any = require('./any');\n\nvar internals = {};\n\ninternals.Map =\n/*#__PURE__*/\nfunction (_Map) {\n _inherits(_class, _Map);\n\n function _class() {\n _classCallCheck(this, _class);\n\n return _possibleConstructorReturn(this, _getPrototypeOf(_class).apply(this, arguments));\n }\n\n _createClass(_class, [{\n key: \"slice\",\n value: function slice() {\n return new internals.Map(this);\n }\n }]);\n\n return _class;\n}(_wrapNativeSuper(Map));\n\nmodule.exports = Any.extend({\n type: 'symbol',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.map = new internals.Map();\n },\n // Coerce\n coerce: {\n method: function method(schema, value, _ref) {\n var error = _ref.error;\n var lookup = schema.$_terms.map.get(value);\n\n if (lookup) {\n value = lookup;\n }\n\n if (!schema._flags.only || _typeof(value) === 'symbol') {\n return {\n value: value\n };\n }\n\n return {\n value: value,\n errors: error('symbol.map', {\n map: schema.$_terms.map\n })\n };\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n var error = _ref2.error;\n\n if (_typeof(value) !== 'symbol') {\n return {\n value: value,\n errors: error('symbol.base')\n };\n }\n },\n // Rules\n rules: {\n map: {\n method: function method(iterable) {\n if (iterable && !iterable[Symbol.iterator] && _typeof(iterable) === 'object') {\n iterable = Object.entries(iterable);\n }\n\n Assert(iterable && iterable[Symbol.iterator], 'Iterable must be an iterable or object');\n var obj = this.clone();\n var symbols = [];\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = iterable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var entry = _step.value;\n Assert(entry && entry[Symbol.iterator], 'Entry must be an iterable');\n\n var _entry = _slicedToArray(entry, 2),\n key = _entry[0],\n value = _entry[1];\n\n Assert(_typeof(key) !== 'object' && typeof key !== 'function' && _typeof(key) !== 'symbol', 'Key must not be of type object, function, or Symbol');\n Assert(_typeof(value) === 'symbol', 'Value must be a Symbol');\n obj.$_terms.map.set(key, value);\n symbols.push(value);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return obj.valid.apply(obj, symbols);\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n obj = obj.map(desc.map);\n return obj;\n },\n // Errors\n messages: {\n 'symbol.base': '\"{{#label}}\" must be a symbol',\n 'symbol.map': '\"{{#label}}\" must be one of {{#map}}'\n }\n});" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Any = require('./any');\n\nconst internals = {};\ninternals.Map = class extends Map {\n slice() {\n return new internals.Map(this);\n }\n\n};\nmodule.exports = Any.extend({\n type: 'symbol',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.map = new internals.Map();\n },\n // Coerce\n coerce: {\n method: function method(schema, value, _ref) {\n let {\n error\n } = _ref;\n const lookup = schema.$_terms.map.get(value);\n\n if (lookup) {\n value = lookup;\n }\n\n if (!schema._flags.only || typeof value === 'symbol') {\n return {\n value\n };\n }\n\n return {\n value,\n errors: error('symbol.map', {\n map: schema.$_terms.map\n })\n };\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n let {\n error\n } = _ref2;\n\n if (typeof value !== 'symbol') {\n return {\n value,\n errors: error('symbol.base')\n };\n }\n },\n // Rules\n rules: {\n map: {\n method: function method(iterable) {\n if (iterable && !iterable[Symbol.iterator] && typeof iterable === 'object') {\n iterable = Object.entries(iterable);\n }\n\n Assert(iterable && iterable[Symbol.iterator], 'Iterable must be an iterable or object');\n const obj = this.clone();\n const symbols = [];\n\n for (const entry of iterable) {\n Assert(entry && entry[Symbol.iterator], 'Entry must be an iterable');\n const [key, value] = entry;\n Assert(typeof key !== 'object' && typeof key !== 'function' && typeof key !== 'symbol', 'Key must not be of type object, function, or Symbol');\n Assert(typeof value === 'symbol', 'Value must be a Symbol');\n obj.$_terms.map.set(key, value);\n symbols.push(value);\n }\n\n return obj.valid(...symbols);\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n obj = obj.map(desc.map);\n return obj;\n },\n // Errors\n messages: {\n 'symbol.base': '\"{{#label}}\" must be a symbol',\n 'symbol.map': '\"{{#label}}\" must be one of {{#map}}'\n }\n});" }, { - "id": 53, + "id": 52, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/null-loader/dist/cjs.js!/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/binary.js", "name": "../lib/types/binary.js", - "index": 53, - "index2": 52, + "index": 52, + "index2": 51, "size": 0, "cacheable": true, "built": true, @@ -4541,15 +4448,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -4563,7 +4470,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/binary", - "loc": "54:27-52" + "loc": "40:27-52" } ], "usedExports": true, @@ -4595,7 +4502,7 @@ "name": "../node_modules/@hapi/hoek/lib/assert.js", "index": 1, "index2": 2, - "size": 418, + "size": 422, "cacheable": true, "built": true, "optional": false, @@ -4612,15 +4519,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -4634,7 +4541,7 @@ "moduleName": "../lib/common.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "19:13-45" + "loc": "3:15-47" }, { "moduleId": 3, @@ -4643,7 +4550,7 @@ "moduleName": "../lib/types/any.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "3:13-45" + "loc": "3:15-47" }, { "moduleId": 4, @@ -4652,7 +4559,7 @@ "moduleName": "../lib/template.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "27:13-45" + "loc": "3:15-47" }, { "moduleId": 5, @@ -4661,7 +4568,7 @@ "moduleName": "../lib/ref.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "27:13-45" + "loc": "3:15-47" }, { "moduleId": 6, @@ -4670,7 +4577,7 @@ "moduleName": "../lib/compile.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "5:13-45" + "loc": "3:15-47" }, { "moduleId": 9, @@ -4679,7 +4586,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/reach.js", "type": "cjs require", "userRequest": "./assert", - "loc": "13:13-32" + "loc": "3:15-34" }, { "moduleId": 10, @@ -4688,7 +4595,7 @@ "moduleName": "../lib/messages.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "5:13-45" + "loc": "3:15-47" }, { "moduleId": 14, @@ -4697,7 +4604,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "17:13-45" + "loc": "3:15-47" }, { "moduleId": 16, @@ -4706,7 +4613,7 @@ "moduleName": "../lib/cache.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "11:13-45" + "loc": "3:15-47" }, { "moduleId": 19, @@ -4715,7 +4622,7 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "21:13-45" + "loc": "3:15-47" }, { "moduleId": 20, @@ -4724,7 +4631,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/merge.js", "type": "cjs require", "userRequest": "./assert", - "loc": "5:13-32" + "loc": "3:15-34" }, { "moduleId": 23, @@ -4733,160 +4640,160 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "41:13-45" + "loc": "5:15-47" }, { - "moduleId": 25, + "moduleId": 24, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/uri.js", "module": "../lib/types/string/uri.js", "moduleName": "../lib/types/string/uri.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "3:13-45" + "loc": "3:15-47" }, { - "moduleId": 30, + "moduleId": 29, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "module": "../lib/types/alternatives.js", "moduleName": "../lib/types/alternatives.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "21:13-45" + "loc": "3:15-47" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "21:13-45" + "loc": "3:15-47" }, { - "moduleId": 32, + "moduleId": 31, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/extend.js", "module": "../lib/extend.js", "moduleName": "../lib/extend.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "13:13-45" + "loc": "3:15-47" }, { - "moduleId": 33, + "moduleId": 32, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/modify.js", "module": "../lib/modify.js", "moduleName": "../lib/modify.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "17:13-45" + "loc": "3:15-47" }, { - "moduleId": 34, + "moduleId": 33, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/validator.js", "module": "../lib/validator.js", "moduleName": "../lib/validator.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "23:13-45" + "loc": "3:15-47" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "13:13-45" + "loc": "3:15-47" }, { - "moduleId": 36, + "moduleId": 35, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", "module": "../lib/types/boolean.js", "moduleName": "../lib/types/boolean.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "11:13-45" + "loc": "3:15-47" }, { - "moduleId": 37, + "moduleId": 36, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/date.js", "module": "../lib/types/date.js", "moduleName": "../lib/types/date.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "3:13-45" + "loc": "3:15-47" }, { - "moduleId": 38, + "moduleId": 37, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/function.js", "module": "../lib/types/function.js", "moduleName": "../lib/types/function.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "3:13-45" + "loc": "3:15-47" }, { - "moduleId": 39, + "moduleId": 38, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/applyToDefaults.js", "module": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "moduleName": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "type": "cjs require", "userRequest": "./assert", - "loc": "5:13-32" + "loc": "3:15-34" }, { - "moduleId": 40, + "moduleId": 39, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/topo/lib/index.js", "module": "../node_modules/@hapi/topo/lib/index.js", "moduleName": "../node_modules/@hapi/topo/lib/index.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "9:13-45" + "loc": "3:15-47" }, { - "moduleId": 41, + "moduleId": 40, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/link.js", "module": "../lib/types/link.js", "moduleName": "../lib/types/link.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "3:13-45" + "loc": "3:15-47" }, { - "moduleId": 42, + "moduleId": 41, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/number.js", "module": "../lib/types/number.js", "moduleName": "../lib/types/number.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "3:13-45" + "loc": "3:15-47" }, { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "13:13-45" + "loc": "11:15-47" }, { - "moduleId": 50, + "moduleId": 49, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/contain.js", "module": "../node_modules/@hapi/hoek/lib/contain.js", "moduleName": "../node_modules/@hapi/hoek/lib/contain.js", "type": "cjs require", "userRequest": "./assert", - "loc": "13:13-32" + "loc": "3:15-34" }, { - "moduleId": 52, + "moduleId": 51, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/symbol.js", "module": "../lib/types/symbol.js", "moduleName": "../lib/types/symbol.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/assert", - "loc": "37:13-45" + "loc": "3:15-47" } ], "usedExports": true, @@ -4895,7 +4802,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar AssertError = require('./error');\n\nvar internals = {};\n\nmodule.exports = function (condition) {\n if (condition) {\n return;\n }\n\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n if (args.length === 1 && args[0] instanceof Error) {\n throw args[0];\n }\n\n throw new AssertError(args);\n};" + "source": "'use strict';\n\nconst AssertError = require('./error');\n\nconst internals = {};\n\nmodule.exports = function (condition) {\n if (condition) {\n return;\n }\n\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n if (args.length === 1 && args[0] instanceof Error) {\n throw args[0];\n }\n\n throw new AssertError(args);\n};" }, { "id": 1, @@ -4903,7 +4810,7 @@ "name": "../lib/common.js", "index": 9, "index2": 15, - "size": 8158, + "size": 5615, "cacheable": true, "built": true, "optional": false, @@ -4920,15 +4827,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -4942,7 +4849,7 @@ "moduleName": "../lib/template.js", "type": "cjs require", "userRequest": "./common", - "loc": "35:13-32" + "loc": "11:15-34" }, { "moduleId": 5, @@ -4951,7 +4858,7 @@ "moduleName": "../lib/ref.js", "type": "cjs require", "userRequest": "./common", - "loc": "33:13-32" + "loc": "9:15-34" }, { "moduleId": 6, @@ -4960,7 +4867,7 @@ "moduleName": "../lib/compile.js", "type": "cjs require", "userRequest": "./common", - "loc": "7:13-32" + "loc": "5:15-34" }, { "moduleId": 7, @@ -4969,7 +4876,7 @@ "moduleName": "../lib/errors.js", "type": "cjs require", "userRequest": "./common", - "loc": "39:13-32" + "loc": "5:15-34" }, { "moduleId": 14, @@ -4978,7 +4885,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./common", - "loc": "21:13-32" + "loc": "7:15-34" }, { "moduleId": 16, @@ -4987,7 +4894,7 @@ "moduleName": "../lib/cache.js", "type": "cjs require", "userRequest": "./common", - "loc": "15:13-32" + "loc": "7:15-34" }, { "moduleId": 19, @@ -4996,7 +4903,7 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "./common", - "loc": "25:13-32" + "loc": "7:15-34" }, { "moduleId": 21, @@ -5005,7 +4912,7 @@ "moduleName": "../lib/values.js", "type": "cjs require", "userRequest": "./common", - "loc": "19:13-32" + "loc": "3:15-34" }, { "moduleId": 23, @@ -5014,97 +4921,97 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "../common", - "loc": "51:13-33" + "loc": "15:15-35" }, { - "moduleId": 30, + "moduleId": 29, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "module": "../lib/types/alternatives.js", "moduleName": "../lib/types/alternatives.js", "type": "cjs require", "userRequest": "../common", - "loc": "25:13-33" + "loc": "7:15-35" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./common", - "loc": "31:13-32" + "loc": "13:15-34" }, { - "moduleId": 33, + "moduleId": 32, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/modify.js", "module": "../lib/modify.js", "moduleName": "../lib/modify.js", "type": "cjs require", "userRequest": "./common", - "loc": "19:13-32" + "loc": "5:15-34" }, { - "moduleId": 34, + "moduleId": 33, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/validator.js", "module": "../lib/validator.js", "moduleName": "../lib/validator.js", "type": "cjs require", "userRequest": "./common", - "loc": "29:13-32" + "loc": "9:15-34" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "../common", - "loc": "23:13-33" + "loc": "13:15-35" }, { - "moduleId": 36, + "moduleId": 35, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", "module": "../lib/types/boolean.js", "moduleName": "../lib/types/boolean.js", "type": "cjs require", "userRequest": "../common", - "loc": "15:13-33" + "loc": "7:15-35" }, { - "moduleId": 37, + "moduleId": 36, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/date.js", "module": "../lib/types/date.js", "moduleName": "../lib/types/date.js", "type": "cjs require", "userRequest": "../common", - "loc": "7:13-33" + "loc": "7:15-35" }, { - "moduleId": 41, + "moduleId": 40, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/link.js", "module": "../lib/types/link.js", "moduleName": "../lib/types/link.js", "type": "cjs require", "userRequest": "../common", - "loc": "7:13-33" + "loc": "7:15-35" }, { - "moduleId": 42, + "moduleId": 41, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/number.js", "module": "../lib/types/number.js", "moduleName": "../lib/types/number.js", "type": "cjs require", "userRequest": "../common", - "loc": "7:13-33" + "loc": "7:15-35" }, { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "../../common", - "loc": "21:13-36" + "loc": "19:15-38" } ], "usedExports": true, @@ -5113,7 +5020,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar AssertError = require('@hapi/hoek/lib/error');\n\nvar Marker = require('@hapi/marker');\n\nvar Pkg = require('../package.json');\n\nvar Messages;\nvar Schemas;\nvar internals = {\n isoDate: /^(?:[-+]\\d{2})?(?:\\d{4}(?!\\d{2}\\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\\1(?:[12]\\d|0[1-9]|3[01]))?|W(?:[0-4]\\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\\d|[12]\\d{2}|3(?:[0-5]\\d|6[1-6])))(?![T]$|[T][\\d]+Z$)(?:[T\\s](?:(?:(?:[01]\\d|2[0-3])(?:(:?)[0-5]\\d)?|24\\:?00)(?:[.,]\\d+(?!:))?)(?:\\2[0-5]\\d(?:[.,]\\d+)?)?(?:[Z]|(?:[+-])(?:[01]\\d|2[0-3])(?::?[0-5]\\d)?)?)?)?$/\n};\nexports.version = Pkg.version;\nexports.defaults = {\n abortEarly: true,\n allowUnknown: false,\n cache: true,\n context: null,\n convert: true,\n dateFormat: 'iso',\n errors: {\n escapeHtml: false,\n language: null,\n stack: false,\n wrapArrays: true\n },\n externals: true,\n messages: {},\n nonEnumerables: false,\n noDefaults: false,\n presence: 'optional',\n skipFunctions: false,\n stripUnknown: false,\n warnings: false\n};\nexports.symbols = {\n any: Marker('joi-any-base'),\n // Used to internally identify any-based types (shared with other joi versions)\n arraySingle: Symbol('arraySingle'),\n deepDefault: Symbol('deepDefault'),\n literal: Symbol('literal'),\n prefs: Symbol('prefs'),\n ref: Symbol('ref'),\n values: Symbol('values'),\n template: Symbol('template')\n};\n\nexports.assertOptions = function (options, keys) {\n var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Options';\n Assert(options && _typeof(options) === 'object' && !Array.isArray(options), 'Options must be of type object');\n var unknownKeys = Object.keys(options).filter(function (k) {\n return !keys.includes(k);\n });\n Assert(unknownKeys.length === 0, \"\".concat(name, \" contain unknown keys: \").concat(unknownKeys));\n};\n\nexports.checkPreferences = function (prefs) {\n Schemas = Schemas || require('./schemas');\n var result = Schemas.preferences.validate(prefs);\n\n if (result.error) {\n throw new AssertError([result.error.details[0].message]);\n }\n};\n\nexports.compare = function (a, b, operator) {\n switch (operator) {\n case '=':\n return a === b;\n\n case '>':\n return a > b;\n\n case '<':\n return a < b;\n\n case '>=':\n return a >= b;\n\n case '<=':\n return a <= b;\n }\n};\n\nexports.default = function (value, defaultValue) {\n return value === undefined ? defaultValue : value;\n};\n\nexports.isIsoDate = function (date) {\n return internals.isoDate.test(date);\n};\n\nexports.isNumber = function (value) {\n return typeof value === 'number' && !isNaN(value);\n};\n\nexports.isResolvable = function (obj) {\n if (!obj) {\n return false;\n }\n\n return obj[exports.symbols.ref] || obj[exports.symbols.template];\n};\n\nexports.isSchema = function (schema) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var any = schema && schema[exports.symbols.any];\n\n if (!any) {\n return false;\n }\n\n Assert(options.legacy || any.version === exports.version, 'Cannot mix different versions of joi schemas');\n return true;\n};\n\nexports.isValues = function (obj) {\n return obj[exports.symbols.values];\n};\n\nexports.limit = function (value) {\n return Number.isSafeInteger(value) && value >= 0;\n};\n\nexports.preferences = function (target, source) {\n Messages = Messages || require('./messages');\n target = target || {};\n var merged = Object.assign({}, target, source);\n\n if (source.errors && target.errors) {\n merged.errors = Object.assign({}, target.errors, source.errors);\n }\n\n if (source.messages) {\n merged.messages = Messages.compile(source.messages, target.messages);\n }\n\n delete merged[exports.symbols.prefs];\n return merged;\n};\n\nexports.State =\n/*#__PURE__*/\nfunction () {\n function _class(path, ancestors, state) {\n _classCallCheck(this, _class);\n\n this.path = path;\n this.ancestors = ancestors;\n this.mainstay = state.mainstay;\n this.schemas = state.schemas;\n }\n\n _createClass(_class, [{\n key: \"entry\",\n value: function entry(schema, reference) {\n var ancestors = reference !== undefined ? [reference] : [];\n var state = new exports.State([], ancestors, this);\n state.schemas = state.schemas && [].concat(_toConsumableArray(state.schemas), [schema]);\n return state;\n }\n }, {\n key: \"localize\",\n value: function localize(path) {\n var ancestors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var schema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n var state = new exports.State(path, ancestors, this);\n\n if (schema) {\n state.schemas = state.schemas && [].concat(_toConsumableArray(state.schemas), [schema]);\n }\n\n return state;\n }\n }, {\n key: \"nest\",\n value: function nest(schema) {\n var state = new exports.State(this.path, this.ancestors, this);\n state.schemas = state.schemas && [].concat(_toConsumableArray(state.schemas), [schema]);\n return state;\n }\n }]);\n\n return _class;\n}();\n\nexports.tryWithPath = function (fn, key) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n\n try {\n return fn();\n } catch (err) {\n if (err.path !== undefined) {\n err.path = key + '.' + err.path;\n } else {\n err.path = key;\n }\n\n if (options.append) {\n err.message = \"\".concat(err.message, \"(\").concat(err.path, \")\");\n }\n\n throw err;\n }\n};\n\nexports.validateArg = function (value, _ref) {\n var assert = _ref.assert,\n message = _ref.message;\n\n if (exports.isSchema(assert)) {\n var result = assert.validate(value);\n\n if (!result.error) {\n return;\n }\n\n return result.error.message;\n } else if (!assert(value)) {\n return message;\n }\n};\n\nexports.verifyFlat = function (args, method) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = args[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var arg = _step.value;\n Assert(!Array.isArray(arg), 'Method no longer accepts array arguments:', method);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst AssertError = require('@hapi/hoek/lib/error');\n\nconst Marker = require('@hapi/marker');\n\nconst Pkg = require('../package.json');\n\nlet Messages;\nlet Schemas;\nconst internals = {\n isoDate: /^(?:[-+]\\d{2})?(?:\\d{4}(?!\\d{2}\\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\\1(?:[12]\\d|0[1-9]|3[01]))?|W(?:[0-4]\\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\\d|[12]\\d{2}|3(?:[0-5]\\d|6[1-6])))(?![T]$|[T][\\d]+Z$)(?:[T\\s](?:(?:(?:[01]\\d|2[0-3])(?:(:?)[0-5]\\d)?|24\\:?00)(?:[.,]\\d+(?!:))?)(?:\\2[0-5]\\d(?:[.,]\\d+)?)?(?:[Z]|(?:[+-])(?:[01]\\d|2[0-3])(?::?[0-5]\\d)?)?)?)?$/\n};\nexports.version = Pkg.version;\nexports.defaults = {\n abortEarly: true,\n allowUnknown: false,\n cache: true,\n context: null,\n convert: true,\n dateFormat: 'iso',\n errors: {\n escapeHtml: false,\n language: null,\n stack: false,\n wrapArrays: true\n },\n externals: true,\n messages: {},\n nonEnumerables: false,\n noDefaults: false,\n presence: 'optional',\n skipFunctions: false,\n stripUnknown: false,\n warnings: false\n};\nexports.symbols = {\n any: Marker('joi-any-base'),\n // Used to internally identify any-based types (shared with other joi versions)\n arraySingle: Symbol('arraySingle'),\n deepDefault: Symbol('deepDefault'),\n literal: Symbol('literal'),\n prefs: Symbol('prefs'),\n ref: Symbol('ref'),\n values: Symbol('values'),\n template: Symbol('template')\n};\n\nexports.assertOptions = function (options, keys) {\n let name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Options';\n Assert(options && typeof options === 'object' && !Array.isArray(options), 'Options must be of type object');\n const unknownKeys = Object.keys(options).filter(k => !keys.includes(k));\n Assert(unknownKeys.length === 0, \"\".concat(name, \" contain unknown keys: \").concat(unknownKeys));\n};\n\nexports.checkPreferences = function (prefs) {\n Schemas = Schemas || require('./schemas');\n const result = Schemas.preferences.validate(prefs);\n\n if (result.error) {\n throw new AssertError([result.error.details[0].message]);\n }\n};\n\nexports.compare = function (a, b, operator) {\n switch (operator) {\n case '=':\n return a === b;\n\n case '>':\n return a > b;\n\n case '<':\n return a < b;\n\n case '>=':\n return a >= b;\n\n case '<=':\n return a <= b;\n }\n};\n\nexports.default = function (value, defaultValue) {\n return value === undefined ? defaultValue : value;\n};\n\nexports.isIsoDate = function (date) {\n return internals.isoDate.test(date);\n};\n\nexports.isNumber = function (value) {\n return typeof value === 'number' && !isNaN(value);\n};\n\nexports.isResolvable = function (obj) {\n if (!obj) {\n return false;\n }\n\n return obj[exports.symbols.ref] || obj[exports.symbols.template];\n};\n\nexports.isSchema = function (schema) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const any = schema && schema[exports.symbols.any];\n\n if (!any) {\n return false;\n }\n\n Assert(options.legacy || any.version === exports.version, 'Cannot mix different versions of joi schemas');\n return true;\n};\n\nexports.isValues = function (obj) {\n return obj[exports.symbols.values];\n};\n\nexports.limit = function (value) {\n return Number.isSafeInteger(value) && value >= 0;\n};\n\nexports.preferences = function (target, source) {\n Messages = Messages || require('./messages');\n target = target || {};\n const merged = Object.assign({}, target, source);\n\n if (source.errors && target.errors) {\n merged.errors = Object.assign({}, target.errors, source.errors);\n }\n\n if (source.messages) {\n merged.messages = Messages.compile(source.messages, target.messages);\n }\n\n delete merged[exports.symbols.prefs];\n return merged;\n};\n\nexports.State = class {\n constructor(path, ancestors, state) {\n this.path = path;\n this.ancestors = ancestors;\n this.mainstay = state.mainstay;\n this.schemas = state.schemas;\n }\n\n entry(schema, reference) {\n const ancestors = reference !== undefined ? [reference] : [];\n const state = new exports.State([], ancestors, this);\n state.schemas = state.schemas && [...state.schemas, schema];\n return state;\n }\n\n localize(path) {\n let ancestors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n let schema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n const state = new exports.State(path, ancestors, this);\n\n if (schema) {\n state.schemas = state.schemas && [...state.schemas, schema];\n }\n\n return state;\n }\n\n nest(schema) {\n const state = new exports.State(this.path, this.ancestors, this);\n state.schemas = state.schemas && [...state.schemas, schema];\n return state;\n }\n\n};\n\nexports.tryWithPath = function (fn, key) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n\n try {\n return fn();\n } catch (err) {\n if (err.path !== undefined) {\n err.path = key + '.' + err.path;\n } else {\n err.path = key;\n }\n\n if (options.append) {\n err.message = \"\".concat(err.message, \"(\").concat(err.path, \")\");\n }\n\n throw err;\n }\n};\n\nexports.validateArg = function (value, _ref) {\n let {\n assert,\n message\n } = _ref;\n\n if (exports.isSchema(assert)) {\n const result = assert.validate(value);\n\n if (!result.error) {\n return;\n }\n\n return result.error.message;\n } else if (!assert(value)) {\n return message;\n }\n};\n\nexports.verifyFlat = function (args, method) {\n for (const arg of args) {\n Assert(!Array.isArray(arg), 'Method no longer accepts array arguments:', method);\n }\n};" }, { "id": 2, @@ -5121,7 +5028,7 @@ "name": "../node_modules/@hapi/hoek/lib/clone.js", "index": 5, "index2": 6, - "size": 5673, + "size": 3257, "cacheable": true, "built": true, "optional": false, @@ -5138,8 +5045,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -5147,15 +5054,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/cache.js", "name": "../lib/cache.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1052, - "building": 123 + "factory": 614, + "building": 142 }, "failed": false, "errors": 0, @@ -5169,7 +5076,7 @@ "moduleName": "../lib/template.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "29:12-43" + "loc": "5:14-45" }, { "moduleId": 5, @@ -5178,7 +5085,7 @@ "moduleName": "../lib/ref.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "29:12-43" + "loc": "5:14-45" }, { "moduleId": 7, @@ -5187,7 +5094,7 @@ "moduleName": "../lib/errors.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "37:12-43" + "loc": "3:14-45" }, { "moduleId": 10, @@ -5196,7 +5103,7 @@ "moduleName": "../lib/messages.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "7:12-43" + "loc": "5:14-45" }, { "moduleId": 16, @@ -5205,7 +5112,7 @@ "moduleName": "../lib/cache.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "13:12-43" + "loc": "5:14-45" }, { "moduleId": 19, @@ -5214,7 +5121,7 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "23:12-43" + "loc": "5:14-45" }, { "moduleId": 20, @@ -5223,7 +5130,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/merge.js", "type": "cjs require", "userRequest": "./clone", - "loc": "7:12-30" + "loc": "5:14-32" }, { "moduleId": 23, @@ -5232,43 +5139,43 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "45:12-43" + "loc": "9:14-45" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "23:12-43" + "loc": "5:14-45" }, { - "moduleId": 32, + "moduleId": 31, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/extend.js", "module": "../lib/extend.js", "moduleName": "../lib/extend.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "15:12-43" + "loc": "5:14-45" }, { - "moduleId": 34, + "moduleId": 33, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/validator.js", "module": "../lib/validator.js", "moduleName": "../lib/validator.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/clone", - "loc": "25:12-43" + "loc": "5:14-45" }, { - "moduleId": 39, + "moduleId": 38, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/applyToDefaults.js", "module": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "moduleName": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "type": "cjs require", "userRequest": "./clone", - "loc": "7:12-30" + "loc": "5:14-32" } ], "usedExports": true, @@ -5277,7 +5184,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Types = require('./types');\n\nvar Utils = require('./utils');\n\nvar internals = {\n needsProtoHack: new Set([Types.set, Types.map, Types.weakSet, Types.weakMap])\n};\n\nmodule.exports = internals.clone = function (obj) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n var _seen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n\n if (_typeof(obj) !== 'object' || obj === null) {\n return obj;\n }\n\n var clone = internals.clone;\n var seen = _seen;\n\n if (options.shallow) {\n if (options.shallow !== true) {\n return internals.cloneWithShallow(obj, options);\n }\n\n clone = function clone(value) {\n return value;\n };\n } else {\n seen = seen || new Map();\n var lookup = seen.get(obj);\n\n if (lookup) {\n return lookup;\n }\n }\n\n var baseProto = Types.getInternalProto(obj);\n var newObj;\n\n switch (baseProto) {\n case Types.buffer:\n return Buffer && Buffer.from(obj);\n // $lab:coverage:ignore$\n\n case Types.date:\n return new Date(obj.getTime());\n\n case Types.regex:\n return new RegExp(obj);\n\n case Types.array:\n newObj = [];\n break;\n\n default:\n if (options.prototype !== false) {\n // Defaults to true\n var proto = Object.getPrototypeOf(obj);\n\n if (proto && proto.isImmutable) {\n return obj;\n }\n\n if (internals.needsProtoHack.has(baseProto)) {\n newObj = new proto.constructor();\n\n if (proto !== baseProto) {\n Object.setPrototypeOf(newObj, proto);\n }\n } else {\n newObj = Object.create(proto);\n }\n } else if (internals.needsProtoHack.has(baseProto)) {\n newObj = new baseProto.constructor();\n } else {\n newObj = {};\n }\n\n }\n\n if (seen) {\n seen.set(obj, newObj); // Set seen, since obj could recurse\n }\n\n if (baseProto === Types.set) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = obj[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var value = _step.value;\n newObj.add(clone(value, options, seen));\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n } else if (baseProto === Types.map) {\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = obj[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var _step2$value = _slicedToArray(_step2.value, 2),\n key = _step2$value[0],\n _value = _step2$value[1];\n\n newObj.set(key, clone(_value, options, seen));\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n\n var keys = Utils.keys(obj, options);\n\n for (var i = 0; i < keys.length; ++i) {\n var key = keys[i];\n\n if (baseProto === Types.array && key === 'length') {\n continue;\n }\n\n var descriptor = Object.getOwnPropertyDescriptor(obj, key);\n\n if (descriptor && (descriptor.get || descriptor.set)) {\n Object.defineProperty(newObj, key, descriptor);\n } else {\n Object.defineProperty(newObj, key, {\n enumerable: descriptor ? descriptor.enumerable : true,\n writable: true,\n configurable: true,\n value: clone(obj[key], options, seen)\n });\n }\n }\n\n if (baseProto === Types.array) {\n newObj.length = obj.length;\n }\n\n return newObj;\n};\n\ninternals.cloneWithShallow = function (source, options) {\n var keys = options.shallow;\n options = Object.assign({}, options);\n options.shallow = false;\n var storage = Utils.store(source, keys); // Move shallow copy items to storage\n\n var copy = internals.clone(source, options); // Deep copy the rest\n\n Utils.restore(copy, source, storage); // Shallow copy the stored items and restore\n\n return copy;\n};" + "source": "'use strict';\n\nconst Types = require('./types');\n\nconst Utils = require('./utils');\n\nconst internals = {\n needsProtoHack: new Set([Types.set, Types.map, Types.weakSet, Types.weakMap])\n};\n\nmodule.exports = internals.clone = function (obj) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n let _seen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n\n if (typeof obj !== 'object' || obj === null) {\n return obj;\n }\n\n let clone = internals.clone;\n let seen = _seen;\n\n if (options.shallow) {\n if (options.shallow !== true) {\n return internals.cloneWithShallow(obj, options);\n }\n\n clone = value => value;\n } else {\n seen = seen || new Map();\n const lookup = seen.get(obj);\n\n if (lookup) {\n return lookup;\n }\n }\n\n const baseProto = Types.getInternalProto(obj);\n let newObj;\n\n switch (baseProto) {\n case Types.buffer:\n return Buffer && Buffer.from(obj);\n // $lab:coverage:ignore$\n\n case Types.date:\n return new Date(obj.getTime());\n\n case Types.regex:\n return new RegExp(obj);\n\n case Types.array:\n newObj = [];\n break;\n\n default:\n if (options.prototype !== false) {\n // Defaults to true\n const proto = Object.getPrototypeOf(obj);\n\n if (proto && proto.isImmutable) {\n return obj;\n }\n\n if (internals.needsProtoHack.has(baseProto)) {\n newObj = new proto.constructor();\n\n if (proto !== baseProto) {\n Object.setPrototypeOf(newObj, proto);\n }\n } else {\n newObj = Object.create(proto);\n }\n } else if (internals.needsProtoHack.has(baseProto)) {\n newObj = new baseProto.constructor();\n } else {\n newObj = {};\n }\n\n }\n\n if (seen) {\n seen.set(obj, newObj); // Set seen, since obj could recurse\n }\n\n if (baseProto === Types.set) {\n for (const value of obj) {\n newObj.add(clone(value, options, seen));\n }\n } else if (baseProto === Types.map) {\n for (const [key, value] of obj) {\n newObj.set(key, clone(value, options, seen));\n }\n }\n\n const keys = Utils.keys(obj, options);\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n\n if (baseProto === Types.array && key === 'length') {\n continue;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n\n if (descriptor && (descriptor.get || descriptor.set)) {\n Object.defineProperty(newObj, key, descriptor);\n } else {\n Object.defineProperty(newObj, key, {\n enumerable: descriptor ? descriptor.enumerable : true,\n writable: true,\n configurable: true,\n value: clone(obj[key], options, seen)\n });\n }\n }\n\n if (baseProto === Types.array) {\n newObj.length = obj.length;\n }\n\n return newObj;\n};\n\ninternals.cloneWithShallow = function (source, options) {\n const keys = options.shallow;\n options = Object.assign({}, options);\n options.shallow = false;\n const storage = Utils.store(source, keys); // Move shallow copy items to storage\n\n const copy = internals.clone(source, options); // Deep copy the rest\n\n Utils.restore(copy, source, storage); // Shallow copy the stored items and restore\n\n return copy;\n};" }, { "id": 3, @@ -5285,7 +5192,7 @@ "name": "../lib/types/any.js", "index": 22, "index2": 27, - "size": 1218, + "size": 1213, "cacheable": true, "built": true, "optional": false, @@ -5302,15 +5209,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -5324,7 +5231,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/any", - "loc": "39:9-31" + "loc": "25:9-31" }, { "moduleId": 23, @@ -5333,79 +5240,79 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "./any", - "loc": "49:10-26" + "loc": "13:12-28" }, { - "moduleId": 30, + "moduleId": 29, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "module": "../lib/types/alternatives.js", "moduleName": "../lib/types/alternatives.js", "type": "cjs require", "userRequest": "./any", - "loc": "23:10-26" + "loc": "5:12-28" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "./any", - "loc": "21:10-26" + "loc": "11:12-28" }, { - "moduleId": 36, + "moduleId": 35, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", "module": "../lib/types/boolean.js", "moduleName": "../lib/types/boolean.js", "type": "cjs require", "userRequest": "./any", - "loc": "13:10-26" + "loc": "5:12-28" }, { - "moduleId": 37, + "moduleId": 36, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/date.js", "module": "../lib/types/date.js", "moduleName": "../lib/types/date.js", "type": "cjs require", "userRequest": "./any", - "loc": "5:10-26" + "loc": "5:12-28" }, { - "moduleId": 41, + "moduleId": 40, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/link.js", "module": "../lib/types/link.js", "moduleName": "../lib/types/link.js", "type": "cjs require", "userRequest": "./any", - "loc": "5:10-26" + "loc": "5:12-28" }, { - "moduleId": 42, + "moduleId": 41, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/number.js", "module": "../lib/types/number.js", "moduleName": "../lib/types/number.js", "type": "cjs require", "userRequest": "./any", - "loc": "5:10-26" + "loc": "5:12-28" }, { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "../any", - "loc": "19:10-27" + "loc": "17:12-29" }, { - "moduleId": 52, + "moduleId": 51, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/symbol.js", "module": "../lib/types/symbol.js", "moduleName": "../lib/types/symbol.js", "type": "cjs require", "userRequest": "./any", - "loc": "39:10-26" + "loc": "5:12-28" } ], "usedExports": true, @@ -5414,7 +5321,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Base = require('../base');\n\nvar internals = {};\nmodule.exports = Base.extend({\n type: 'any',\n // Rules\n rules: {\n warning: {\n method: function method(code, local) {\n Assert(code && typeof code === 'string', 'Invalid warning code');\n return this.$_addRule({\n name: 'warning',\n args: {\n code: code,\n local: local\n },\n warn: true\n });\n },\n validate: function validate(value, helpers, _ref) {\n var code = _ref.code,\n local = _ref.local;\n return helpers.error(code, local);\n },\n args: ['code', 'local'],\n multi: true\n }\n },\n // Errors\n messages: {\n 'any.default': '\"{{#label}}\" threw an error when running default method',\n 'any.failover': '\"{{#label}}\" threw an error when running failover method',\n 'any.invalid': '\"{{#label}}\" contains an invalid value',\n 'any.only': '\"{{#label}}\" must be one of {{#valids}}',\n 'any.ref': '\"{{#label}}\" {{#arg}} references \"{{#ref}}\" which {{#reason}}',\n 'any.required': '\"{{#label}}\" is required',\n 'any.unknown': '\"{{#label}}\" is not allowed'\n }\n});" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Base = require('../base');\n\nconst internals = {};\nmodule.exports = Base.extend({\n type: 'any',\n // Rules\n rules: {\n warning: {\n method: function method(code, local) {\n Assert(code && typeof code === 'string', 'Invalid warning code');\n return this.$_addRule({\n name: 'warning',\n args: {\n code,\n local\n },\n warn: true\n });\n },\n validate: function validate(value, helpers, _ref) {\n let {\n code,\n local\n } = _ref;\n return helpers.error(code, local);\n },\n args: ['code', 'local'],\n multi: true\n }\n },\n // Errors\n messages: {\n 'any.default': '\"{{#label}}\" threw an error when running default method',\n 'any.failover': '\"{{#label}}\" threw an error when running failover method',\n 'any.invalid': '\"{{#label}}\" contains an invalid value',\n 'any.only': '\"{{#label}}\" must be one of {{#valids}}',\n 'any.ref': '\"{{#label}}\" {{#arg}} references \"{{#ref}}\" which {{#reason}}',\n 'any.required': '\"{{#label}}\" is required',\n 'any.unknown': '\"{{#label}}\" is not allowed'\n }\n});" }, { "id": 4, @@ -5422,7 +5329,7 @@ "name": "../lib/template.js", "index": 14, "index2": 13, - "size": 14522, + "size": 7795, "cacheable": true, "built": true, "optional": false, @@ -5439,15 +5346,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -5461,7 +5368,7 @@ "moduleName": "../lib/ref.js", "type": "cjs require", "userRequest": "./template", - "loc": "431:29-50" + "loc": "340:27-48" }, { "moduleId": 7, @@ -5470,7 +5377,7 @@ "moduleName": "../lib/errors.js", "type": "cjs require", "userRequest": "./template", - "loc": "41:15-36" + "loc": "7:17-38" }, { "moduleId": 10, @@ -5479,7 +5386,7 @@ "moduleName": "../lib/messages.js", "type": "cjs require", "userRequest": "./template", - "loc": "9:15-36" + "loc": "7:17-38" }, { "moduleId": 14, @@ -5488,7 +5395,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./template", - "loc": "31:15-36" + "loc": "17:17-38" }, { "moduleId": 19, @@ -5497,7 +5404,7 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "./template", - "loc": "31:15-36" + "loc": "13:17-38" }, { "moduleId": 23, @@ -5506,16 +5413,16 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "../template", - "loc": "59:15-37" + "loc": "23:17-39" }, { - "moduleId": 37, + "moduleId": 36, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/date.js", "module": "../lib/types/date.js", "moduleName": "../lib/types/date.js", "type": "cjs require", "userRequest": "../template", - "loc": "9:15-37" + "loc": "9:17-39" } ], "usedExports": true, @@ -5524,7 +5431,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar EscapeHtml = require('@hapi/hoek/lib/escapeHtml');\n\nvar Formula = require('@hapi/formula');\n\nvar Common = require('./common');\n\nvar Ref = require('./ref');\n\nvar internals = {\n symbol: Symbol('template'),\n opens: new Array(1000).join(\"\\0\"),\n closes: new Array(1000).join(\"\\x01\"),\n dateFormat: {\n date: Date.prototype.toDateString,\n iso: Date.prototype.toISOString,\n string: Date.prototype.toString,\n time: Date.prototype.toTimeString,\n utc: Date.prototype.toUTCString\n }\n};\n\nmodule.exports = exports = internals.Template =\n/*#__PURE__*/\nfunction () {\n function _class(source, options) {\n _classCallCheck(this, _class);\n\n Assert(typeof source === 'string', 'Template source must be a string');\n Assert(!source.includes(\"\\0\") && !source.includes(\"\\x01\"), 'Template source cannot contain reserved control characters');\n this.source = source;\n this.rendered = source;\n this._template = null;\n this._settings = Clone(options);\n\n this._parse();\n }\n\n _createClass(_class, [{\n key: \"_parse\",\n value: function _parse() {\n // 'text {raw} {{ref}} \\\\{{ignore}} {{ignore\\\\}} {{ignore {{ignore}'\n if (!this.source.includes('{')) {\n return;\n } // Encode escaped \\\\{{{{{\n\n\n var encoded = internals.encode(this.source); // Split on first { in each set\n\n var parts = internals.split(encoded); // Process parts\n\n var refs = false;\n var processed = [];\n var head = parts.shift();\n\n if (head) {\n processed.push(head);\n }\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var part = _step.value;\n var raw = part[0] !== '{';\n var ender = raw ? '}' : '}}';\n var end = part.indexOf(ender);\n\n if (end === -1 || // Ignore non-matching closing\n part[1] === '{') {\n // Ignore more than two {\n processed.push(\"{\".concat(internals.decode(part)));\n continue;\n }\n\n var variable = part.slice(raw ? 0 : 1, end);\n\n var dynamic = this._ref(internals.decode(variable), raw);\n\n processed.push(dynamic);\n\n if (typeof dynamic !== 'string') {\n refs = true;\n }\n\n var rest = part.slice(end + ender.length);\n\n if (rest) {\n processed.push(internals.decode(rest));\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n if (!refs) {\n this.rendered = processed.join('');\n return;\n }\n\n this._template = processed;\n }\n }, {\n key: \"describe\",\n value: function describe() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n if (!this._settings && options.compact) {\n return this.source;\n }\n\n var desc = {\n template: this.source\n };\n\n if (this._settings) {\n desc.options = this._settings;\n }\n\n return desc;\n }\n }, {\n key: \"isDynamic\",\n value: function isDynamic() {\n return !!this._template;\n }\n }, {\n key: \"refs\",\n value: function refs() {\n if (!this._template) {\n return;\n }\n\n var refs = [];\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = this._template[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var part = _step2.value;\n\n if (typeof part !== 'string') {\n refs.push.apply(refs, _toConsumableArray(part.refs));\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return refs;\n }\n }, {\n key: \"resolve\",\n value: function resolve(value, state, prefs, local) {\n if (this._template && this._template.length === 1) {\n return this._part(this._template[0], value, state, prefs, local);\n }\n\n return this.render(value, state, prefs, local);\n }\n }, {\n key: \"_part\",\n value: function _part(part) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n if (part.ref) {\n var _part$ref;\n\n return (_part$ref = part.ref).resolve.apply(_part$ref, args);\n }\n\n return part.formula.evaluate(args);\n }\n }, {\n key: \"render\",\n value: function render(value, state, prefs, local) {\n var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};\n\n if (!this.isDynamic()) {\n return this.rendered;\n }\n\n var parts = [];\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = this._template[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var part = _step3.value;\n\n if (typeof part === 'string') {\n parts.push(part);\n } else {\n var string = internals.stringify(this._part(part, value, state, prefs, local), prefs, options);\n\n if (string !== undefined) {\n var result = part.raw || options.escapeHtml === false ? string : EscapeHtml(string);\n parts.push(result);\n }\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n return parts.join('');\n }\n }, {\n key: \"_ref\",\n value: function _ref(content, raw) {\n var _this = this;\n\n var refs = [];\n\n var reference = function reference(variable) {\n var ref = Ref.create(variable, _this._settings);\n refs.push(ref);\n return function (context) {\n return ref.resolve.apply(ref, _toConsumableArray(context));\n };\n };\n\n try {\n var formula = new Formula(content, {\n reference: reference,\n functions: internals.functions,\n constants: internals.constants\n });\n } catch (err) {\n err.message = \"Invalid template variable \\\"\".concat(content, \"\\\" fails due to: \").concat(err.message);\n throw err;\n }\n\n if (formula.single) {\n if (formula.single.type === 'reference') {\n return {\n ref: refs[0],\n raw: raw,\n refs: refs\n };\n }\n\n return internals.stringify(formula.single.value);\n }\n\n return {\n formula: formula,\n raw: raw,\n refs: refs\n };\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return this.source;\n }\n }], [{\n key: \"date\",\n value: function date(_date, prefs) {\n return internals.dateFormat[prefs.dateFormat].call(_date);\n }\n }, {\n key: \"build\",\n value: function build(desc) {\n return new internals.Template(desc.template, desc.options);\n }\n }, {\n key: \"isTemplate\",\n value: function isTemplate(template) {\n return template ? !!template[Common.symbols.template] : false;\n }\n }]);\n\n return _class;\n}();\n\ninternals.Template.prototype[Common.symbols.template] = true;\ninternals.Template.prototype.isImmutable = true; // Prevents Hoek from deep cloning schema objects\n\ninternals.encode = function (string) {\n return string.replace(/\\\\(\\{+)/g, function ($0, $1) {\n return internals.opens.slice(0, $1.length);\n }).replace(/\\\\(\\}+)/g, function ($0, $1) {\n return internals.closes.slice(0, $1.length);\n });\n};\n\ninternals.decode = function (string) {\n return string.replace(/\\u0000/g, '{').replace(/\\u0001/g, '}');\n};\n\ninternals.split = function (string) {\n var parts = [];\n var current = '';\n\n for (var i = 0; i < string.length; ++i) {\n var char = string[i];\n\n if (char === '{') {\n var next = '';\n\n while (i + 1 < string.length && string[i + 1] === '{') {\n next += '{';\n ++i;\n }\n\n parts.push(current);\n current = next;\n } else {\n current += char;\n }\n }\n\n parts.push(current);\n return parts;\n};\n\ninternals.stringify = function (value, prefs, options) {\n var type = _typeof(value);\n\n if (value === null) {\n return 'null';\n }\n\n if (type === 'string') {\n return value;\n }\n\n if (type === 'number' || type === 'function' || type === 'symbol') {\n return value.toString();\n }\n\n if (type !== 'object') {\n return JSON.stringify(value);\n }\n\n if (value instanceof Date) {\n return internals.Template.date(value, prefs);\n }\n\n if (value instanceof Map) {\n var pairs = [];\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = value.entries()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var _step4$value = _slicedToArray(_step4.value, 2),\n key = _step4$value[0],\n sym = _step4$value[1];\n\n pairs.push(\"\".concat(key.toString(), \" -> \").concat(sym.toString()));\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n\n value = pairs;\n }\n\n if (!Array.isArray(value)) {\n return value.toString();\n }\n\n var partial = '';\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = value[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var item = _step5.value;\n partial = partial + (partial.length ? ', ' : '') + internals.stringify(item, prefs, options);\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n\n return options.wrapArrays ? '[' + partial + ']' : partial;\n};\n\ninternals.constants = {\n true: true,\n false: false,\n null: null,\n second: 1000,\n minute: 60 * 1000,\n hour: 60 * 60 * 1000,\n day: 24 * 60 * 60 * 1000\n};\ninternals.functions = {\n if: function _if(condition, then, otherwise) {\n return condition ? then : otherwise;\n },\n number: function number(value) {\n if (typeof value === 'number') {\n return value;\n }\n\n if (typeof value === 'string') {\n return parseFloat(value);\n }\n\n if (typeof value === 'boolean') {\n return value ? 1 : 0;\n }\n\n if (value instanceof Date) {\n return value.getTime();\n }\n\n return null;\n }\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst EscapeHtml = require('@hapi/hoek/lib/escapeHtml');\n\nconst Formula = require('@hapi/formula');\n\nconst Common = require('./common');\n\nconst Ref = require('./ref');\n\nconst internals = {\n symbol: Symbol('template'),\n opens: new Array(1000).join('\\u0000'),\n closes: new Array(1000).join('\\u0001'),\n dateFormat: {\n date: Date.prototype.toDateString,\n iso: Date.prototype.toISOString,\n string: Date.prototype.toString,\n time: Date.prototype.toTimeString,\n utc: Date.prototype.toUTCString\n }\n};\nmodule.exports = exports = internals.Template = class {\n constructor(source, options) {\n Assert(typeof source === 'string', 'Template source must be a string');\n Assert(!source.includes('\\u0000') && !source.includes('\\u0001'), 'Template source cannot contain reserved control characters');\n this.source = source;\n this.rendered = source;\n this._template = null;\n this._settings = Clone(options);\n\n this._parse();\n }\n\n _parse() {\n // 'text {raw} {{ref}} \\\\{{ignore}} {{ignore\\\\}} {{ignore {{ignore}'\n if (!this.source.includes('{')) {\n return;\n } // Encode escaped \\\\{{{{{\n\n\n const encoded = internals.encode(this.source); // Split on first { in each set\n\n const parts = internals.split(encoded); // Process parts\n\n let refs = false;\n const processed = [];\n const head = parts.shift();\n\n if (head) {\n processed.push(head);\n }\n\n for (const part of parts) {\n const raw = part[0] !== '{';\n const ender = raw ? '}' : '}}';\n const end = part.indexOf(ender);\n\n if (end === -1 || // Ignore non-matching closing\n part[1] === '{') {\n // Ignore more than two {\n processed.push(\"{\".concat(internals.decode(part)));\n continue;\n }\n\n const variable = part.slice(raw ? 0 : 1, end);\n\n const dynamic = this._ref(internals.decode(variable), raw);\n\n processed.push(dynamic);\n\n if (typeof dynamic !== 'string') {\n refs = true;\n }\n\n const rest = part.slice(end + ender.length);\n\n if (rest) {\n processed.push(internals.decode(rest));\n }\n }\n\n if (!refs) {\n this.rendered = processed.join('');\n return;\n }\n\n this._template = processed;\n }\n\n static date(date, prefs) {\n return internals.dateFormat[prefs.dateFormat].call(date);\n }\n\n describe() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n if (!this._settings && options.compact) {\n return this.source;\n }\n\n const desc = {\n template: this.source\n };\n\n if (this._settings) {\n desc.options = this._settings;\n }\n\n return desc;\n }\n\n static build(desc) {\n return new internals.Template(desc.template, desc.options);\n }\n\n isDynamic() {\n return !!this._template;\n }\n\n static isTemplate(template) {\n return template ? !!template[Common.symbols.template] : false;\n }\n\n refs() {\n if (!this._template) {\n return;\n }\n\n const refs = [];\n\n for (const part of this._template) {\n if (typeof part !== 'string') {\n refs.push(...part.refs);\n }\n }\n\n return refs;\n }\n\n resolve(value, state, prefs, local) {\n if (this._template && this._template.length === 1) {\n return this._part(this._template[0], value, state, prefs, local);\n }\n\n return this.render(value, state, prefs, local);\n }\n\n _part(part) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n if (part.ref) {\n return part.ref.resolve(...args);\n }\n\n return part.formula.evaluate(args);\n }\n\n render(value, state, prefs, local) {\n let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};\n\n if (!this.isDynamic()) {\n return this.rendered;\n }\n\n const parts = [];\n\n for (const part of this._template) {\n if (typeof part === 'string') {\n parts.push(part);\n } else {\n const string = internals.stringify(this._part(part, value, state, prefs, local), prefs, options);\n\n if (string !== undefined) {\n const result = part.raw || options.escapeHtml === false ? string : EscapeHtml(string);\n parts.push(result);\n }\n }\n }\n\n return parts.join('');\n }\n\n _ref(content, raw) {\n const refs = [];\n\n const reference = variable => {\n const ref = Ref.create(variable, this._settings);\n refs.push(ref);\n return context => ref.resolve(...context);\n };\n\n try {\n var formula = new Formula(content, {\n reference,\n functions: internals.functions,\n constants: internals.constants\n });\n } catch (err) {\n err.message = \"Invalid template variable \\\"\".concat(content, \"\\\" fails due to: \").concat(err.message);\n throw err;\n }\n\n if (formula.single) {\n if (formula.single.type === 'reference') {\n return {\n ref: refs[0],\n raw,\n refs\n };\n }\n\n return internals.stringify(formula.single.value);\n }\n\n return {\n formula,\n raw,\n refs\n };\n }\n\n toString() {\n return this.source;\n }\n\n};\ninternals.Template.prototype[Common.symbols.template] = true;\ninternals.Template.prototype.isImmutable = true; // Prevents Hoek from deep cloning schema objects\n\ninternals.encode = function (string) {\n return string.replace(/\\\\(\\{+)/g, ($0, $1) => {\n return internals.opens.slice(0, $1.length);\n }).replace(/\\\\(\\}+)/g, ($0, $1) => {\n return internals.closes.slice(0, $1.length);\n });\n};\n\ninternals.decode = function (string) {\n return string.replace(/\\u0000/g, '{').replace(/\\u0001/g, '}');\n};\n\ninternals.split = function (string) {\n const parts = [];\n let current = '';\n\n for (let i = 0; i < string.length; ++i) {\n const char = string[i];\n\n if (char === '{') {\n let next = '';\n\n while (i + 1 < string.length && string[i + 1] === '{') {\n next += '{';\n ++i;\n }\n\n parts.push(current);\n current = next;\n } else {\n current += char;\n }\n }\n\n parts.push(current);\n return parts;\n};\n\ninternals.stringify = function (value, prefs, options) {\n const type = typeof value;\n\n if (value === null) {\n return 'null';\n }\n\n if (type === 'string') {\n return value;\n }\n\n if (type === 'number' || type === 'function' || type === 'symbol') {\n return value.toString();\n }\n\n if (type !== 'object') {\n return JSON.stringify(value);\n }\n\n if (value instanceof Date) {\n return internals.Template.date(value, prefs);\n }\n\n if (value instanceof Map) {\n const pairs = [];\n\n for (const [key, sym] of value.entries()) {\n pairs.push(\"\".concat(key.toString(), \" -> \").concat(sym.toString()));\n }\n\n value = pairs;\n }\n\n if (!Array.isArray(value)) {\n return value.toString();\n }\n\n let partial = '';\n\n for (const item of value) {\n partial = partial + (partial.length ? ', ' : '') + internals.stringify(item, prefs, options);\n }\n\n return options.wrapArrays ? '[' + partial + ']' : partial;\n};\n\ninternals.constants = {\n true: true,\n false: false,\n null: null,\n second: 1000,\n minute: 60 * 1000,\n hour: 60 * 60 * 1000,\n day: 24 * 60 * 60 * 1000\n};\ninternals.functions = {\n if: function _if(condition, then, otherwise) {\n return condition ? then : otherwise;\n },\n number: function number(value) {\n if (typeof value === 'number') {\n return value;\n }\n\n if (typeof value === 'string') {\n return parseFloat(value);\n }\n\n if (typeof value === 'boolean') {\n return value ? 1 : 0;\n }\n\n if (value instanceof Date) {\n return value.getTime();\n }\n\n return null;\n }\n};" }, { "id": 5, @@ -5532,7 +5439,7 @@ "name": "../lib/ref.js", "index": 17, "index2": 12, - "size": 13556, + "size": 8580, "cacheable": true, "built": true, "optional": false, @@ -5549,15 +5456,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -5571,7 +5478,7 @@ "moduleName": "../lib/template.js", "type": "cjs require", "userRequest": "./ref", - "loc": "37:10-26" + "loc": "13:12-28" }, { "moduleId": 6, @@ -5580,7 +5487,7 @@ "moduleName": "../lib/compile.js", "type": "cjs require", "userRequest": "./ref", - "loc": "9:10-26" + "loc": "7:12-28" }, { "moduleId": 14, @@ -5589,7 +5496,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./ref", - "loc": "29:10-26" + "loc": "15:12-28" }, { "moduleId": 19, @@ -5598,7 +5505,7 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "./ref", - "loc": "29:10-26" + "loc": "11:12-28" }, { "moduleId": 23, @@ -5607,25 +5514,25 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "../ref", - "loc": "57:10-27" + "loc": "21:12-29" }, { - "moduleId": 30, + "moduleId": 29, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "module": "../lib/types/alternatives.js", "moduleName": "../lib/types/alternatives.js", "type": "cjs require", "userRequest": "../ref", - "loc": "31:10-27" + "loc": "13:12-29" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./ref", - "loc": "45:10-26" + "loc": "27:12-28" } ], "usedExports": true, @@ -5634,7 +5541,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Reach = require('@hapi/hoek/lib/reach');\n\nvar Common = require('./common');\n\nvar Template;\nvar internals = {\n symbol: Symbol('ref'),\n // Used to internally identify references (shared with other joi versions)\n defaults: {\n adjust: null,\n iterables: null,\n map: null,\n separator: '.',\n type: 'value'\n }\n};\n\nexports.create = function (key) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(typeof key === 'string', 'Invalid reference key:', key);\n Common.assertOptions(options, ['adjust', 'ancestor', 'iterables', 'map', 'prefix', 'separator']);\n Assert(!options.prefix || _typeof(options.prefix) === 'object', 'options.prefix must be of type object');\n var ref = Object.assign({}, internals.defaults, options);\n delete ref.prefix;\n var separator = ref.separator;\n var context = internals.context(key, options.prefix);\n ref.type = context.type;\n key = context.key;\n\n if (ref.type === 'value') {\n if (context.root) {\n Assert(!separator || key[0] !== separator, 'Cannot specify relative path with root prefix');\n ref.ancestor = 'root';\n\n if (!key) {\n key = null;\n }\n }\n\n if (separator && separator === key) {\n key = null;\n ref.ancestor = 0;\n } else {\n if (ref.ancestor !== undefined) {\n Assert(!separator || !key || key[0] !== separator, 'Cannot combine prefix with ancestor option');\n } else {\n var _internals$ancestor = internals.ancestor(key, separator),\n _internals$ancestor2 = _slicedToArray(_internals$ancestor, 2),\n ancestor = _internals$ancestor2[0],\n slice = _internals$ancestor2[1];\n\n if (slice) {\n key = key.slice(slice);\n\n if (key === '') {\n key = null;\n }\n }\n\n ref.ancestor = ancestor;\n }\n }\n }\n\n ref.path = separator ? key === null ? [] : key.split(separator) : [key];\n return new internals.Ref(ref);\n};\n\nexports.isRef = function (ref) {\n return ref ? !!ref[Common.symbols.ref] : false;\n};\n\ninternals.Ref =\n/*#__PURE__*/\nfunction () {\n function _class(options) {\n _classCallCheck(this, _class);\n\n Assert(_typeof(options) === 'object', 'Invalid reference construction');\n Common.assertOptions(options, ['adjust', 'ancestor', 'iterables', 'map', 'path', 'separator', 'type', // Copied\n 'depth', 'key', 'root', 'display' // Overridden\n ]);\n Assert([false, undefined].includes(options.separator) || typeof options.separator === 'string' && options.separator.length === 1, 'Invalid separator');\n Assert(!options.adjust || typeof options.adjust === 'function', 'options.adjust must be a function');\n Assert(!options.map || Array.isArray(options.map), 'options.map must be an array');\n Assert(!options.map || !options.adjust, 'Cannot set both map and adjust options');\n Object.assign(this, internals.defaults, options);\n Assert(this.type === 'value' || this.ancestor === undefined, 'Non-value references cannot reference ancestors');\n\n if (Array.isArray(this.map)) {\n this.map = new Map(this.map);\n }\n\n this.depth = this.path.length;\n this.key = this.path.length ? this.path.join(this.separator) : null;\n this.root = this.path[0];\n this.updateDisplay();\n }\n\n _createClass(_class, [{\n key: \"resolve\",\n value: function resolve(value, state, prefs, local) {\n var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};\n\n if (this.type === 'global') {\n return this._resolve(prefs.context, state, options);\n }\n\n if (this.type === 'local') {\n return this._resolve(local, state, options);\n }\n\n if (!this.ancestor) {\n return this._resolve(value, state, options);\n }\n\n if (this.ancestor === 'root') {\n return this._resolve(state.ancestors[state.ancestors.length - 1], state, options);\n }\n\n Assert(this.ancestor <= state.ancestors.length, 'Invalid reference exceeds the schema root:', this.display);\n return this._resolve(state.ancestors[this.ancestor - 1], state, options);\n }\n }, {\n key: \"_resolve\",\n value: function _resolve(target, state, options) {\n var resolved;\n\n if (this.type === 'value' && state.mainstay && state.mainstay.shadow && options.shadow !== false) {\n resolved = state.mainstay.shadow.get(this.path);\n }\n\n if (resolved === undefined) {\n resolved = Reach(target, this.path, {\n iterables: this.iterables,\n functions: true\n });\n }\n\n if (this.adjust) {\n resolved = this.adjust(resolved);\n }\n\n if (this.map) {\n var mapped = this.map.get(resolved);\n\n if (mapped !== undefined) {\n return mapped;\n }\n }\n\n return resolved;\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return this.display;\n }\n }, {\n key: \"clone\",\n value: function clone() {\n return new internals.Ref(this);\n }\n }, {\n key: \"describe\",\n value: function describe() {\n var ref = {\n path: this.path\n };\n\n if (this.type !== 'value') {\n ref.type = this.type;\n }\n\n if (this.separator !== '.') {\n ref.separator = this.separator;\n }\n\n if (this.type === 'value' && this.ancestor !== 1) {\n ref.ancestor = this.ancestor;\n }\n\n if (this.map) {\n ref.map = _toConsumableArray(this.map);\n }\n\n for (var _i2 = 0, _arr2 = ['adjust', 'iterables']; _i2 < _arr2.length; _i2++) {\n var key = _arr2[_i2];\n\n if (this[key] !== null) {\n ref[key] = this[key];\n }\n }\n\n return {\n ref: ref\n };\n }\n }, {\n key: \"updateDisplay\",\n value: function updateDisplay() {\n if (this.type !== 'value') {\n this.display = \"ref:\".concat(this.type, \":\").concat(this.key);\n return;\n }\n\n if (!this.separator) {\n this.display = \"ref:\".concat(this.key);\n return;\n }\n\n if (!this.ancestor) {\n this.display = \"ref:\".concat(this.separator).concat(this.key);\n return;\n }\n\n if (this.ancestor === 'root') {\n this.display = \"ref:root:\".concat(this.key);\n return;\n }\n\n if (this.ancestor === 1) {\n this.display = \"ref:\".concat(this.key);\n return;\n }\n\n var lead = new Array(this.ancestor + 1).fill(this.separator).join('');\n this.display = \"ref:\".concat(lead).concat(this.key || '');\n }\n }]);\n\n return _class;\n}();\n\ninternals.Ref.prototype[Common.symbols.ref] = true;\n\nexports.build = function (desc) {\n desc = Object.assign({}, internals.defaults, desc);\n\n if (desc.type === 'value' && desc.ancestor === undefined) {\n desc.ancestor = 1;\n }\n\n return new internals.Ref(desc);\n};\n\ninternals.context = function (key) {\n var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n key = key.trim();\n var globalp = prefix.global || '$';\n\n if (key.startsWith(globalp)) {\n return {\n key: key.slice(globalp.length),\n type: 'global'\n };\n }\n\n var local = prefix.local || '#';\n\n if (key.startsWith(local)) {\n return {\n key: key.slice(local.length),\n type: 'local'\n };\n }\n\n var root = prefix.root || '/';\n\n if (key.startsWith(root)) {\n return {\n key: key.slice(root.length),\n type: 'value',\n root: true\n };\n }\n\n return {\n key: key,\n type: 'value'\n };\n};\n\ninternals.ancestor = function (key, separator) {\n if (!separator) {\n return [1, 0]; // 'a_b' -> 1 (parent)\n }\n\n if (key[0] !== separator) {\n // 'a.b' -> 1 (parent)\n return [1, 0];\n }\n\n if (key[1] !== separator) {\n // '.a.b' -> 0 (self)\n return [0, 1];\n }\n\n var i = 2;\n\n while (key[i] === separator) {\n ++i;\n }\n\n return [i - 1, i]; // '...a.b.' -> 2 (grandparent)\n};\n\nexports.toSibling = 0;\nexports.toParent = 1;\n\nexports.Manager =\n/*#__PURE__*/\nfunction () {\n function _class2() {\n _classCallCheck(this, _class2);\n\n this.refs = []; // 0: [self refs], 1: [parent refs], 2: [grandparent refs], ...\n }\n\n _createClass(_class2, [{\n key: \"register\",\n value: function register(source, target) {\n if (!source) {\n return;\n }\n\n target = target === undefined ? exports.toParent : target; // Array\n\n if (Array.isArray(source)) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = source[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var ref = _step.value;\n this.register(ref, target);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return;\n } // Schema\n\n\n if (Common.isSchema(source)) {\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = source._refs.refs[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var item = _step2.value;\n\n if (item.ancestor - target >= 0) {\n this.refs.push({\n ancestor: item.ancestor - target,\n root: item.root\n });\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return;\n } // Reference\n\n\n if (exports.isRef(source) && source.type === 'value' && source.ancestor - target >= 0) {\n this.refs.push({\n ancestor: source.ancestor - target,\n root: source.root\n });\n } // Template\n\n\n Template = Template || require('./template');\n\n if (Template.isTemplate(source)) {\n this.register(source.refs(), target);\n }\n }\n }, {\n key: \"clone\",\n value: function clone() {\n var copy = new exports.Manager();\n copy.refs = Clone(this.refs);\n return copy;\n }\n }, {\n key: \"reset\",\n value: function reset() {\n this.refs = [];\n }\n }, {\n key: \"roots\",\n value: function roots() {\n return this.refs.filter(function (ref) {\n return !ref.ancestor;\n }).map(function (ref) {\n return ref.root;\n });\n }\n }, {\n key: \"length\",\n get: function get() {\n return this.refs.length;\n }\n }]);\n\n return _class2;\n}();" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Reach = require('@hapi/hoek/lib/reach');\n\nconst Common = require('./common');\n\nlet Template;\nconst internals = {\n symbol: Symbol('ref'),\n // Used to internally identify references (shared with other joi versions)\n defaults: {\n adjust: null,\n iterables: null,\n map: null,\n separator: '.',\n type: 'value'\n }\n};\n\nexports.create = function (key) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(typeof key === 'string', 'Invalid reference key:', key);\n Common.assertOptions(options, ['adjust', 'ancestor', 'iterables', 'map', 'prefix', 'separator']);\n Assert(!options.prefix || typeof options.prefix === 'object', 'options.prefix must be of type object');\n const ref = Object.assign({}, internals.defaults, options);\n delete ref.prefix;\n const separator = ref.separator;\n const context = internals.context(key, options.prefix);\n ref.type = context.type;\n key = context.key;\n\n if (ref.type === 'value') {\n if (context.root) {\n Assert(!separator || key[0] !== separator, 'Cannot specify relative path with root prefix');\n ref.ancestor = 'root';\n\n if (!key) {\n key = null;\n }\n }\n\n if (separator && separator === key) {\n key = null;\n ref.ancestor = 0;\n } else {\n if (ref.ancestor !== undefined) {\n Assert(!separator || !key || key[0] !== separator, 'Cannot combine prefix with ancestor option');\n } else {\n const [ancestor, slice] = internals.ancestor(key, separator);\n\n if (slice) {\n key = key.slice(slice);\n\n if (key === '') {\n key = null;\n }\n }\n\n ref.ancestor = ancestor;\n }\n }\n }\n\n ref.path = separator ? key === null ? [] : key.split(separator) : [key];\n return new internals.Ref(ref);\n};\n\nexports.isRef = function (ref) {\n return ref ? !!ref[Common.symbols.ref] : false;\n};\n\ninternals.Ref = class {\n constructor(options) {\n Assert(typeof options === 'object', 'Invalid reference construction');\n Common.assertOptions(options, ['adjust', 'ancestor', 'iterables', 'map', 'path', 'separator', 'type', // Copied\n 'depth', 'key', 'root', 'display' // Overridden\n ]);\n Assert([false, undefined].includes(options.separator) || typeof options.separator === 'string' && options.separator.length === 1, 'Invalid separator');\n Assert(!options.adjust || typeof options.adjust === 'function', 'options.adjust must be a function');\n Assert(!options.map || Array.isArray(options.map), 'options.map must be an array');\n Assert(!options.map || !options.adjust, 'Cannot set both map and adjust options');\n Object.assign(this, internals.defaults, options);\n Assert(this.type === 'value' || this.ancestor === undefined, 'Non-value references cannot reference ancestors');\n\n if (Array.isArray(this.map)) {\n this.map = new Map(this.map);\n }\n\n this.depth = this.path.length;\n this.key = this.path.length ? this.path.join(this.separator) : null;\n this.root = this.path[0];\n this.updateDisplay();\n }\n\n resolve(value, state, prefs, local) {\n let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};\n\n if (this.type === 'global') {\n return this._resolve(prefs.context, state, options);\n }\n\n if (this.type === 'local') {\n return this._resolve(local, state, options);\n }\n\n if (!this.ancestor) {\n return this._resolve(value, state, options);\n }\n\n if (this.ancestor === 'root') {\n return this._resolve(state.ancestors[state.ancestors.length - 1], state, options);\n }\n\n Assert(this.ancestor <= state.ancestors.length, 'Invalid reference exceeds the schema root:', this.display);\n return this._resolve(state.ancestors[this.ancestor - 1], state, options);\n }\n\n _resolve(target, state, options) {\n let resolved;\n\n if (this.type === 'value' && state.mainstay && state.mainstay.shadow && options.shadow !== false) {\n resolved = state.mainstay.shadow.get(this.path);\n }\n\n if (resolved === undefined) {\n resolved = Reach(target, this.path, {\n iterables: this.iterables,\n functions: true\n });\n }\n\n if (this.adjust) {\n resolved = this.adjust(resolved);\n }\n\n if (this.map) {\n const mapped = this.map.get(resolved);\n\n if (mapped !== undefined) {\n return mapped;\n }\n }\n\n return resolved;\n }\n\n toString() {\n return this.display;\n }\n\n clone() {\n return new internals.Ref(this);\n }\n\n describe() {\n const ref = {\n path: this.path\n };\n\n if (this.type !== 'value') {\n ref.type = this.type;\n }\n\n if (this.separator !== '.') {\n ref.separator = this.separator;\n }\n\n if (this.type === 'value' && this.ancestor !== 1) {\n ref.ancestor = this.ancestor;\n }\n\n if (this.map) {\n ref.map = [...this.map];\n }\n\n for (const key of ['adjust', 'iterables']) {\n if (this[key] !== null) {\n ref[key] = this[key];\n }\n }\n\n return {\n ref\n };\n }\n\n updateDisplay() {\n if (this.type !== 'value') {\n this.display = \"ref:\".concat(this.type, \":\").concat(this.key);\n return;\n }\n\n if (!this.separator) {\n this.display = \"ref:\".concat(this.key);\n return;\n }\n\n if (!this.ancestor) {\n this.display = \"ref:\".concat(this.separator).concat(this.key);\n return;\n }\n\n if (this.ancestor === 'root') {\n this.display = \"ref:root:\".concat(this.key);\n return;\n }\n\n if (this.ancestor === 1) {\n this.display = \"ref:\".concat(this.key);\n return;\n }\n\n const lead = new Array(this.ancestor + 1).fill(this.separator).join('');\n this.display = \"ref:\".concat(lead).concat(this.key || '');\n }\n\n};\ninternals.Ref.prototype[Common.symbols.ref] = true;\n\nexports.build = function (desc) {\n desc = Object.assign({}, internals.defaults, desc);\n\n if (desc.type === 'value' && desc.ancestor === undefined) {\n desc.ancestor = 1;\n }\n\n return new internals.Ref(desc);\n};\n\ninternals.context = function (key) {\n let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n key = key.trim();\n const globalp = prefix.global || '$';\n\n if (key.startsWith(globalp)) {\n return {\n key: key.slice(globalp.length),\n type: 'global'\n };\n }\n\n const local = prefix.local || '#';\n\n if (key.startsWith(local)) {\n return {\n key: key.slice(local.length),\n type: 'local'\n };\n }\n\n const root = prefix.root || '/';\n\n if (key.startsWith(root)) {\n return {\n key: key.slice(root.length),\n type: 'value',\n root: true\n };\n }\n\n return {\n key,\n type: 'value'\n };\n};\n\ninternals.ancestor = function (key, separator) {\n if (!separator) {\n return [1, 0]; // 'a_b' -> 1 (parent)\n }\n\n if (key[0] !== separator) {\n // 'a.b' -> 1 (parent)\n return [1, 0];\n }\n\n if (key[1] !== separator) {\n // '.a.b' -> 0 (self)\n return [0, 1];\n }\n\n let i = 2;\n\n while (key[i] === separator) {\n ++i;\n }\n\n return [i - 1, i]; // '...a.b.' -> 2 (grandparent)\n};\n\nexports.toSibling = 0;\nexports.toParent = 1;\nexports.Manager = class {\n constructor() {\n this.refs = []; // 0: [self refs], 1: [parent refs], 2: [grandparent refs], ...\n }\n\n register(source, target) {\n if (!source) {\n return;\n }\n\n target = target === undefined ? exports.toParent : target; // Array\n\n if (Array.isArray(source)) {\n for (const ref of source) {\n this.register(ref, target);\n }\n\n return;\n } // Schema\n\n\n if (Common.isSchema(source)) {\n for (const item of source._refs.refs) {\n if (item.ancestor - target >= 0) {\n this.refs.push({\n ancestor: item.ancestor - target,\n root: item.root\n });\n }\n }\n\n return;\n } // Reference\n\n\n if (exports.isRef(source) && source.type === 'value' && source.ancestor - target >= 0) {\n this.refs.push({\n ancestor: source.ancestor - target,\n root: source.root\n });\n } // Template\n\n\n Template = Template || require('./template');\n\n if (Template.isTemplate(source)) {\n this.register(source.refs(), target);\n }\n }\n\n get length() {\n return this.refs.length;\n }\n\n clone() {\n const copy = new exports.Manager();\n copy.refs = Clone(this.refs);\n return copy;\n }\n\n reset() {\n this.refs = [];\n }\n\n roots() {\n return this.refs.filter(ref => !ref.ancestor).map(ref => ref.root);\n }\n\n};" }, { "id": 6, @@ -5642,7 +5549,7 @@ "name": "../lib/compile.js", "index": 18, "index2": 17, - "size": 4225, + "size": 3264, "cacheable": true, "built": true, "optional": false, @@ -5659,15 +5566,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -5681,7 +5588,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./compile", - "loc": "23:14-34" + "loc": "9:16-36" }, { "moduleId": 23, @@ -5690,43 +5597,43 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "../compile", - "loc": "53:14-35" + "loc": "17:16-37" }, { - "moduleId": 30, + "moduleId": 29, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "module": "../lib/types/alternatives.js", "moduleName": "../lib/types/alternatives.js", "type": "cjs require", "userRequest": "../compile", - "loc": "27:14-35" + "loc": "9:16-37" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./compile", - "loc": "33:14-34" + "loc": "15:16-36" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "../compile", - "loc": "25:14-35" + "loc": "15:16-37" }, { - "moduleId": 41, + "moduleId": 40, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/link.js", "module": "../lib/types/link.js", "moduleName": "../lib/types/link.js", "type": "cjs require", "userRequest": "../compile", - "loc": "9:14-35" + "loc": "9:16-37" } ], "usedExports": true, @@ -5735,7 +5642,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Common = require('./common');\n\nvar Ref = require('./ref');\n\nvar internals = {};\n\nexports.schema = function (Joi, config) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Common.assertOptions(options, ['appendPath']);\n\n try {\n return internals.schema(Joi, config);\n } catch (err) {\n if (options.appendPath && err.path !== undefined) {\n err.message = \"\".concat(err.message).concat(err.message[err.message.length - 1] === ' ' ? '' : ' ', \"(\").concat(err.path, \")\");\n }\n\n throw err;\n }\n};\n\ninternals.schema = function (Joi, config) {\n if (config !== undefined && config !== null && _typeof(config) === 'object') {\n if (Common.isResolvable(config)) {\n return Joi.valid(config);\n }\n\n if (Common.isSchema(config)) {\n return config;\n }\n\n if (Array.isArray(config)) {\n return Joi.alternatives().try(config);\n }\n\n if (config instanceof RegExp) {\n return Joi.string().regex(config);\n }\n\n if (config instanceof Date) {\n return Joi.date().valid(config);\n }\n\n Assert(Object.getPrototypeOf(config) === Object.getPrototypeOf({}), 'Schema can only contain plain objects');\n return Joi.object().keys(config);\n }\n\n if (typeof config === 'string') {\n return Joi.string().valid(config);\n }\n\n if (typeof config === 'number') {\n return Joi.number().valid(config);\n }\n\n if (typeof config === 'boolean') {\n return Joi.boolean().valid(config);\n }\n\n Assert(config === null, 'Invalid schema content:', config);\n return Joi.valid(null);\n};\n\nexports.ref = function (id, options) {\n return Ref.isRef(id) ? id : Ref.create(id, options);\n};\n\nexports.compile = function (root, schema) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Common.assertOptions(options, ['legacy']); // Compiled by any supported version\n\n var any = schema && schema[Common.symbols.any];\n\n if (any) {\n Assert(options.legacy || any.version === Common.version, 'Cannot mix different versions of joi schemas');\n return schema;\n } // Uncompiled root\n\n\n if (_typeof(schema) !== 'object' || !options.legacy) {\n return exports.schema(root, schema, {\n appendPath: true\n }); // Will error if schema contains other versions\n } // Scan schema for compiled parts\n\n\n var compiler = internals.walk(schema);\n\n if (!compiler) {\n return exports.schema(root, schema, {\n appendPath: true\n });\n }\n\n return compiler.compile(compiler.root, schema);\n};\n\ninternals.walk = function (schema) {\n if (_typeof(schema) !== 'object') {\n return null;\n }\n\n if (Array.isArray(schema)) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = schema[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var item = _step.value;\n var compiler = internals.walk(item);\n\n if (compiler) {\n return compiler;\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return null;\n }\n\n var any = schema[Common.symbols.any];\n\n if (any) {\n return {\n root: schema[any.root],\n compile: any.compile\n };\n }\n\n Assert(Object.getPrototypeOf(schema) === Object.getPrototypeOf({}), 'Schema can only contain plain objects');\n\n for (var key in schema) {\n var _compiler = internals.walk(schema[key]);\n\n if (_compiler) {\n return _compiler;\n }\n }\n\n return null;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Common = require('./common');\n\nconst Ref = require('./ref');\n\nconst internals = {};\n\nexports.schema = function (Joi, config) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Common.assertOptions(options, ['appendPath']);\n\n try {\n return internals.schema(Joi, config);\n } catch (err) {\n if (options.appendPath && err.path !== undefined) {\n err.message = \"\".concat(err.message).concat(err.message[err.message.length - 1] === ' ' ? '' : ' ', \"(\").concat(err.path, \")\");\n }\n\n throw err;\n }\n};\n\ninternals.schema = function (Joi, config) {\n if (config !== undefined && config !== null && typeof config === 'object') {\n if (Common.isResolvable(config)) {\n return Joi.valid(config);\n }\n\n if (Common.isSchema(config)) {\n return config;\n }\n\n if (Array.isArray(config)) {\n return Joi.alternatives().try(config);\n }\n\n if (config instanceof RegExp) {\n return Joi.string().regex(config);\n }\n\n if (config instanceof Date) {\n return Joi.date().valid(config);\n }\n\n Assert(Object.getPrototypeOf(config) === Object.getPrototypeOf({}), 'Schema can only contain plain objects');\n return Joi.object().keys(config);\n }\n\n if (typeof config === 'string') {\n return Joi.string().valid(config);\n }\n\n if (typeof config === 'number') {\n return Joi.number().valid(config);\n }\n\n if (typeof config === 'boolean') {\n return Joi.boolean().valid(config);\n }\n\n Assert(config === null, 'Invalid schema content:', config);\n return Joi.valid(null);\n};\n\nexports.ref = function (id, options) {\n return Ref.isRef(id) ? id : Ref.create(id, options);\n};\n\nexports.compile = function (root, schema) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Common.assertOptions(options, ['legacy']); // Compiled by any supported version\n\n const any = schema && schema[Common.symbols.any];\n\n if (any) {\n Assert(options.legacy || any.version === Common.version, 'Cannot mix different versions of joi schemas');\n return schema;\n } // Uncompiled root\n\n\n if (typeof schema !== 'object' || !options.legacy) {\n return exports.schema(root, schema, {\n appendPath: true\n }); // Will error if schema contains other versions\n } // Scan schema for compiled parts\n\n\n const compiler = internals.walk(schema);\n\n if (!compiler) {\n return exports.schema(root, schema, {\n appendPath: true\n });\n }\n\n return compiler.compile(compiler.root, schema);\n};\n\ninternals.walk = function (schema) {\n if (typeof schema !== 'object') {\n return null;\n }\n\n if (Array.isArray(schema)) {\n for (const item of schema) {\n const compiler = internals.walk(item);\n\n if (compiler) {\n return compiler;\n }\n }\n\n return null;\n }\n\n const any = schema[Common.symbols.any];\n\n if (any) {\n return {\n root: schema[any.root],\n compile: any.compile\n };\n }\n\n Assert(Object.getPrototypeOf(schema) === Object.getPrototypeOf({}), 'Schema can only contain plain objects');\n\n for (const key in schema) {\n const compiler = internals.walk(schema[key]);\n\n if (compiler) {\n return compiler;\n }\n }\n\n return null;\n};" }, { "id": 7, @@ -5743,7 +5650,7 @@ "name": "../lib/errors.js", "index": 19, "index2": 18, - "size": 15899, + "size": 9361, "cacheable": true, "built": true, "optional": false, @@ -5760,15 +5667,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -5782,7 +5689,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./errors", - "loc": "25:13-32" + "loc": "11:15-34" }, { "moduleId": 23, @@ -5791,34 +5698,34 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "../errors", - "loc": "55:13-33" + "loc": "19:15-35" }, { - "moduleId": 30, + "moduleId": 29, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "module": "../lib/types/alternatives.js", "moduleName": "../lib/types/alternatives.js", "type": "cjs require", "userRequest": "../errors", - "loc": "29:13-33" + "loc": "11:15-35" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./errors", - "loc": "35:13-32" + "loc": "17:15-34" }, { - "moduleId": 34, + "moduleId": 33, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/validator.js", "module": "../lib/validator.js", "moduleName": "../lib/validator.js", "type": "cjs require", "userRequest": "./errors", - "loc": "31:13-32" + "loc": "11:15-34" } ], "usedExports": true, @@ -5827,7 +5734,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Common = require('./common');\n\nvar Template = require('./template');\n\nvar internals = {\n annotations: Symbol('annotations')\n};\n\nexports.Report =\n/*#__PURE__*/\nfunction () {\n function _class(code, value, local, flags, messages, state, prefs) {\n _classCallCheck(this, _class);\n\n this.code = code;\n this.flags = flags;\n this.messages = messages;\n this.path = state.path;\n this.prefs = prefs;\n this.state = state;\n this.value = value;\n this.message = null;\n this.template = null;\n this.local = local || {};\n this.local.label = exports.label(this.flags, this.state, this.prefs, this.messages);\n\n if (this.value !== undefined && !this.local.hasOwnProperty('value')) {\n this.local.value = this.value;\n }\n\n if (this.path.length) {\n var key = this.path[this.path.length - 1];\n\n if (_typeof(key) !== 'object') {\n this.local.key = key;\n }\n }\n }\n\n _createClass(_class, [{\n key: \"_setTemplate\",\n value: function _setTemplate(template) {\n this.template = template;\n\n if (!this.flags.label && this.path.length === 0) {\n var localized = this._template(this.template, 'root');\n\n if (localized) {\n this.local.label = localized;\n }\n }\n }\n }, {\n key: \"toString\",\n value: function toString() {\n if (this.message) {\n return this.message;\n }\n\n var code = this.code;\n\n var template = this._template(this.template) || this._template(this.prefs.messages) || this._template(this.messages);\n\n if (template === undefined) {\n return \"Error code \\\"\".concat(code, \"\\\" is not defined, your custom type is missing the correct messages definition\");\n }\n\n this.message = template.render(this.value, this.state, this.prefs, this.local, this.prefs.errors); // Cache result\n\n return this.message;\n }\n }, {\n key: \"_template\",\n value: function _template(messages, code) {\n return internals.template(this.value, messages, code || this.code, this.state, this.prefs);\n }\n }]);\n\n return _class;\n}();\n\ninternals.label = function (path) {\n var label = '';\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = path[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var segment = _step.value;\n\n if (_typeof(segment) === 'object') {\n // Exclude array single path segment\n continue;\n }\n\n if (typeof segment === 'string') {\n if (label) {\n label += '.';\n }\n\n label += segment;\n } else {\n label += \"[\".concat(segment, \"]\");\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return label;\n};\n\ninternals.template = function (value, messages, code, state, prefs) {\n if (!messages) {\n return;\n }\n\n if (Template.isTemplate(messages)) {\n return code !== 'root' ? messages : null;\n }\n\n var lang = prefs.errors.language;\n\n if (Common.isResolvable(lang)) {\n var local = state.ancestors[state.ancestors.length - 1];\n lang = lang.resolve(value, state, prefs, local);\n }\n\n if (lang && messages[lang] && messages[lang][code] !== undefined) {\n return messages[lang][code];\n }\n\n return messages[code];\n};\n\nexports.label = function (flags, state, prefs, messages) {\n return flags.label || internals.label(state.path) || internals.template(null, prefs.messages, 'root', state, prefs) || messages && internals.template(null, messages, 'root', state, prefs) || 'value';\n};\n\nexports.process = function (errors, original, prefs) {\n if (!errors) {\n return null;\n }\n\n var _exports$details = exports.details(errors),\n override = _exports$details.override,\n message = _exports$details.message,\n details = _exports$details.details;\n\n if (override) {\n return override;\n }\n\n if (prefs.errors.stack) {\n return new exports.ValidationError(message, details, original);\n }\n\n var limit = Error.stackTraceLimit;\n Error.stackTraceLimit = 0;\n var validationError = new exports.ValidationError(message, details, original);\n Error.stackTraceLimit = limit;\n return validationError;\n};\n\nexports.details = function (errors) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var messages = [];\n var details = [];\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = errors[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var item = _step2.value;\n\n // Override\n if (item instanceof Error) {\n if (options.override !== false) {\n return {\n override: item\n };\n }\n\n var _message = item.toString();\n\n messages.push(_message);\n details.push({\n message: _message,\n type: 'override',\n context: {\n error: item\n }\n });\n continue;\n } // Report\n\n\n var message = item.toString();\n messages.push(message);\n details.push({\n message: message,\n path: item.path.filter(function (v) {\n return _typeof(v) !== 'object';\n }),\n type: item.code,\n context: item.local\n });\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (messages.length > 1) {\n messages = _toConsumableArray(new Set(messages));\n }\n\n return {\n message: messages.join('. '),\n details: details\n };\n};\n\nexports.ValidationError =\n/*#__PURE__*/\nfunction (_Error) {\n _inherits(_class2, _Error);\n\n function _class2(message, details, original) {\n var _this;\n\n _classCallCheck(this, _class2);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(_class2).call(this, message));\n _this._original = original;\n _this.details = details;\n return _this;\n }\n\n _createClass(_class2, [{\n key: \"annotate\",\n value: function annotate(stripColorCodes) {\n if (!this._original || _typeof(this._original) !== 'object') {\n return this.details[0].message;\n }\n\n var redFgEscape = stripColorCodes ? '' : \"\\x1B[31m\";\n var redBgEscape = stripColorCodes ? '' : \"\\x1B[41m\";\n var endColor = stripColorCodes ? '' : \"\\x1B[0m\";\n var obj = Clone(this._original);\n\n for (var i = this.details.length - 1; i >= 0; --i) {\n // Reverse order to process deepest child first\n var pos = i + 1;\n var error = this.details[i];\n var path = error.path;\n var node = obj;\n\n for (var j = 0;; ++j) {\n var seg = path[j];\n\n if (Common.isSchema(node)) {\n node = node.clone(); // joi schemas are not cloned by hoek, we have to take this extra step\n }\n\n if (j + 1 < path.length && typeof node[seg] !== 'string') {\n node = node[seg];\n } else {\n var refAnnotations = node[internals.annotations] || {\n errors: {},\n missing: {}\n };\n node[internals.annotations] = refAnnotations;\n var cacheKey = seg || error.context.key;\n\n if (node[seg] !== undefined) {\n refAnnotations.errors[cacheKey] = refAnnotations.errors[cacheKey] || [];\n refAnnotations.errors[cacheKey].push(pos);\n } else {\n refAnnotations.missing[cacheKey] = pos;\n }\n\n break;\n }\n }\n }\n\n var replacers = {\n key: /_\\$key\\$_([, \\d]+)_\\$end\\$_\"/g,\n missing: /\"_\\$miss\\$_([^|]+)\\|(\\d+)_\\$end\\$_\": \"__missing__\"/g,\n arrayIndex: /\\s*\"_\\$idx\\$_([, \\d]+)_\\$end\\$_\",?\\n(.*)/g,\n specials: /\"\\[(NaN|Symbol.*|-?Infinity|function.*|\\(.*)]\"/g\n };\n var message = internals.safeStringify(obj, 2).replace(replacers.key, function ($0, $1) {\n return \"\\\" \".concat(redFgEscape, \"[\").concat($1, \"]\").concat(endColor);\n }).replace(replacers.missing, function ($0, $1, $2) {\n return \"\".concat(redBgEscape, \"\\\"\").concat($1, \"\\\"\").concat(endColor).concat(redFgEscape, \" [\").concat($2, \"]: -- missing --\").concat(endColor);\n }).replace(replacers.arrayIndex, function ($0, $1, $2) {\n return \"\\n\".concat($2, \" \").concat(redFgEscape, \"[\").concat($1, \"]\").concat(endColor);\n }).replace(replacers.specials, function ($0, $1) {\n return $1;\n });\n message = \"\".concat(message, \"\\n\").concat(redFgEscape);\n\n for (var _i = 0; _i < this.details.length; ++_i) {\n var _pos = _i + 1;\n\n message = \"\".concat(message, \"\\n[\").concat(_pos, \"] \").concat(this.details[_i].message);\n }\n\n message = message + endColor;\n return message;\n }\n }]);\n\n return _class2;\n}(_wrapNativeSuper(Error));\n\nexports.ValidationError.prototype.isJoi = true;\nexports.ValidationError.prototype.name = 'ValidationError'; // Inspired by json-stringify-safe\n\ninternals.safeStringify = function (obj, spaces) {\n return JSON.stringify(obj, internals.serializer(), spaces);\n};\n\ninternals.serializer = function () {\n var keys = [];\n var stack = [];\n\n var cycleReplacer = function cycleReplacer(key, value) {\n if (stack[0] === value) {\n return '[Circular ~]';\n }\n\n return '[Circular ~.' + keys.slice(0, stack.indexOf(value)).join('.') + ']';\n };\n\n return function (key, value) {\n if (stack.length > 0) {\n var thisPos = stack.indexOf(this);\n\n if (~thisPos) {\n stack.length = thisPos + 1;\n keys.length = thisPos + 1;\n keys[thisPos] = key;\n } else {\n stack.push(this);\n keys.push(key);\n }\n\n if (~stack.indexOf(value)) {\n value = cycleReplacer.call(this, key, value);\n }\n } else {\n stack.push(value);\n }\n\n if (value) {\n var annotations = value[internals.annotations];\n\n if (annotations) {\n if (Array.isArray(value)) {\n var annotated = [];\n\n for (var i = 0; i < value.length; ++i) {\n if (annotations.errors[i]) {\n annotated.push(\"_$idx$_\".concat(annotations.errors[i].sort().join(', '), \"_$end$_\"));\n }\n\n annotated.push(value[i]);\n }\n\n value = annotated;\n } else {\n for (var errorKey in annotations.errors) {\n value[\"\".concat(errorKey, \"_$key$_\").concat(annotations.errors[errorKey].sort().join(', '), \"_$end$_\")] = value[errorKey];\n value[errorKey] = undefined;\n }\n\n for (var missingKey in annotations.missing) {\n value[\"_$miss$_\".concat(missingKey, \"|\").concat(annotations.missing[missingKey], \"_$end$_\")] = '__missing__';\n }\n }\n\n return value;\n }\n }\n\n if (value === Infinity || value === -Infinity || Number.isNaN(value) || typeof value === 'function' || _typeof(value) === 'symbol') {\n return '[' + value.toString() + ']';\n }\n\n return value;\n };\n};" + "source": "'use strict';\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Common = require('./common');\n\nconst Template = require('./template');\n\nconst internals = {\n annotations: Symbol('annotations')\n};\nexports.Report = class {\n constructor(code, value, local, flags, messages, state, prefs) {\n this.code = code;\n this.flags = flags;\n this.messages = messages;\n this.path = state.path;\n this.prefs = prefs;\n this.state = state;\n this.value = value;\n this.message = null;\n this.template = null;\n this.local = local || {};\n this.local.label = exports.label(this.flags, this.state, this.prefs, this.messages);\n\n if (this.value !== undefined && !this.local.hasOwnProperty('value')) {\n this.local.value = this.value;\n }\n\n if (this.path.length) {\n const key = this.path[this.path.length - 1];\n\n if (typeof key !== 'object') {\n this.local.key = key;\n }\n }\n }\n\n _setTemplate(template) {\n this.template = template;\n\n if (!this.flags.label && this.path.length === 0) {\n const localized = this._template(this.template, 'root');\n\n if (localized) {\n this.local.label = localized;\n }\n }\n }\n\n toString() {\n if (this.message) {\n return this.message;\n }\n\n const code = this.code;\n\n const template = this._template(this.template) || this._template(this.prefs.messages) || this._template(this.messages);\n\n if (template === undefined) {\n return \"Error code \\\"\".concat(code, \"\\\" is not defined, your custom type is missing the correct messages definition\");\n }\n\n this.message = template.render(this.value, this.state, this.prefs, this.local, this.prefs.errors); // Cache result\n\n return this.message;\n }\n\n _template(messages, code) {\n return internals.template(this.value, messages, code || this.code, this.state, this.prefs);\n }\n\n};\n\ninternals.label = function (path) {\n let label = '';\n\n for (const segment of path) {\n if (typeof segment === 'object') {\n // Exclude array single path segment\n continue;\n }\n\n if (typeof segment === 'string') {\n if (label) {\n label += '.';\n }\n\n label += segment;\n } else {\n label += \"[\".concat(segment, \"]\");\n }\n }\n\n return label;\n};\n\ninternals.template = function (value, messages, code, state, prefs) {\n if (!messages) {\n return;\n }\n\n if (Template.isTemplate(messages)) {\n return code !== 'root' ? messages : null;\n }\n\n let lang = prefs.errors.language;\n\n if (Common.isResolvable(lang)) {\n const local = state.ancestors[state.ancestors.length - 1];\n lang = lang.resolve(value, state, prefs, local);\n }\n\n if (lang && messages[lang] && messages[lang][code] !== undefined) {\n return messages[lang][code];\n }\n\n return messages[code];\n};\n\nexports.label = function (flags, state, prefs, messages) {\n return flags.label || internals.label(state.path) || internals.template(null, prefs.messages, 'root', state, prefs) || messages && internals.template(null, messages, 'root', state, prefs) || 'value';\n};\n\nexports.process = function (errors, original, prefs) {\n if (!errors) {\n return null;\n }\n\n const {\n override,\n message,\n details\n } = exports.details(errors);\n\n if (override) {\n return override;\n }\n\n if (prefs.errors.stack) {\n return new exports.ValidationError(message, details, original);\n }\n\n const limit = Error.stackTraceLimit;\n Error.stackTraceLimit = 0;\n const validationError = new exports.ValidationError(message, details, original);\n Error.stackTraceLimit = limit;\n return validationError;\n};\n\nexports.details = function (errors) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n let messages = [];\n const details = [];\n\n for (const item of errors) {\n // Override\n if (item instanceof Error) {\n if (options.override !== false) {\n return {\n override: item\n };\n }\n\n const message = item.toString();\n messages.push(message);\n details.push({\n message,\n type: 'override',\n context: {\n error: item\n }\n });\n continue;\n } // Report\n\n\n const message = item.toString();\n messages.push(message);\n details.push({\n message,\n path: item.path.filter(v => typeof v !== 'object'),\n type: item.code,\n context: item.local\n });\n }\n\n if (messages.length > 1) {\n messages = [...new Set(messages)];\n }\n\n return {\n message: messages.join('. '),\n details\n };\n};\n\nexports.ValidationError = class extends Error {\n constructor(message, details, original) {\n super(message);\n this._original = original;\n this.details = details;\n }\n\n annotate(stripColorCodes) {\n if (!this._original || typeof this._original !== 'object') {\n return this.details[0].message;\n }\n\n const redFgEscape = stripColorCodes ? '' : '\\u001b[31m';\n const redBgEscape = stripColorCodes ? '' : '\\u001b[41m';\n const endColor = stripColorCodes ? '' : '\\u001b[0m';\n const obj = Clone(this._original);\n\n for (let i = this.details.length - 1; i >= 0; --i) {\n // Reverse order to process deepest child first\n const pos = i + 1;\n const error = this.details[i];\n const path = error.path;\n let node = obj;\n\n for (let j = 0;; ++j) {\n const seg = path[j];\n\n if (Common.isSchema(node)) {\n node = node.clone(); // joi schemas are not cloned by hoek, we have to take this extra step\n }\n\n if (j + 1 < path.length && typeof node[seg] !== 'string') {\n node = node[seg];\n } else {\n const refAnnotations = node[internals.annotations] || {\n errors: {},\n missing: {}\n };\n node[internals.annotations] = refAnnotations;\n const cacheKey = seg || error.context.key;\n\n if (node[seg] !== undefined) {\n refAnnotations.errors[cacheKey] = refAnnotations.errors[cacheKey] || [];\n refAnnotations.errors[cacheKey].push(pos);\n } else {\n refAnnotations.missing[cacheKey] = pos;\n }\n\n break;\n }\n }\n }\n\n const replacers = {\n key: /_\\$key\\$_([, \\d]+)_\\$end\\$_\"/g,\n missing: /\"_\\$miss\\$_([^|]+)\\|(\\d+)_\\$end\\$_\": \"__missing__\"/g,\n arrayIndex: /\\s*\"_\\$idx\\$_([, \\d]+)_\\$end\\$_\",?\\n(.*)/g,\n specials: /\"\\[(NaN|Symbol.*|-?Infinity|function.*|\\(.*)]\"/g\n };\n let message = internals.safeStringify(obj, 2).replace(replacers.key, ($0, $1) => \"\\\" \".concat(redFgEscape, \"[\").concat($1, \"]\").concat(endColor)).replace(replacers.missing, ($0, $1, $2) => \"\".concat(redBgEscape, \"\\\"\").concat($1, \"\\\"\").concat(endColor).concat(redFgEscape, \" [\").concat($2, \"]: -- missing --\").concat(endColor)).replace(replacers.arrayIndex, ($0, $1, $2) => \"\\n\".concat($2, \" \").concat(redFgEscape, \"[\").concat($1, \"]\").concat(endColor)).replace(replacers.specials, ($0, $1) => $1);\n message = \"\".concat(message, \"\\n\").concat(redFgEscape);\n\n for (let i = 0; i < this.details.length; ++i) {\n const pos = i + 1;\n message = \"\".concat(message, \"\\n[\").concat(pos, \"] \").concat(this.details[i].message);\n }\n\n message = message + endColor;\n return message;\n }\n\n};\nexports.ValidationError.prototype.isJoi = true;\nexports.ValidationError.prototype.name = 'ValidationError'; // Inspired by json-stringify-safe\n\ninternals.safeStringify = function (obj, spaces) {\n return JSON.stringify(obj, internals.serializer(), spaces);\n};\n\ninternals.serializer = function () {\n const keys = [];\n const stack = [];\n\n const cycleReplacer = (key, value) => {\n if (stack[0] === value) {\n return '[Circular ~]';\n }\n\n return '[Circular ~.' + keys.slice(0, stack.indexOf(value)).join('.') + ']';\n };\n\n return function (key, value) {\n if (stack.length > 0) {\n const thisPos = stack.indexOf(this);\n\n if (~thisPos) {\n stack.length = thisPos + 1;\n keys.length = thisPos + 1;\n keys[thisPos] = key;\n } else {\n stack.push(this);\n keys.push(key);\n }\n\n if (~stack.indexOf(value)) {\n value = cycleReplacer.call(this, key, value);\n }\n } else {\n stack.push(value);\n }\n\n if (value) {\n const annotations = value[internals.annotations];\n\n if (annotations) {\n if (Array.isArray(value)) {\n const annotated = [];\n\n for (let i = 0; i < value.length; ++i) {\n if (annotations.errors[i]) {\n annotated.push(\"_$idx$_\".concat(annotations.errors[i].sort().join(', '), \"_$end$_\"));\n }\n\n annotated.push(value[i]);\n }\n\n value = annotated;\n } else {\n for (const errorKey in annotations.errors) {\n value[\"\".concat(errorKey, \"_$key$_\").concat(annotations.errors[errorKey].sort().join(', '), \"_$end$_\")] = value[errorKey];\n value[errorKey] = undefined;\n }\n\n for (const missingKey in annotations.missing) {\n value[\"_$miss$_\".concat(missingKey, \"|\").concat(annotations.missing[missingKey], \"_$end$_\")] = '__missing__';\n }\n }\n\n return value;\n }\n }\n\n if (value === Infinity || value === -Infinity || Number.isNaN(value) || typeof value === 'function' || typeof value === 'symbol') {\n return '[' + value.toString() + ']';\n }\n\n return value;\n };\n};" }, { "id": 8, @@ -5835,7 +5742,7 @@ "name": "../node_modules/@hapi/hoek/lib/utils.js", "index": 7, "index2": 5, - "size": 2869, + "size": 1153, "cacheable": true, "built": true, "optional": false, @@ -5852,8 +5759,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -5861,9 +5768,9 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/cache.js", "name": "../lib/cache.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { @@ -5871,14 +5778,14 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/clone.js", "name": "../node_modules/@hapi/hoek/lib/clone.js", "profile": { - "factory": 1052, - "building": 123 + "factory": 614, + "building": 142 } } ], "profile": { - "factory": 368, - "building": 118, + "factory": 185, + "building": 102, "dependencies": 0 }, "failed": false, @@ -5893,7 +5800,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/clone.js", "type": "cjs require", "userRequest": "./utils", - "loc": "15:12-30" + "loc": "5:14-32" }, { "moduleId": 20, @@ -5902,25 +5809,25 @@ "moduleName": "../node_modules/@hapi/hoek/lib/merge.js", "type": "cjs require", "userRequest": "./utils", - "loc": "9:12-30" + "loc": "7:14-32" }, { - "moduleId": 39, + "moduleId": 38, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/applyToDefaults.js", "module": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "moduleName": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "type": "cjs require", "userRequest": "./utils", - "loc": "11:12-30" + "loc": "9:14-32" }, { - "moduleId": 50, + "moduleId": 49, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/contain.js", "module": "../node_modules/@hapi/hoek/lib/contain.js", "moduleName": "../node_modules/@hapi/hoek/lib/contain.js", "type": "cjs require", "userRequest": "./utils", - "loc": "19:12-30" + "loc": "9:14-32" } ], "usedExports": true, @@ -5929,7 +5836,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Reach = require('./reach');\n\nvar internals = {};\n\nexports.keys = function (obj) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return options.symbols !== false ? Reflect.ownKeys(obj) : Object.getOwnPropertyNames(obj); // Defaults to true\n};\n\nexports.store = function (source, keys) {\n var storage = new Map();\n\n for (var i = 0; i < keys.length; ++i) {\n var key = keys[i];\n var value = Reach(source, key);\n\n if (_typeof(value) === 'object' || typeof value === 'function') {\n storage.set(key, value);\n internals.reachSet(source, key, undefined);\n }\n }\n\n return storage;\n};\n\nexports.restore = function (copy, source, storage) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = storage[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var _step$value = _slicedToArray(_step.value, 2),\n key = _step$value[0],\n value = _step$value[1];\n\n internals.reachSet(copy, key, value);\n internals.reachSet(source, key, value);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n};\n\ninternals.reachSet = function (obj, key, value) {\n var path = Array.isArray(key) ? key : key.split('.');\n var ref = obj;\n\n for (var i = 0; i < path.length; ++i) {\n var segment = path[i];\n\n if (i + 1 === path.length) {\n ref[segment] = value;\n }\n\n ref = ref[segment];\n }\n};" + "source": "'use strict';\n\nconst Reach = require('./reach');\n\nconst internals = {};\n\nexports.keys = function (obj) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return options.symbols !== false ? Reflect.ownKeys(obj) : Object.getOwnPropertyNames(obj); // Defaults to true\n};\n\nexports.store = function (source, keys) {\n const storage = new Map();\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n const value = Reach(source, key);\n\n if (typeof value === 'object' || typeof value === 'function') {\n storage.set(key, value);\n internals.reachSet(source, key, undefined);\n }\n }\n\n return storage;\n};\n\nexports.restore = function (copy, source, storage) {\n for (const [key, value] of storage) {\n internals.reachSet(copy, key, value);\n internals.reachSet(source, key, value);\n }\n};\n\ninternals.reachSet = function (obj, key, value) {\n const path = Array.isArray(key) ? key : key.split('.');\n let ref = obj;\n\n for (let i = 0; i < path.length; ++i) {\n const segment = path[i];\n\n if (i + 1 === path.length) {\n ref[segment] = value;\n }\n\n ref = ref[segment];\n }\n};" }, { "id": 9, @@ -5937,7 +5844,7 @@ "name": "../node_modules/@hapi/hoek/lib/reach.js", "index": 8, "index2": 4, - "size": 2576, + "size": 1660, "cacheable": true, "built": true, "optional": false, @@ -5945,34 +5852,34 @@ "chunks": [ 0 ], - "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", - "issuerId": 35, - "issuerName": "../lib/types/array.js", + "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/ref.js", + "issuerId": 5, + "issuerName": "../lib/ref.js", "issuerPath": [ { "id": 14, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 35, - "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", - "name": "../lib/types/array.js", + "id": 5, + "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/ref.js", + "name": "../lib/ref.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1026, - "building": 91, - "dependencies": 298 + "factory": 505, + "building": 170, + "dependencies": 0 }, "failed": false, "errors": 0, @@ -5986,7 +5893,7 @@ "moduleName": "../lib/ref.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/reach", - "loc": "31:12-43" + "loc": "7:14-45" }, { "moduleId": 8, @@ -5995,25 +5902,25 @@ "moduleName": "../node_modules/@hapi/hoek/lib/utils.js", "type": "cjs require", "userRequest": "./reach", - "loc": "13:12-30" + "loc": "3:14-32" }, { - "moduleId": 34, + "moduleId": 33, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/validator.js", "module": "../lib/validator.js", "moduleName": "../lib/validator.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/reach", - "loc": "27:12-43" + "loc": "7:14-45" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/reach", - "loc": "19:12-43" + "loc": "9:14-45" } ], "usedExports": true, @@ -6022,7 +5929,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('./assert');\n\nvar internals = {};\n\nmodule.exports = function (obj, chain, options) {\n if (chain === false || chain === null || chain === undefined) {\n return obj;\n }\n\n options = options || {};\n\n if (typeof options === 'string') {\n options = {\n separator: options\n };\n }\n\n var isChainArray = Array.isArray(chain);\n Assert(!isChainArray || !options.separator, 'Separator option no valid for array-based chain');\n var path = isChainArray ? chain : chain.split(options.separator || '.');\n var ref = obj;\n\n for (var i = 0; i < path.length; ++i) {\n var key = path[i];\n var type = options.iterables && internals.iterables(ref);\n\n if (Array.isArray(ref) || type === 'set') {\n var number = Number(key);\n\n if (Number.isInteger(number)) {\n key = number < 0 ? ref.length + number : number;\n }\n }\n\n if (!ref || typeof ref === 'function' && options.functions === false || // Defaults to true\n !type && ref[key] === undefined) {\n Assert(!options.strict || i + 1 === path.length, 'Missing segment', key, 'in reach path ', chain);\n Assert(_typeof(ref) === 'object' || options.functions === true || typeof ref !== 'function', 'Invalid segment', key, 'in reach path ', chain);\n ref = options.default;\n break;\n }\n\n if (!type) {\n ref = ref[key];\n } else if (type === 'set') {\n ref = _toConsumableArray(ref)[key];\n } else {\n // type === 'map'\n ref = ref.get(key);\n }\n }\n\n return ref;\n};\n\ninternals.iterables = function (ref) {\n if (ref instanceof Set) {\n return 'set';\n }\n\n if (ref instanceof Map) {\n return 'map';\n }\n};" + "source": "'use strict';\n\nconst Assert = require('./assert');\n\nconst internals = {};\n\nmodule.exports = function (obj, chain, options) {\n if (chain === false || chain === null || chain === undefined) {\n return obj;\n }\n\n options = options || {};\n\n if (typeof options === 'string') {\n options = {\n separator: options\n };\n }\n\n const isChainArray = Array.isArray(chain);\n Assert(!isChainArray || !options.separator, 'Separator option no valid for array-based chain');\n const path = isChainArray ? chain : chain.split(options.separator || '.');\n let ref = obj;\n\n for (let i = 0; i < path.length; ++i) {\n let key = path[i];\n const type = options.iterables && internals.iterables(ref);\n\n if (Array.isArray(ref) || type === 'set') {\n const number = Number(key);\n\n if (Number.isInteger(number)) {\n key = number < 0 ? ref.length + number : number;\n }\n }\n\n if (!ref || typeof ref === 'function' && options.functions === false || // Defaults to true\n !type && ref[key] === undefined) {\n Assert(!options.strict || i + 1 === path.length, 'Missing segment', key, 'in reach path ', chain);\n Assert(typeof ref === 'object' || options.functions === true || typeof ref !== 'function', 'Invalid segment', key, 'in reach path ', chain);\n ref = options.default;\n break;\n }\n\n if (!type) {\n ref = ref[key];\n } else if (type === 'set') {\n ref = [...ref][key];\n } else {\n // type === 'map'\n ref = ref.get(key);\n }\n }\n\n return ref;\n};\n\ninternals.iterables = function (ref) {\n if (ref instanceof Set) {\n return 'set';\n }\n\n if (ref instanceof Map) {\n return 'map';\n }\n};" }, { "id": 10, @@ -6030,7 +5937,7 @@ "name": "../lib/messages.js", "index": 13, "index2": 14, - "size": 4149, + "size": 3820, "cacheable": true, "built": true, "optional": false, @@ -6047,8 +5954,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -6056,16 +5963,16 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/common.js", "name": "../lib/common.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1398, - "building": 8, - "dependencies": 1 + "factory": 890, + "building": 9, + "dependencies": 0 }, "failed": false, "errors": 0, @@ -6079,7 +5986,7 @@ "moduleName": "../lib/common.js", "type": "cjs require", "userRequest": "./messages", - "loc": "145:25-46" + "loc": "127:25-46" }, { "moduleId": 19, @@ -6088,25 +5995,25 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "./messages", - "loc": "27:15-36" + "loc": "9:17-38" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./messages", - "loc": "41:15-36" + "loc": "23:17-38" }, { - "moduleId": 32, + "moduleId": 31, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/extend.js", "module": "../lib/extend.js", "moduleName": "../lib/extend.js", "type": "cjs require", "userRequest": "./messages", - "loc": "17:15-36" + "loc": "7:17-38" } ], "usedExports": true, @@ -6115,7 +6022,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Template = require('./template');\n\nvar internals = {};\n\nexports.compile = function (messages, target) {\n // Single value string ('plain error message', 'template {error} message')\n if (typeof messages === 'string') {\n Assert(!target, 'Cannot set single message string');\n return new Template(messages);\n } // Single value template\n\n\n if (Template.isTemplate(messages)) {\n Assert(!target, 'Cannot set single message template');\n return messages;\n } // By error code { 'number.min': }\n\n\n Assert(_typeof(messages) === 'object' && !Array.isArray(messages), 'Invalid message options');\n target = target ? Clone(target) : {};\n\n for (var code in messages) {\n var message = messages[code];\n\n if (code === 'root' || Template.isTemplate(message)) {\n target[code] = message;\n continue;\n }\n\n if (typeof message === 'string') {\n target[code] = new Template(message);\n continue;\n } // By language { english: { 'number.min': } }\n\n\n Assert(_typeof(message) === 'object' && !Array.isArray(message), 'Invalid message for', code);\n var language = code;\n target[language] = target[language] || {};\n\n for (code in message) {\n var localized = message[code];\n\n if (code === 'root' || Template.isTemplate(localized)) {\n target[language][code] = localized;\n continue;\n }\n\n Assert(typeof localized === 'string', 'Invalid message for', code, 'in', language);\n target[language][code] = new Template(localized);\n }\n }\n\n return target;\n};\n\nexports.decompile = function (messages) {\n // By error code { 'number.min': }\n var target = {};\n\n for (var code in messages) {\n var message = messages[code];\n\n if (code === 'root') {\n target[code] = message;\n continue;\n }\n\n if (Template.isTemplate(message)) {\n target[code] = message.describe({\n compact: true\n });\n continue;\n } // By language { english: { 'number.min': } }\n\n\n var language = code;\n target[language] = {};\n\n for (code in message) {\n var localized = message[code];\n\n if (code === 'root') {\n target[language][code] = localized;\n continue;\n }\n\n target[language][code] = localized.describe({\n compact: true\n });\n }\n }\n\n return target;\n};\n\nexports.merge = function (base, extended) {\n if (!base) {\n return exports.compile(extended);\n }\n\n if (!extended) {\n return base;\n } // Single value string\n\n\n if (typeof extended === 'string') {\n return new Template(extended);\n } // Single value template\n\n\n if (Template.isTemplate(extended)) {\n return extended;\n } // By error code { 'number.min': }\n\n\n var target = Clone(base);\n\n for (var code in extended) {\n var message = extended[code];\n\n if (code === 'root' || Template.isTemplate(message)) {\n target[code] = message;\n continue;\n }\n\n if (typeof message === 'string') {\n target[code] = new Template(message);\n continue;\n } // By language { english: { 'number.min': } }\n\n\n Assert(_typeof(message) === 'object' && !Array.isArray(message), 'Invalid message for', code);\n var language = code;\n target[language] = target[language] || {};\n\n for (code in message) {\n var localized = message[code];\n\n if (code === 'root' || Template.isTemplate(localized)) {\n target[language][code] = localized;\n continue;\n }\n\n Assert(typeof localized === 'string', 'Invalid message for', code, 'in', language);\n target[language][code] = new Template(localized);\n }\n }\n\n return target;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Template = require('./template');\n\nconst internals = {};\n\nexports.compile = function (messages, target) {\n // Single value string ('plain error message', 'template {error} message')\n if (typeof messages === 'string') {\n Assert(!target, 'Cannot set single message string');\n return new Template(messages);\n } // Single value template\n\n\n if (Template.isTemplate(messages)) {\n Assert(!target, 'Cannot set single message template');\n return messages;\n } // By error code { 'number.min': }\n\n\n Assert(typeof messages === 'object' && !Array.isArray(messages), 'Invalid message options');\n target = target ? Clone(target) : {};\n\n for (let code in messages) {\n const message = messages[code];\n\n if (code === 'root' || Template.isTemplate(message)) {\n target[code] = message;\n continue;\n }\n\n if (typeof message === 'string') {\n target[code] = new Template(message);\n continue;\n } // By language { english: { 'number.min': } }\n\n\n Assert(typeof message === 'object' && !Array.isArray(message), 'Invalid message for', code);\n const language = code;\n target[language] = target[language] || {};\n\n for (code in message) {\n const localized = message[code];\n\n if (code === 'root' || Template.isTemplate(localized)) {\n target[language][code] = localized;\n continue;\n }\n\n Assert(typeof localized === 'string', 'Invalid message for', code, 'in', language);\n target[language][code] = new Template(localized);\n }\n }\n\n return target;\n};\n\nexports.decompile = function (messages) {\n // By error code { 'number.min': }\n const target = {};\n\n for (let code in messages) {\n const message = messages[code];\n\n if (code === 'root') {\n target[code] = message;\n continue;\n }\n\n if (Template.isTemplate(message)) {\n target[code] = message.describe({\n compact: true\n });\n continue;\n } // By language { english: { 'number.min': } }\n\n\n const language = code;\n target[language] = {};\n\n for (code in message) {\n const localized = message[code];\n\n if (code === 'root') {\n target[language][code] = localized;\n continue;\n }\n\n target[language][code] = localized.describe({\n compact: true\n });\n }\n }\n\n return target;\n};\n\nexports.merge = function (base, extended) {\n if (!base) {\n return exports.compile(extended);\n }\n\n if (!extended) {\n return base;\n } // Single value string\n\n\n if (typeof extended === 'string') {\n return new Template(extended);\n } // Single value template\n\n\n if (Template.isTemplate(extended)) {\n return extended;\n } // By error code { 'number.min': }\n\n\n const target = Clone(base);\n\n for (let code in extended) {\n const message = extended[code];\n\n if (code === 'root' || Template.isTemplate(message)) {\n target[code] = message;\n continue;\n }\n\n if (typeof message === 'string') {\n target[code] = new Template(message);\n continue;\n } // By language { english: { 'number.min': } }\n\n\n Assert(typeof message === 'object' && !Array.isArray(message), 'Invalid message for', code);\n const language = code;\n target[language] = target[language] || {};\n\n for (code in message) {\n const localized = message[code];\n\n if (code === 'root' || Template.isTemplate(localized)) {\n target[language][code] = localized;\n continue;\n }\n\n Assert(typeof localized === 'string', 'Invalid message for', code, 'in', language);\n target[language][code] = new Template(localized);\n }\n }\n\n return target;\n};" }, { "id": 11, @@ -6123,7 +6030,7 @@ "name": "../lib/schemas.js", "index": 12, "index2": 9, - "size": 5717, + "size": 5721, "cacheable": true, "built": true, "optional": false, @@ -6140,15 +6047,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -6162,7 +6069,7 @@ "moduleName": "../lib/common.js", "type": "cjs require", "userRequest": "./schemas", - "loc": "77:23-43" + "loc": "59:23-43" }, { "moduleId": 14, @@ -6171,7 +6078,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./schemas", - "loc": "175:25-45" + "loc": "126:25-45" }, { "moduleId": 19, @@ -6180,7 +6087,7 @@ "moduleName": "../lib/manifest.js", "type": "cjs require", "userRequest": "./schemas", - "loc": "641:23-43" + "loc": "476:23-43" } ], "usedExports": true, @@ -6189,7 +6096,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar Joi = require('./index');\n\nvar internals = {}; // Preferences\n\nexports.preferences = Joi.object({\n allowUnknown: Joi.boolean(),\n abortEarly: Joi.boolean(),\n cache: Joi.boolean(),\n context: Joi.object(),\n convert: Joi.boolean(),\n dateFormat: Joi.valid('date', 'iso', 'string', 'time', 'utc'),\n errors: {\n escapeHtml: Joi.boolean(),\n language: [Joi.string(), Joi.object().ref()],\n stack: Joi.boolean(),\n wrapArrays: Joi.boolean()\n },\n externals: Joi.boolean(),\n messages: Joi.object(),\n noDefaults: Joi.boolean(),\n nonEnumerables: Joi.boolean(),\n presence: Joi.valid('required', 'optional', 'forbidden'),\n skipFunctions: Joi.boolean(),\n stripUnknown: Joi.object({\n arrays: Joi.boolean(),\n objects: Joi.boolean()\n }).or('arrays', 'objects').allow(true, false),\n warnings: Joi.boolean()\n}).strict(); // Extensions\n\ninternals.nameRx = /^[a-zA-Z0-9]+$/;\ninternals.rule = Joi.object({\n alias: Joi.array().items(Joi.string().pattern(internals.nameRx)).single(),\n method: Joi.func().allow(false),\n validate: Joi.func(),\n args: Joi.array().items(Joi.string(), Joi.object({\n name: Joi.string().pattern(internals.nameRx).required(),\n ref: Joi.boolean(),\n assert: Joi.alternatives([Joi.func(), Joi.object().schema()]).when('ref', {\n is: true,\n then: Joi.required(),\n otherwise: Joi.forbidden()\n }),\n normalize: Joi.func().when('ref', {\n is: true,\n otherwise: Joi.forbidden()\n }),\n message: Joi.string().when('assert', {\n is: Joi.object(),\n then: Joi.forbidden(),\n otherwise: Joi.required()\n })\n })),\n multi: Joi.boolean(),\n convert: Joi.boolean()\n});\nexports.extension = Joi.object({\n type: Joi.string().required(),\n args: Joi.func(),\n base: Joi.object().schema(),\n build: Joi.func().arity(2),\n coerce: Joi.func().maxArity(3),\n initialize: Joi.func().arity(1),\n messages: [Joi.object(), Joi.string()],\n modify: Joi.func().arity(3),\n rebuild: Joi.func().arity(1),\n rules: Joi.object().pattern(internals.nameRx, internals.rule),\n validate: Joi.func().maxArity(3)\n}).and('modify', 'rebuild').strict();\nexports.extensions = Joi.array().items(Joi.object(), Joi.func().arity(1)).strict(); // Manifest\n\ninternals.desc = {\n buffer: Joi.object({\n buffer: Joi.string()\n }),\n func: Joi.object({\n function: Joi.func().required(),\n options: {\n literal: true\n }\n }),\n ref: Joi.object({\n ref: Joi.object({\n type: Joi.valid('value', 'global', 'local'),\n path: Joi.array().required(),\n separator: Joi.string().length(1).allow(false),\n ancestor: Joi.number().min(0).integer().allow('root'),\n map: Joi.array().items(Joi.array().length(2)).min(1),\n adjust: Joi.func(),\n iterables: Joi.boolean()\n }).required()\n }),\n regex: Joi.object({\n regex: Joi.string().min(3)\n }),\n special: Joi.object({\n special: Joi.valid('deep').required()\n }),\n template: Joi.object({\n template: Joi.string().required(),\n options: Joi.object()\n }),\n value: Joi.object({\n value: Joi.alternatives([Joi.object(), Joi.array()]).required()\n })\n};\ninternals.desc.entity = Joi.alternatives([Joi.boolean(), Joi.func(), Joi.number(), Joi.string(), internals.desc.buffer, internals.desc.func, internals.desc.ref, internals.desc.regex, internals.desc.special, internals.desc.template, internals.desc.value, Joi.link('/')]);\ninternals.desc.values = Joi.array().items(null, Joi.boolean(), Joi.func(), Joi.number().allow(Infinity, -Infinity), Joi.string().allow(''), Joi.symbol(), internals.desc.buffer, internals.desc.func, internals.desc.ref, internals.desc.regex, internals.desc.template, internals.desc.value);\ninternals.desc.messages = Joi.object().pattern(/.+/, [Joi.string(), internals.desc.template, Joi.object().pattern(/.+/, [Joi.string(), internals.desc.template])]);\nexports.description = Joi.object({\n type: Joi.string().required(),\n flags: Joi.object({\n cast: Joi.string(),\n default: internals.desc.entity,\n description: Joi.string(),\n empty: Joi.link('/'),\n encoding: Joi.string(),\n failover: internals.desc.entity,\n format: Joi.string().valid('iso', 'javascript', 'unix'),\n id: Joi.string(),\n insensitive: Joi.boolean(),\n label: Joi.string(),\n only: true,\n presence: Joi.string().valid('optional', 'required', 'forbidden'),\n result: Joi.string().valid('raw', 'strip'),\n single: Joi.boolean(),\n sparse: Joi.boolean(),\n strip: Joi.boolean(),\n truncate: Joi.boolean(),\n unit: Joi.string(),\n unknown: true,\n unsafe: Joi.boolean()\n }).unknown(),\n preferences: {\n allowUnknown: Joi.boolean(),\n abortEarly: Joi.boolean(),\n cache: Joi.boolean(),\n convert: Joi.boolean(),\n dateFormat: Joi.valid('date', 'iso', 'string', 'time', 'utc'),\n errors: {\n escapeHtml: Joi.boolean(),\n language: [Joi.string(), internals.desc.ref],\n wrapArrays: Joi.boolean()\n },\n externals: Joi.boolean(),\n messages: internals.desc.messages,\n noDefaults: Joi.boolean(),\n nonEnumerables: Joi.boolean(),\n presence: Joi.valid('required', 'optional', 'forbidden'),\n skipFunctions: Joi.boolean(),\n stripUnknown: Joi.object({\n arrays: Joi.boolean(),\n objects: Joi.boolean()\n }).or('arrays', 'objects').allow(true, false),\n warnings: Joi.boolean()\n },\n allow: internals.desc.values,\n invalid: internals.desc.values,\n rules: Joi.array().min(1).items({\n name: Joi.string().required(),\n args: Joi.object().min(1),\n keep: Joi.boolean(),\n message: [Joi.string(), internals.desc.messages],\n warn: Joi.boolean()\n }),\n // Terms\n keys: Joi.object().pattern(/.*/, Joi.link('/')),\n link: internals.desc.ref\n}).pattern(/^[a-z]\\w*$/, Joi.any());" + "source": "'use strict';\n\nconst Joi = require('./index');\n\nconst internals = {}; // Preferences\n\nexports.preferences = Joi.object({\n allowUnknown: Joi.boolean(),\n abortEarly: Joi.boolean(),\n cache: Joi.boolean(),\n context: Joi.object(),\n convert: Joi.boolean(),\n dateFormat: Joi.valid('date', 'iso', 'string', 'time', 'utc'),\n errors: {\n escapeHtml: Joi.boolean(),\n language: [Joi.string(), Joi.object().ref()],\n stack: Joi.boolean(),\n wrapArrays: Joi.boolean()\n },\n externals: Joi.boolean(),\n messages: Joi.object(),\n noDefaults: Joi.boolean(),\n nonEnumerables: Joi.boolean(),\n presence: Joi.valid('required', 'optional', 'forbidden'),\n skipFunctions: Joi.boolean(),\n stripUnknown: Joi.object({\n arrays: Joi.boolean(),\n objects: Joi.boolean()\n }).or('arrays', 'objects').allow(true, false),\n warnings: Joi.boolean()\n}).strict(); // Extensions\n\ninternals.nameRx = /^[a-zA-Z0-9]+$/;\ninternals.rule = Joi.object({\n alias: Joi.array().items(Joi.string().pattern(internals.nameRx)).single(),\n method: Joi.func().allow(false),\n validate: Joi.func(),\n args: Joi.array().items(Joi.string(), Joi.object({\n name: Joi.string().pattern(internals.nameRx).required(),\n ref: Joi.boolean(),\n assert: Joi.alternatives([Joi.func(), Joi.object().schema()]).when('ref', {\n is: true,\n then: Joi.required(),\n otherwise: Joi.forbidden()\n }),\n normalize: Joi.func().when('ref', {\n is: true,\n otherwise: Joi.forbidden()\n }),\n message: Joi.string().when('assert', {\n is: Joi.object(),\n then: Joi.forbidden(),\n otherwise: Joi.required()\n })\n })),\n multi: Joi.boolean(),\n convert: Joi.boolean()\n});\nexports.extension = Joi.object({\n type: Joi.string().required(),\n args: Joi.func(),\n base: Joi.object().schema(),\n build: Joi.func().arity(2),\n coerce: Joi.func().maxArity(3),\n initialize: Joi.func().arity(1),\n messages: [Joi.object(), Joi.string()],\n modify: Joi.func().arity(3),\n rebuild: Joi.func().arity(1),\n rules: Joi.object().pattern(internals.nameRx, internals.rule),\n validate: Joi.func().maxArity(3)\n}).and('modify', 'rebuild').strict();\nexports.extensions = Joi.array().items(Joi.object(), Joi.func().arity(1)).strict(); // Manifest\n\ninternals.desc = {\n buffer: Joi.object({\n buffer: Joi.string()\n }),\n func: Joi.object({\n function: Joi.func().required(),\n options: {\n literal: true\n }\n }),\n ref: Joi.object({\n ref: Joi.object({\n type: Joi.valid('value', 'global', 'local'),\n path: Joi.array().required(),\n separator: Joi.string().length(1).allow(false),\n ancestor: Joi.number().min(0).integer().allow('root'),\n map: Joi.array().items(Joi.array().length(2)).min(1),\n adjust: Joi.func(),\n iterables: Joi.boolean()\n }).required()\n }),\n regex: Joi.object({\n regex: Joi.string().min(3)\n }),\n special: Joi.object({\n special: Joi.valid('deep').required()\n }),\n template: Joi.object({\n template: Joi.string().required(),\n options: Joi.object()\n }),\n value: Joi.object({\n value: Joi.alternatives([Joi.object(), Joi.array()]).required()\n })\n};\ninternals.desc.entity = Joi.alternatives([Joi.boolean(), Joi.func(), Joi.number(), Joi.string(), internals.desc.buffer, internals.desc.func, internals.desc.ref, internals.desc.regex, internals.desc.special, internals.desc.template, internals.desc.value, Joi.link('/')]);\ninternals.desc.values = Joi.array().items(null, Joi.boolean(), Joi.func(), Joi.number().allow(Infinity, -Infinity), Joi.string().allow(''), Joi.symbol(), internals.desc.buffer, internals.desc.func, internals.desc.ref, internals.desc.regex, internals.desc.template, internals.desc.value);\ninternals.desc.messages = Joi.object().pattern(/.+/, [Joi.string(), internals.desc.template, Joi.object().pattern(/.+/, [Joi.string(), internals.desc.template])]);\nexports.description = Joi.object({\n type: Joi.string().required(),\n flags: Joi.object({\n cast: Joi.string(),\n default: internals.desc.entity,\n description: Joi.string(),\n empty: Joi.link('/'),\n encoding: Joi.string(),\n failover: internals.desc.entity,\n format: Joi.string().valid('iso', 'javascript', 'unix'),\n id: Joi.string(),\n insensitive: Joi.boolean(),\n label: Joi.string(),\n only: true,\n presence: Joi.string().valid('optional', 'required', 'forbidden'),\n result: Joi.string().valid('raw', 'strip'),\n single: Joi.boolean(),\n sparse: Joi.boolean(),\n strip: Joi.boolean(),\n truncate: Joi.boolean(),\n unit: Joi.string(),\n unknown: true,\n unsafe: Joi.boolean()\n }).unknown(),\n preferences: {\n allowUnknown: Joi.boolean(),\n abortEarly: Joi.boolean(),\n cache: Joi.boolean(),\n convert: Joi.boolean(),\n dateFormat: Joi.valid('date', 'iso', 'string', 'time', 'utc'),\n errors: {\n escapeHtml: Joi.boolean(),\n language: [Joi.string(), internals.desc.ref],\n wrapArrays: Joi.boolean()\n },\n externals: Joi.boolean(),\n messages: internals.desc.messages,\n noDefaults: Joi.boolean(),\n nonEnumerables: Joi.boolean(),\n presence: Joi.valid('required', 'optional', 'forbidden'),\n skipFunctions: Joi.boolean(),\n stripUnknown: Joi.object({\n arrays: Joi.boolean(),\n objects: Joi.boolean()\n }).or('arrays', 'objects').allow(true, false),\n warnings: Joi.boolean()\n },\n allow: internals.desc.values,\n invalid: internals.desc.values,\n rules: Joi.array().min(1).items({\n name: Joi.string().required(),\n args: Joi.object().min(1),\n keep: Joi.boolean(),\n message: [Joi.string(), internals.desc.messages],\n warn: Joi.boolean()\n }),\n // Terms\n keys: Joi.object().pattern(/.*/, Joi.link('/')),\n link: internals.desc.ref\n}).pattern(/^[a-z]\\w*$/, Joi.any());" }, { "id": 12, @@ -6197,7 +6104,7 @@ "name": "../node_modules/@hapi/hoek/lib/deepEqual.js", "index": 24, "index2": 20, - "size": 11569, + "size": 6172, "cacheable": true, "built": true, "optional": false, @@ -6206,7 +6113,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", - "issuerId": 35, + "issuerId": 34, "issuerName": "../lib/types/array.js", "issuerPath": [ { @@ -6214,25 +6121,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 35, + "id": 34, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "name": "../lib/types/array.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1026, - "building": 91, - "dependencies": 298 + "factory": 574, + "building": 43, + "dependencies": 24 }, "failed": false, "errors": 0, @@ -6240,31 +6147,31 @@ "assets": [], "reasons": [ { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/deepEqual", - "loc": "25:16-51" + "loc": "7:18-53" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/deepEqual", - "loc": "17:16-51" + "loc": "7:18-53" }, { - "moduleId": 50, + "moduleId": 49, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/contain.js", "module": "../node_modules/@hapi/hoek/lib/contain.js", "moduleName": "../node_modules/@hapi/hoek/lib/contain.js", "type": "cjs require", "userRequest": "./deepEqual", - "loc": "15:16-38" + "loc": "5:18-40" } ], "usedExports": true, @@ -6273,15 +6180,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Types = require('./types');\n\nvar internals = {\n mismatched: null\n};\n\nmodule.exports = function (obj, ref, options) {\n options = Object.assign({\n prototype: true\n }, options);\n return !!internals.isDeepEqual(obj, ref, options, []);\n};\n\ninternals.isDeepEqual = function (obj, ref, options, seen) {\n if (obj === ref) {\n // Copied from Deep-eql, copyright(c) 2013 Jake Luer, jake@alogicalparadox.com, MIT Licensed, https://github.com/chaijs/deep-eql\n return obj !== 0 || 1 / obj === 1 / ref;\n }\n\n var type = _typeof(obj);\n\n if (type !== _typeof(ref)) {\n return false;\n }\n\n if (obj === null || ref === null) {\n return false;\n }\n\n if (type === 'function') {\n if (!options.deepFunction || obj.toString() !== ref.toString()) {\n return false;\n } // Continue as object\n\n } else if (type !== 'object') {\n return obj !== obj && ref !== ref; // NaN\n }\n\n var instanceType = internals.getSharedType(obj, ref, !!options.prototype);\n\n switch (instanceType) {\n case Types.buffer:\n return Buffer && Buffer.prototype.equals.call(obj, ref);\n // $lab:coverage:ignore$\n\n case Types.promise:\n return obj === ref;\n\n case Types.regex:\n return obj.toString() === ref.toString();\n\n case internals.mismatched:\n return false;\n }\n\n for (var i = seen.length - 1; i >= 0; --i) {\n if (seen[i].isSame(obj, ref)) {\n return true; // If previous comparison failed, it would have stopped execution\n }\n }\n\n seen.push(new internals.SeenEntry(obj, ref));\n\n try {\n return !!internals.isDeepEqualObj(instanceType, obj, ref, options, seen);\n } finally {\n seen.pop();\n }\n};\n\ninternals.getSharedType = function (obj, ref, checkPrototype) {\n if (checkPrototype) {\n if (Object.getPrototypeOf(obj) !== Object.getPrototypeOf(ref)) {\n return internals.mismatched;\n }\n\n return Types.getInternalProto(obj);\n }\n\n var type = Types.getInternalProto(obj);\n\n if (type !== Types.getInternalProto(ref)) {\n return internals.mismatched;\n }\n\n return type;\n};\n\ninternals.valueOf = function (obj) {\n var objValueOf = obj.valueOf;\n\n if (objValueOf === undefined) {\n return obj;\n }\n\n try {\n return objValueOf.call(obj);\n } catch (err) {\n return err;\n }\n};\n\ninternals.hasOwnEnumerableProperty = function (obj, key) {\n return Object.prototype.propertyIsEnumerable.call(obj, key);\n};\n\ninternals.isSetSimpleEqual = function (obj, ref) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = obj[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var entry = _step.value;\n\n if (!ref.has(entry)) {\n return false;\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return true;\n};\n\ninternals.isDeepEqualObj = function (instanceType, obj, ref, options, seen) {\n var isDeepEqual = internals.isDeepEqual,\n valueOf = internals.valueOf,\n hasOwnEnumerableProperty = internals.hasOwnEnumerableProperty;\n var keys = Object.keys,\n getOwnPropertySymbols = Object.getOwnPropertySymbols;\n\n if (instanceType === Types.array) {\n if (options.part) {\n // Check if any index match any other index\n for (var i = 0; i < obj.length; ++i) {\n var objValue = obj[i];\n\n for (var j = 0; j < ref.length; ++j) {\n if (isDeepEqual(objValue, ref[j], options, seen)) {\n return true;\n }\n }\n }\n } else {\n if (obj.length !== ref.length) {\n return false;\n }\n\n for (var _i = 0; _i < obj.length; ++_i) {\n if (!isDeepEqual(obj[_i], ref[_i], options, seen)) {\n return false;\n }\n }\n\n return true;\n }\n } else if (instanceType === Types.set) {\n if (obj.size !== ref.size) {\n return false;\n }\n\n if (!internals.isSetSimpleEqual(obj, ref)) {\n // Check for deep equality\n var ref2 = new Set(ref);\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = obj[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var objEntry = _step2.value;\n\n if (ref2.delete(objEntry)) {\n continue;\n }\n\n var found = false;\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = ref2[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var refEntry = _step3.value;\n\n if (isDeepEqual(objEntry, refEntry, options, seen)) {\n ref2.delete(refEntry);\n found = true;\n break;\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n if (!found) {\n return false;\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n } else if (instanceType === Types.map) {\n if (obj.size !== ref.size) {\n return false;\n }\n\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = obj[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var _step4$value = _slicedToArray(_step4.value, 2),\n key = _step4$value[0],\n value = _step4$value[1];\n\n if (value === undefined && !ref.has(key)) {\n return false;\n }\n\n if (!isDeepEqual(value, ref.get(key), options, seen)) {\n return false;\n }\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n } else if (instanceType === Types.error) {\n // Always check name and message\n if (obj.name !== ref.name || obj.message !== ref.message) {\n return false;\n }\n } // Check .valueOf()\n\n\n var valueOfObj = valueOf(obj);\n var valueOfRef = valueOf(ref);\n\n if (!(obj === valueOfObj && ref === valueOfRef) && !isDeepEqual(valueOfObj, valueOfRef, options, seen)) {\n return false;\n } // Check properties\n\n\n var objKeys = keys(obj);\n\n if (!options.part && objKeys.length !== keys(ref).length) {\n return false;\n }\n\n for (var _i2 = 0; _i2 < objKeys.length; ++_i2) {\n var key = objKeys[_i2];\n\n if (!hasOwnEnumerableProperty(ref, key)) {\n return false;\n }\n\n if (options.skip && options.skip.includes(key)) {\n continue;\n }\n\n if (!isDeepEqual(obj[key], ref[key], options, seen)) {\n return false;\n }\n } // Check symbols\n\n\n if (options.symbols !== false) {\n // Defaults to true\n var objSymbols = getOwnPropertySymbols(obj);\n var refSymbols = new Set(getOwnPropertySymbols(ref));\n\n for (var _i3 = 0; _i3 < objSymbols.length; ++_i3) {\n var _key = objSymbols[_i3];\n\n if (hasOwnEnumerableProperty(obj, _key)) {\n if (!hasOwnEnumerableProperty(ref, _key)) {\n return false;\n }\n\n if (!(options.skip && options.skip.includes(_key)) && !isDeepEqual(obj[_key], ref[_key], options, seen)) {\n return false;\n }\n } else if (hasOwnEnumerableProperty(ref, _key)) {\n return false;\n }\n\n refSymbols.delete(_key);\n }\n\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = refSymbols[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var _key2 = _step5.value;\n\n if (hasOwnEnumerableProperty(ref, _key2)) {\n return false;\n }\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n }\n\n return true;\n};\n\ninternals.SeenEntry =\n/*#__PURE__*/\nfunction () {\n function _class(obj, ref) {\n _classCallCheck(this, _class);\n\n this.obj = obj;\n this.ref = ref;\n }\n\n _createClass(_class, [{\n key: \"isSame\",\n value: function isSame(obj, ref) {\n return this.obj === obj && this.ref === ref;\n }\n }]);\n\n return _class;\n}();" + "source": "'use strict';\n\nconst Types = require('./types');\n\nconst internals = {\n mismatched: null\n};\n\nmodule.exports = function (obj, ref, options) {\n options = Object.assign({\n prototype: true\n }, options);\n return !!internals.isDeepEqual(obj, ref, options, []);\n};\n\ninternals.isDeepEqual = function (obj, ref, options, seen) {\n if (obj === ref) {\n // Copied from Deep-eql, copyright(c) 2013 Jake Luer, jake@alogicalparadox.com, MIT Licensed, https://github.com/chaijs/deep-eql\n return obj !== 0 || 1 / obj === 1 / ref;\n }\n\n const type = typeof obj;\n\n if (type !== typeof ref) {\n return false;\n }\n\n if (obj === null || ref === null) {\n return false;\n }\n\n if (type === 'function') {\n if (!options.deepFunction || obj.toString() !== ref.toString()) {\n return false;\n } // Continue as object\n\n } else if (type !== 'object') {\n return obj !== obj && ref !== ref; // NaN\n }\n\n const instanceType = internals.getSharedType(obj, ref, !!options.prototype);\n\n switch (instanceType) {\n case Types.buffer:\n return Buffer && Buffer.prototype.equals.call(obj, ref);\n // $lab:coverage:ignore$\n\n case Types.promise:\n return obj === ref;\n\n case Types.regex:\n return obj.toString() === ref.toString();\n\n case internals.mismatched:\n return false;\n }\n\n for (let i = seen.length - 1; i >= 0; --i) {\n if (seen[i].isSame(obj, ref)) {\n return true; // If previous comparison failed, it would have stopped execution\n }\n }\n\n seen.push(new internals.SeenEntry(obj, ref));\n\n try {\n return !!internals.isDeepEqualObj(instanceType, obj, ref, options, seen);\n } finally {\n seen.pop();\n }\n};\n\ninternals.getSharedType = function (obj, ref, checkPrototype) {\n if (checkPrototype) {\n if (Object.getPrototypeOf(obj) !== Object.getPrototypeOf(ref)) {\n return internals.mismatched;\n }\n\n return Types.getInternalProto(obj);\n }\n\n const type = Types.getInternalProto(obj);\n\n if (type !== Types.getInternalProto(ref)) {\n return internals.mismatched;\n }\n\n return type;\n};\n\ninternals.valueOf = function (obj) {\n const objValueOf = obj.valueOf;\n\n if (objValueOf === undefined) {\n return obj;\n }\n\n try {\n return objValueOf.call(obj);\n } catch (err) {\n return err;\n }\n};\n\ninternals.hasOwnEnumerableProperty = function (obj, key) {\n return Object.prototype.propertyIsEnumerable.call(obj, key);\n};\n\ninternals.isSetSimpleEqual = function (obj, ref) {\n for (const entry of obj) {\n if (!ref.has(entry)) {\n return false;\n }\n }\n\n return true;\n};\n\ninternals.isDeepEqualObj = function (instanceType, obj, ref, options, seen) {\n const {\n isDeepEqual,\n valueOf,\n hasOwnEnumerableProperty\n } = internals;\n const {\n keys,\n getOwnPropertySymbols\n } = Object;\n\n if (instanceType === Types.array) {\n if (options.part) {\n // Check if any index match any other index\n for (let i = 0; i < obj.length; ++i) {\n const objValue = obj[i];\n\n for (let j = 0; j < ref.length; ++j) {\n if (isDeepEqual(objValue, ref[j], options, seen)) {\n return true;\n }\n }\n }\n } else {\n if (obj.length !== ref.length) {\n return false;\n }\n\n for (let i = 0; i < obj.length; ++i) {\n if (!isDeepEqual(obj[i], ref[i], options, seen)) {\n return false;\n }\n }\n\n return true;\n }\n } else if (instanceType === Types.set) {\n if (obj.size !== ref.size) {\n return false;\n }\n\n if (!internals.isSetSimpleEqual(obj, ref)) {\n // Check for deep equality\n const ref2 = new Set(ref);\n\n for (const objEntry of obj) {\n if (ref2.delete(objEntry)) {\n continue;\n }\n\n let found = false;\n\n for (const refEntry of ref2) {\n if (isDeepEqual(objEntry, refEntry, options, seen)) {\n ref2.delete(refEntry);\n found = true;\n break;\n }\n }\n\n if (!found) {\n return false;\n }\n }\n }\n } else if (instanceType === Types.map) {\n if (obj.size !== ref.size) {\n return false;\n }\n\n for (const [key, value] of obj) {\n if (value === undefined && !ref.has(key)) {\n return false;\n }\n\n if (!isDeepEqual(value, ref.get(key), options, seen)) {\n return false;\n }\n }\n } else if (instanceType === Types.error) {\n // Always check name and message\n if (obj.name !== ref.name || obj.message !== ref.message) {\n return false;\n }\n } // Check .valueOf()\n\n\n const valueOfObj = valueOf(obj);\n const valueOfRef = valueOf(ref);\n\n if (!(obj === valueOfObj && ref === valueOfRef) && !isDeepEqual(valueOfObj, valueOfRef, options, seen)) {\n return false;\n } // Check properties\n\n\n const objKeys = keys(obj);\n\n if (!options.part && objKeys.length !== keys(ref).length) {\n return false;\n }\n\n for (let i = 0; i < objKeys.length; ++i) {\n const key = objKeys[i];\n\n if (!hasOwnEnumerableProperty(ref, key)) {\n return false;\n }\n\n if (options.skip && options.skip.includes(key)) {\n continue;\n }\n\n if (!isDeepEqual(obj[key], ref[key], options, seen)) {\n return false;\n }\n } // Check symbols\n\n\n if (options.symbols !== false) {\n // Defaults to true\n const objSymbols = getOwnPropertySymbols(obj);\n const refSymbols = new Set(getOwnPropertySymbols(ref));\n\n for (let i = 0; i < objSymbols.length; ++i) {\n const key = objSymbols[i];\n\n if (hasOwnEnumerableProperty(obj, key)) {\n if (!hasOwnEnumerableProperty(ref, key)) {\n return false;\n }\n\n if (!(options.skip && options.skip.includes(key)) && !isDeepEqual(obj[key], ref[key], options, seen)) {\n return false;\n }\n } else if (hasOwnEnumerableProperty(ref, key)) {\n return false;\n }\n\n refSymbols.delete(key);\n }\n\n for (const key of refSymbols) {\n if (hasOwnEnumerableProperty(ref, key)) {\n return false;\n }\n }\n }\n\n return true;\n};\n\ninternals.SeenEntry = class {\n constructor(obj, ref) {\n this.obj = obj;\n this.ref = ref;\n }\n\n isSame(obj, ref) {\n return this.obj === obj && this.ref === ref;\n }\n\n};" }, { "id": 13, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/escapeRegex.js", "name": "../node_modules/@hapi/hoek/lib/escapeRegex.js", - "index": 48, - "index2": 46, - "size": 188, + "index": 47, + "index2": 45, + "size": 190, "cacheable": true, "built": true, "optional": false, @@ -6290,7 +6197,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", - "issuerId": 43, + "issuerId": 42, "issuerName": "../lib/types/string/index.js", "issuerPath": [ { @@ -6298,25 +6205,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 }, "failed": false, "errors": 0, @@ -6324,31 +6231,31 @@ "assets": [], "reasons": [ { - "moduleId": 25, + "moduleId": 24, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/uri.js", "module": "../lib/types/string/uri.js", "moduleName": "../lib/types/string/uri.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/escapeRegex", - "loc": "5:18-55" + "loc": "5:20-57" }, { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/escapeRegex", - "loc": "15:18-55" + "loc": "13:20-57" }, { - "moduleId": 50, + "moduleId": 49, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/contain.js", "module": "../node_modules/@hapi/hoek/lib/contain.js", "moduleName": "../node_modules/@hapi/hoek/lib/contain.js", "type": "cjs require", "userRequest": "./escapeRegex", - "loc": "17:18-42" + "loc": "7:20-44" } ], "usedExports": true, @@ -6357,15 +6264,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nvar internals = {};\n\nmodule.exports = function (string) {\n // Escape ^$.*+-?=!:|\\/()[]{},\n return string.replace(/[\\^\\$\\.\\*\\+\\-\\?\\=\\!\\:\\|\\\\\\/\\(\\)\\[\\]\\{\\}\\,]/g, '\\\\$&');\n};" + "source": "'use strict';\n\nconst internals = {};\n\nmodule.exports = function (string) {\n // Escape ^$.*+-?=!:|\\/()[]{},\n return string.replace(/[\\^\\$\\.\\*\\+\\-\\?\\=\\!\\:\\|\\\\\\/\\(\\)\\[\\]\\{\\}\\,]/g, '\\\\$&');\n};" }, { "id": 14, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "index": 0, - "index2": 53, - "size": 8203, + "index2": 52, + "size": 5044, "cacheable": true, "built": true, "optional": false, @@ -6378,8 +6285,8 @@ "issuerName": null, "issuerPath": null, "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 }, "failed": false, "errors": 0, @@ -6393,7 +6300,7 @@ "moduleName": "../lib/schemas.js", "type": "cjs require", "userRequest": "./index", - "loc": "3:10-28" + "loc": "3:12-30" }, { "moduleId": null, @@ -6411,7 +6318,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 0, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Cache = require('./cache');\n\nvar Common = require('./common');\n\nvar Compile = require('./compile');\n\nvar Errors = require('./errors');\n\nvar Manifest = require('./manifest');\n\nvar Ref = require('./ref');\n\nvar Template = require('./template');\n\nvar Pkg = require('../package.json');\n\nvar Schemas;\nvar internals = {\n types: {\n alternatives: require('./types/alternatives'),\n any: require('./types/any'),\n array: require('./types/array'),\n boolean: require('./types/boolean'),\n date: require('./types/date'),\n function: require('./types/function'),\n link: require('./types/link'),\n number: require('./types/number'),\n object: require('./types/object'),\n string: require('./types/string'),\n symbol: require('./types/symbol')\n }\n};\n\nif (Buffer) {\n // $lab:coverage:ignore$\n internals.types.binary = require('./types/binary');\n}\n\ninternals.root = function () {\n var root = {\n _types: new Set(Object.keys(internals.types))\n }; // Types\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n var _loop = function _loop() {\n var type = _step.value;\n\n root[type] = function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n Assert(!args.length || ['alternatives', 'link', 'object'].includes(type), 'The', type, 'type does not allow arguments');\n return internals.generate(this, internals.types[type], args);\n };\n };\n\n for (var _iterator = root._types[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n _loop();\n } // Shortcuts\n\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n var _loop2 = function _loop2() {\n var method = _arr[_i];\n\n root[method] = function () {\n var _this$any;\n\n return (_this$any = this.any())[method].apply(_this$any, arguments);\n };\n };\n\n for (var _i = 0, _arr = ['allow', 'disallow', 'equal', 'exist', 'forbidden', 'invalid', 'not', 'optional', 'options', 'prefs', 'preferences', 'required', 'valid', 'when']; _i < _arr.length; _i++) {\n _loop2();\n } // Methods\n\n\n Object.assign(root, internals.methods); // Aliases\n\n root.alt = root.alternatives;\n root.attempt = root.assert;\n root.bool = root.boolean;\n root.func = root.function;\n root.x = root.expression;\n return root;\n};\n\ninternals.methods = {\n ValidationError: Errors.ValidationError,\n version: Pkg.version,\n cache: Cache.provider,\n assert: function assert(value, schema)\n /* [message], [options]*/\n {\n var first = arguments.length <= 2 ? undefined : arguments[2];\n var message = first instanceof Error || typeof first === 'string' ? first : null;\n var options = message ? arguments.length <= 3 ? undefined : arguments[3] : arguments.length <= 2 ? undefined : arguments[2];\n var result = schema.validate(value, options);\n var error = result.error;\n\n if (!error) {\n return result.value;\n }\n\n if (message instanceof Error) {\n throw message;\n }\n\n if (typeof error.annotate === 'function') {\n error.message = message ? \"\".concat(message, \" \").concat(error.annotate()) : error.annotate();\n }\n\n throw error;\n },\n build: function build(desc) {\n return Manifest.build(this, desc);\n },\n checkPreferences: function checkPreferences(prefs) {\n Common.checkPreferences(prefs);\n },\n compile: function compile(schema, options) {\n return Compile.compile(this, schema, options);\n },\n expression: function expression() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n return _construct(Template, args);\n },\n extend: function extend() {\n var _this = this;\n\n for (var _len3 = arguments.length, extensions = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n extensions[_key3] = arguments[_key3];\n }\n\n Common.verifyFlat(extensions, 'extend');\n Schemas = Schemas || require('./schemas');\n Assert(extensions.length, 'You need to provide at least one extension');\n this.assert(extensions, Schemas.extensions);\n var joi = Object.assign({}, this);\n joi._types = new Set(joi._types);\n\n var _loop3 = function _loop3() {\n var extension = _extensions[_i2];\n\n if (typeof extension === 'function') {\n extension = extension(joi);\n }\n\n _this.assert(extension, Schemas.extension);\n\n var base = extension.base || _this.any();\n\n var schema = base.extend(extension);\n\n joi._types.add(extension.type);\n\n joi[extension.type] = function () {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n\n return internals.generate(this, schema, args);\n };\n };\n\n for (var _i2 = 0, _extensions = extensions; _i2 < _extensions.length; _i2++) {\n _loop3();\n }\n\n return joi;\n },\n isExpression: Template.isTemplate,\n isRef: Ref.isRef,\n isSchema: Common.isSchema,\n ref: function ref() {\n return Ref.create.apply(Ref, arguments);\n },\n types: function types() {\n var types = {};\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = this._types[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var type = _step2.value;\n types[type] = this[type]();\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return types;\n }\n}; // Helpers\n\ninternals.generate = function (root, schema, args) {\n var _schema$_definition;\n\n Assert(root, 'Must be invoked on a Joi instance.');\n schema._root = root;\n\n if (!schema._definition.args || !args.length) {\n return schema;\n }\n\n return (_schema$_definition = schema._definition).args.apply(_schema$_definition, [schema].concat(_toConsumableArray(args)));\n};\n\nmodule.exports = internals.root();" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Cache = require('./cache');\n\nconst Common = require('./common');\n\nconst Compile = require('./compile');\n\nconst Errors = require('./errors');\n\nconst Manifest = require('./manifest');\n\nconst Ref = require('./ref');\n\nconst Template = require('./template');\n\nconst Pkg = require('../package.json');\n\nlet Schemas;\nconst internals = {\n types: {\n alternatives: require('./types/alternatives'),\n any: require('./types/any'),\n array: require('./types/array'),\n boolean: require('./types/boolean'),\n date: require('./types/date'),\n function: require('./types/function'),\n link: require('./types/link'),\n number: require('./types/number'),\n object: require('./types/object'),\n string: require('./types/string'),\n symbol: require('./types/symbol')\n }\n};\n\nif (Buffer) {\n // $lab:coverage:ignore$\n internals.types.binary = require('./types/binary');\n}\n\ninternals.root = function () {\n const root = {\n _types: new Set(Object.keys(internals.types))\n }; // Types\n\n for (const type of root._types) {\n root[type] = function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n Assert(!args.length || ['alternatives', 'link', 'object'].includes(type), 'The', type, 'type does not allow arguments');\n return internals.generate(this, internals.types[type], args);\n };\n } // Shortcuts\n\n\n for (const method of ['allow', 'disallow', 'equal', 'exist', 'forbidden', 'invalid', 'not', 'optional', 'options', 'prefs', 'preferences', 'required', 'valid', 'when']) {\n root[method] = function () {\n return this.any()[method](...arguments);\n };\n } // Methods\n\n\n Object.assign(root, internals.methods); // Aliases\n\n root.alt = root.alternatives;\n root.attempt = root.assert;\n root.bool = root.boolean;\n root.func = root.function;\n root.x = root.expression;\n return root;\n};\n\ninternals.methods = {\n ValidationError: Errors.ValidationError,\n version: Pkg.version,\n cache: Cache.provider,\n assert: function assert(value, schema)\n /* [message], [options]*/\n {\n const first = arguments.length <= 2 ? undefined : arguments[2];\n const message = first instanceof Error || typeof first === 'string' ? first : null;\n const options = message ? arguments.length <= 3 ? undefined : arguments[3] : arguments.length <= 2 ? undefined : arguments[2];\n const result = schema.validate(value, options);\n const error = result.error;\n\n if (!error) {\n return result.value;\n }\n\n if (message instanceof Error) {\n throw message;\n }\n\n if (typeof error.annotate === 'function') {\n error.message = message ? \"\".concat(message, \" \").concat(error.annotate()) : error.annotate();\n }\n\n throw error;\n },\n build: function build(desc) {\n return Manifest.build(this, desc);\n },\n checkPreferences: function checkPreferences(prefs) {\n Common.checkPreferences(prefs);\n },\n compile: function compile(schema, options) {\n return Compile.compile(this, schema, options);\n },\n expression: function expression() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n\n return new Template(...args);\n },\n extend: function extend() {\n for (var _len3 = arguments.length, extensions = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n extensions[_key3] = arguments[_key3];\n }\n\n Common.verifyFlat(extensions, 'extend');\n Schemas = Schemas || require('./schemas');\n Assert(extensions.length, 'You need to provide at least one extension');\n this.assert(extensions, Schemas.extensions);\n const joi = Object.assign({}, this);\n joi._types = new Set(joi._types);\n\n for (let extension of extensions) {\n if (typeof extension === 'function') {\n extension = extension(joi);\n }\n\n this.assert(extension, Schemas.extension);\n const base = extension.base || this.any();\n const schema = base.extend(extension);\n\n joi._types.add(extension.type);\n\n joi[extension.type] = function () {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n\n return internals.generate(this, schema, args);\n };\n }\n\n return joi;\n },\n isExpression: Template.isTemplate,\n isRef: Ref.isRef,\n isSchema: Common.isSchema,\n ref: function ref() {\n return Ref.create(...arguments);\n },\n types: function types() {\n const types = {};\n\n for (const type of this._types) {\n types[type] = this[type]();\n }\n\n return types;\n }\n}; // Helpers\n\ninternals.generate = function (root, schema, args) {\n Assert(root, 'Must be invoked on a Joi instance.');\n schema._root = root;\n\n if (!schema._definition.args || !args.length) {\n return schema;\n }\n\n return schema._definition.args(schema, ...args);\n};\n\nmodule.exports = internals.root();" }, { "id": 15, @@ -6419,7 +6326,7 @@ "name": "../node_modules/@hapi/hoek/lib/error.js", "index": 2, "index2": 1, - "size": 3928, + "size": 412, "cacheable": true, "built": true, "optional": false, @@ -6436,8 +6343,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -6445,16 +6352,16 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/common.js", "name": "../lib/common.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1398, - "building": 8, - "dependencies": 1 + "factory": 890, + "building": 9, + "dependencies": 0 }, "failed": false, "errors": 0, @@ -6468,7 +6375,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/assert.js", "type": "cjs require", "userRequest": "./error", - "loc": "3:18-36" + "loc": "3:20-38" }, { "moduleId": 1, @@ -6477,7 +6384,7 @@ "moduleName": "../lib/common.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/error", - "loc": "21:18-49" + "loc": "5:20-51" } ], "usedExports": true, @@ -6486,7 +6393,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nvar Stringify = require('./stringify');\n\nvar internals = {};\n\nmodule.exports =\n/*#__PURE__*/\nfunction (_Error) {\n _inherits(_class, _Error);\n\n function _class(args) {\n var _this;\n\n _classCallCheck(this, _class);\n\n var msgs = args.filter(function (arg) {\n return arg !== '';\n }).map(function (arg) {\n return typeof arg === 'string' ? arg : arg instanceof Error ? arg.message : Stringify(arg);\n });\n _this = _possibleConstructorReturn(this, _getPrototypeOf(_class).call(this, msgs.join(' ') || 'Unknown error'));\n Error.captureStackTrace(_assertThisInitialized(_this), exports.assert);\n return _this;\n }\n\n return _class;\n}(_wrapNativeSuper(Error));" + "source": "'use strict';\n\nconst Stringify = require('./stringify');\n\nconst internals = {};\nmodule.exports = class extends Error {\n constructor(args) {\n const msgs = args.filter(arg => arg !== '').map(arg => {\n return typeof arg === 'string' ? arg : arg instanceof Error ? arg.message : Stringify(arg);\n });\n super(msgs.join(' ') || 'Unknown error');\n Error.captureStackTrace(this, exports.assert);\n }\n\n};" }, { "id": 16, @@ -6494,7 +6401,7 @@ "name": "../lib/cache.js", "index": 4, "index2": 16, - "size": 4047, + "size": 2329, "cacheable": true, "built": true, "optional": false, @@ -6511,15 +6418,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -6533,16 +6440,16 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./cache", - "loc": "19:12-30" + "loc": "5:14-32" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./cache", - "loc": "29:12-30" + "loc": "11:14-32" } ], "usedExports": true, @@ -6551,7 +6458,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Common = require('./common');\n\nvar internals = {\n max: 1000,\n supported: new Set(['undefined', 'boolean', 'number', 'string'])\n};\nexports.provider = {\n provision: function provision(options) {\n return new internals.Cache(options);\n }\n}; // Least Recently Used (LRU) Cache\n\ninternals.Cache =\n/*#__PURE__*/\nfunction () {\n function _class() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n _classCallCheck(this, _class);\n\n Common.assertOptions(options, ['max']);\n Assert(options.max === undefined || options.max && options.max > 0 && isFinite(options.max), 'Invalid max cache size');\n this._max = options.max || internals.max;\n this._map = new Map(); // Map of nodes by key\n\n this._list = new internals.List(); // List of nodes (most recently used in head)\n }\n\n _createClass(_class, [{\n key: \"set\",\n value: function set(key, value) {\n if (key !== null && !internals.supported.has(_typeof(key))) {\n return;\n }\n\n var node = this._map.get(key);\n\n if (node) {\n node.value = value;\n\n this._list.first(node);\n\n return;\n }\n\n node = this._list.unshift({\n key: key,\n value: value\n });\n\n this._map.set(key, node);\n\n this._compact();\n }\n }, {\n key: \"get\",\n value: function get(key) {\n var node = this._map.get(key);\n\n if (node) {\n this._list.first(node);\n\n return Clone(node.value);\n }\n }\n }, {\n key: \"_compact\",\n value: function _compact() {\n if (this._map.size > this._max) {\n var node = this._list.pop();\n\n this._map.delete(node.key);\n }\n }\n }, {\n key: \"length\",\n get: function get() {\n return this._map.size;\n }\n }]);\n\n return _class;\n}();\n\ninternals.List =\n/*#__PURE__*/\nfunction () {\n function _class2() {\n _classCallCheck(this, _class2);\n\n this.tail = null;\n this.head = null;\n }\n\n _createClass(_class2, [{\n key: \"unshift\",\n value: function unshift(node) {\n node.next = null;\n node.prev = this.head;\n\n if (this.head) {\n this.head.next = node;\n }\n\n this.head = node;\n\n if (!this.tail) {\n this.tail = node;\n }\n\n return node;\n }\n }, {\n key: \"first\",\n value: function first(node) {\n if (node === this.head) {\n return;\n }\n\n this._remove(node);\n\n this.unshift(node);\n }\n }, {\n key: \"pop\",\n value: function pop() {\n return this._remove(this.tail);\n }\n }, {\n key: \"_remove\",\n value: function _remove(node) {\n var next = node.next,\n prev = node.prev;\n next.prev = prev;\n\n if (prev) {\n prev.next = next;\n }\n\n if (node === this.tail) {\n this.tail = next;\n }\n\n node.prev = null;\n node.next = null;\n return node;\n }\n }]);\n\n return _class2;\n}();" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Common = require('./common');\n\nconst internals = {\n max: 1000,\n supported: new Set(['undefined', 'boolean', 'number', 'string'])\n};\nexports.provider = {\n provision: function provision(options) {\n return new internals.Cache(options);\n }\n}; // Least Recently Used (LRU) Cache\n\ninternals.Cache = class {\n constructor() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['max']);\n Assert(options.max === undefined || options.max && options.max > 0 && isFinite(options.max), 'Invalid max cache size');\n this._max = options.max || internals.max;\n this._map = new Map(); // Map of nodes by key\n\n this._list = new internals.List(); // List of nodes (most recently used in head)\n }\n\n get length() {\n return this._map.size;\n }\n\n set(key, value) {\n if (key !== null && !internals.supported.has(typeof key)) {\n return;\n }\n\n let node = this._map.get(key);\n\n if (node) {\n node.value = value;\n\n this._list.first(node);\n\n return;\n }\n\n node = this._list.unshift({\n key,\n value\n });\n\n this._map.set(key, node);\n\n this._compact();\n }\n\n get(key) {\n const node = this._map.get(key);\n\n if (node) {\n this._list.first(node);\n\n return Clone(node.value);\n }\n }\n\n _compact() {\n if (this._map.size > this._max) {\n const node = this._list.pop();\n\n this._map.delete(node.key);\n }\n }\n\n};\ninternals.List = class {\n constructor() {\n this.tail = null;\n this.head = null;\n }\n\n unshift(node) {\n node.next = null;\n node.prev = this.head;\n\n if (this.head) {\n this.head.next = node;\n }\n\n this.head = node;\n\n if (!this.tail) {\n this.tail = node;\n }\n\n return node;\n }\n\n first(node) {\n if (node === this.head) {\n return;\n }\n\n this._remove(node);\n\n this.unshift(node);\n }\n\n pop() {\n return this._remove(this.tail);\n }\n\n _remove(node) {\n const {\n next,\n prev\n } = node;\n next.prev = prev;\n\n if (prev) {\n prev.next = next;\n }\n\n if (node === this.tail) {\n this.tail = next;\n }\n\n node.prev = null;\n node.next = null;\n return node;\n }\n\n};" }, { "id": 17, @@ -6559,7 +6466,7 @@ "name": "../node_modules/@hapi/hoek/lib/types.js", "index": 6, "index2": 3, - "size": 1084, + "size": 1088, "cacheable": true, "built": true, "optional": false, @@ -6576,8 +6483,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -6585,9 +6492,9 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/cache.js", "name": "../lib/cache.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { @@ -6595,14 +6502,14 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/clone.js", "name": "../node_modules/@hapi/hoek/lib/clone.js", "profile": { - "factory": 1052, - "building": 123 + "factory": 614, + "building": 142 } } ], "profile": { - "factory": 368, - "building": 118, + "factory": 185, + "building": 102, "dependencies": 0 }, "failed": false, @@ -6617,7 +6524,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/clone.js", "type": "cjs require", "userRequest": "./types", - "loc": "13:12-30" + "loc": "3:14-32" }, { "moduleId": 12, @@ -6626,7 +6533,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/deepEqual.js", "type": "cjs require", "userRequest": "./types", - "loc": "19:12-30" + "loc": "3:14-32" } ], "usedExports": true, @@ -6635,7 +6542,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nvar internals = {};\nexports = module.exports = {\n array: Array.prototype,\n buffer: Buffer && Buffer.prototype,\n // $lab:coverage:ignore$\n date: Date.prototype,\n error: Error.prototype,\n generic: Object.prototype,\n map: Map.prototype,\n promise: Promise.prototype,\n regex: RegExp.prototype,\n set: Set.prototype,\n weakMap: WeakMap.prototype,\n weakSet: WeakSet.prototype\n};\ninternals.typeMap = new Map([['[object Error]', exports.error], ['[object Map]', exports.map], ['[object Promise]', exports.promise], ['[object Set]', exports.set], ['[object WeakMap]', exports.weakMap], ['[object WeakSet]', exports.weakSet]]);\n\nexports.getInternalProto = function (obj) {\n if (Array.isArray(obj)) {\n return exports.array;\n }\n\n if (Buffer && obj instanceof Buffer) {\n // $lab:coverage:ignore$\n return exports.buffer;\n }\n\n if (obj instanceof Date) {\n return exports.date;\n }\n\n if (obj instanceof RegExp) {\n return exports.regex;\n }\n\n var objName = Object.prototype.toString.call(obj);\n return internals.typeMap.get(objName) || exports.generic;\n};" + "source": "'use strict';\n\nconst internals = {};\nexports = module.exports = {\n array: Array.prototype,\n buffer: Buffer && Buffer.prototype,\n // $lab:coverage:ignore$\n date: Date.prototype,\n error: Error.prototype,\n generic: Object.prototype,\n map: Map.prototype,\n promise: Promise.prototype,\n regex: RegExp.prototype,\n set: Set.prototype,\n weakMap: WeakMap.prototype,\n weakSet: WeakSet.prototype\n};\ninternals.typeMap = new Map([['[object Error]', exports.error], ['[object Map]', exports.map], ['[object Promise]', exports.promise], ['[object Set]', exports.set], ['[object WeakMap]', exports.weakMap], ['[object WeakSet]', exports.weakSet]]);\n\nexports.getInternalProto = function (obj) {\n if (Array.isArray(obj)) {\n return exports.array;\n }\n\n if (Buffer && obj instanceof Buffer) {\n // $lab:coverage:ignore$\n return exports.buffer;\n }\n\n if (obj instanceof Date) {\n return exports.date;\n }\n\n if (obj instanceof RegExp) {\n return exports.regex;\n }\n\n const objName = Object.prototype.toString.call(obj);\n return internals.typeMap.get(objName) || exports.generic;\n};" }, { "id": 18, @@ -6660,15 +6567,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -6682,7 +6589,7 @@ "moduleName": "../lib/common.js", "type": "cjs require", "userRequest": "../package.json", - "loc": "25:10-36" + "loc": "9:12-38" }, { "moduleId": 14, @@ -6691,7 +6598,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "../package.json", - "loc": "33:10-36" + "loc": "19:12-38" } ], "usedExports": true, @@ -6721,7 +6628,7 @@ "name": "../lib/manifest.js", "index": 20, "index2": 19, - "size": 17706, + "size": 10323, "cacheable": true, "built": true, "optional": false, @@ -6738,15 +6645,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -6760,16 +6667,16 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./manifest", - "loc": "27:15-36" + "loc": "13:17-38" }, { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./manifest", - "loc": "39:15-36" + "loc": "21:17-38" } ], "usedExports": true, @@ -6778,7 +6685,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Common = require('./common');\n\nvar Messages = require('./messages');\n\nvar Ref = require('./ref');\n\nvar Template = require('./template');\n\nvar Schemas;\nvar internals = {};\n\nexports.describe = function (schema) {\n // Type\n var desc = {\n type: schema.type,\n flags: {},\n rules: []\n }; // Flags\n\n for (var flag in schema._flags) {\n if (flag[0] !== '_' && schema._flags[flag] !== internals.flagDefaults(desc.type, flag)) {\n desc.flags[flag] = internals.describe(schema._flags[flag]);\n }\n }\n\n if (!Object.keys(desc.flags).length) {\n delete desc.flags;\n } // Preferences\n\n\n if (schema._preferences) {\n desc.preferences = Clone(schema._preferences, {\n shallow: ['messages']\n });\n delete desc.preferences[Common.symbols.prefs];\n\n if (desc.preferences.messages) {\n desc.preferences.messages = Messages.decompile(desc.preferences.messages);\n }\n } // Allow / Invalid\n\n\n if (schema._valids) {\n desc.allow = schema._valids.describe();\n }\n\n if (schema._invalids) {\n desc.invalid = schema._invalids.describe();\n } // Rules\n\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = schema._rules[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var rule = _step.value;\n\n if (rule.name === 'items') {\n continue;\n }\n\n var _item2 = {\n name: rule.name\n };\n\n for (var _i2 = 0, _arr = ['keep', 'message', 'warn']; _i2 < _arr.length; _i2++) {\n var custom = _arr[_i2];\n\n if (rule[custom] !== undefined) {\n _item2[custom] = internals.describe(rule[custom]);\n }\n }\n\n if (rule.args) {\n _item2.args = {};\n\n for (var key in rule.args) {\n var arg = rule.args[key];\n\n if (key === 'options' && !Object.keys(arg).length) {\n continue;\n }\n\n _item2.args[key] = internals.describe(arg, {\n assign: key\n });\n }\n\n if (!Object.keys(_item2.args).length) {\n delete _item2.args;\n }\n }\n\n desc.rules.push(_item2);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n if (!desc.rules.length) {\n delete desc.rules;\n } // Terms\n\n\n for (var term in schema.$_terms) {\n if (term[0] === '_') {\n continue;\n }\n\n Assert(!desc[term], 'Cannot describe schema due to internal name conflict with', term);\n var items = schema.$_terms[term];\n\n if (!items) {\n continue;\n }\n\n if (items instanceof Map) {\n if (items.size) {\n desc[term] = _toConsumableArray(items.entries());\n }\n\n continue;\n }\n\n if (Common.isValues(items)) {\n if (items.length) {\n desc[term] = items.describe();\n }\n\n continue;\n }\n\n if (!items.length && term !== 'keys') {\n continue;\n }\n\n var normalized = [];\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = items[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var _item = _step2.value;\n normalized.push(internals.describe(_item));\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (term === 'keys') {\n var mapped = {};\n\n for (var _i = 0, _normalized = normalized; _i < _normalized.length; _i++) {\n var item = _normalized[_i];\n mapped[item.key] = item.schema;\n }\n\n normalized = mapped;\n }\n\n desc[term] = term === 'link' ? normalized[0] : normalized;\n }\n\n internals.validate(schema._root, desc);\n return desc;\n};\n\ninternals.describe = function (item) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (item === Common.symbols.deepDefault) {\n return {\n special: 'deep'\n };\n }\n\n if (_typeof(item) !== 'object') {\n return item;\n }\n\n if (options.assign === 'options' || Array.isArray(item)) {\n return Clone(item);\n }\n\n if (Buffer && Buffer.isBuffer(item)) {\n // $lab:coverage:ignore$\n return {\n buffer: item.toString('binary')\n };\n }\n\n if (item instanceof Date) {\n return item.toISOString();\n }\n\n if (item instanceof RegExp) {\n if (options.assign === 'regex') {\n return item.toString();\n }\n\n return {\n regex: item.toString()\n };\n }\n\n if (item[Common.symbols.literal]) {\n return {\n function: item.literal,\n options: {\n literal: true\n }\n };\n }\n\n if (typeof item.describe === 'function') {\n if (options.assign === 'ref') {\n return item.describe().ref;\n }\n\n return item.describe();\n }\n\n var normalized = {};\n\n for (var key in item) {\n var value = item[key];\n\n if (value === undefined || value === null) {\n continue;\n }\n\n normalized[key] = internals.describe(value, {\n assign: key\n });\n }\n\n return normalized;\n};\n\nexports.build = function (joi, desc) {\n var builder = new internals.Builder(joi);\n return builder.parse(desc);\n};\n\ninternals.Builder =\n/*#__PURE__*/\nfunction () {\n function _class(joi) {\n _classCallCheck(this, _class);\n\n this.joi = joi;\n }\n\n _createClass(_class, [{\n key: \"parse\",\n value: function parse(desc) {\n var _this = this;\n\n internals.validate(this.joi, desc); // Type\n\n var schema = this.joi[desc.type]();\n var def = schema._definition; // Flags\n\n if (desc.flags) {\n for (var flag in desc.flags) {\n schema = schema[flag](this.build(desc.flags[flag]));\n }\n } // Preferences\n\n\n if (desc.preferences) {\n schema = schema.preferences(this.structure(desc.preferences));\n } // Allow / Invalid\n\n\n if (desc.allow) {\n var _schema;\n\n schema = (_schema = schema).allow.apply(_schema, _toConsumableArray(this.build(desc.allow)));\n }\n\n if (desc.invalid) {\n var _schema2;\n\n schema = (_schema2 = schema).invalid.apply(_schema2, _toConsumableArray(this.build(desc.invalid)));\n } // Rules\n\n\n if (desc.rules) {\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = desc.rules[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var _schema3;\n\n var rule = _step3.value;\n Assert(typeof schema[rule.name] === 'function', 'Invalid rule', rule.name, 'for type', desc.type);\n var args = [];\n\n if (rule.args) {\n var built = {};\n\n for (var key in rule.args) {\n built[key] = this.build(rule.args[key], {\n assign: key\n });\n }\n\n var keys = Object.keys(built);\n var definition = def.rules[rule.name].args;\n\n if (definition) {\n Assert(keys.length <= definition.length, 'Invalid number of arguments for', desc.type, rule.name, '(expected up to', definition.length, ', found', keys.length, ')');\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = definition[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var name = _step4.value.name;\n args.push(built[name]);\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n } else {\n Assert(keys.length === 1, 'Invalid number of arguments for', desc.type, rule.name, '(expected up to 1, found', keys.length, ')');\n args.push(built[keys[0]]);\n }\n } // Apply\n\n\n schema = (_schema3 = schema)[rule.name].apply(_schema3, args); // Ruleset\n\n var options = {};\n\n for (var _i3 = 0, _arr2 = ['keep', 'message', 'warn']; _i3 < _arr2.length; _i3++) {\n var custom = _arr2[_i3];\n\n if (rule[custom] !== undefined) {\n options[custom] = this.build(rule[custom]);\n }\n }\n\n if (Object.keys(options).length) {\n schema = schema.rule(options);\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n } // Terms\n\n\n var terms = {};\n\n for (var _key in desc) {\n if (['allow', 'flags', 'invalid', 'keys', 'preferences', 'rules', 'type'].includes(_key)) {\n continue;\n }\n\n if (['items', 'ordered'].includes(_key)) {\n terms[_key] = desc[_key].map(function (item) {\n return _this.parse(item);\n });\n continue;\n }\n\n if (['falsy', 'truthy'].includes(_key)) {\n terms[_key] = desc[_key].map(function (item) {\n return _this.build(item);\n });\n continue;\n }\n\n if (_key === 'link') {\n terms.link = this.build(desc.link);\n continue;\n }\n\n var values = this.structure(desc[_key]);\n\n if (['examples', 'externals', 'metas', 'notes', 'tags'].includes(_key)) {\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = values[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var value = _step5.value;\n schema = schema[_key.slice(0, -1)](value);\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n } else if (_key === 'alterations') {\n var alter = {};\n var _iteratorNormalCompletion6 = true;\n var _didIteratorError6 = false;\n var _iteratorError6 = undefined;\n\n try {\n for (var _iterator6 = values[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {\n var _step6$value = _step6.value,\n target = _step6$value.target,\n adjuster = _step6$value.adjuster;\n alter[target] = adjuster;\n }\n } catch (err) {\n _didIteratorError6 = true;\n _iteratorError6 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion6 && _iterator6.return != null) {\n _iterator6.return();\n }\n } finally {\n if (_didIteratorError6) {\n throw _iteratorError6;\n }\n }\n }\n\n schema = schema.alter(alter);\n } else {\n terms[_key] = values;\n }\n }\n\n if (desc.keys) {\n terms.keys = {};\n\n for (var _key2 in desc.keys) {\n terms.keys[_key2] = this.parse(desc.keys[_key2]);\n }\n }\n\n if (def.build && Object.keys(terms).length) {\n schema = def.build(schema, terms);\n }\n\n return schema;\n }\n }, {\n key: \"build\",\n value: function build(desc) {\n var _this2 = this;\n\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (desc === null) {\n return null;\n }\n\n if (Array.isArray(desc)) {\n return desc.map(function (item) {\n return _this2.build(item);\n });\n }\n\n if (options.assign === 'options') {\n return Clone(desc);\n }\n\n if (options.assign === 'regex') {\n return internals.regex(desc);\n }\n\n if (_typeof(desc) !== 'object') {\n return desc;\n }\n\n if (desc.buffer) {\n Assert(Buffer, 'Buffers are not supported');\n return Buffer && Buffer.from(desc.buffer, 'binary'); // $lab:coverage:ignore$\n }\n\n if (desc.function) {\n var _ref;\n\n return _ref = {}, _defineProperty(_ref, Common.symbols.literal, true), _defineProperty(_ref, \"literal\", desc.function), _ref;\n }\n\n if (options.assign === 'ref') {\n return Ref.build(desc);\n }\n\n if (desc.ref) {\n return Ref.build(desc.ref);\n }\n\n if (desc.regex) {\n return internals.regex(desc.regex);\n }\n\n if (desc.special) {\n Assert(['deep'].includes(desc.special), 'Unknown special value', desc.special);\n return Common.symbols.deepDefault;\n }\n\n if (desc.type) {\n return this.parse(desc);\n }\n\n if (desc.value) {\n return Clone(desc.value);\n }\n\n if (desc.template) {\n return Template.build(desc);\n }\n }\n }, {\n key: \"structure\",\n value: function structure(desc) {\n var _this3 = this;\n\n if (_typeof(desc) !== 'object') {\n return desc;\n }\n\n if (Array.isArray(desc)) {\n return desc.map(function (item) {\n return _this3.structure(item);\n });\n }\n\n var normalized = {};\n\n for (var key in desc) {\n var value = this.build(desc[key], {\n assign: key\n });\n\n if (value === undefined) {\n value = this.structure(desc[key]);\n }\n\n normalized[key] = value;\n }\n\n return normalized;\n }\n }]);\n\n return _class;\n}();\n\ninternals.regex = function (string) {\n var end = string.lastIndexOf('/');\n var exp = string.slice(1, end);\n var flags = string.slice(end + 1);\n return new RegExp(exp, flags);\n};\n\ninternals.validate = function (joi, desc) {\n Schemas = Schemas || require('./schemas');\n joi.assert(desc, Schemas.description);\n};\n\ninternals.flagDefaults = function (type, flag) {\n if (type === 'boolean' && flag === 'insensitive') {\n return true;\n }\n\n if (['insensitive', 'only', 'single', 'sparse', 'strip', 'truncate', 'unknown', 'unsafe'].includes(flag)) {\n return false;\n }\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Common = require('./common');\n\nconst Messages = require('./messages');\n\nconst Ref = require('./ref');\n\nconst Template = require('./template');\n\nlet Schemas;\nconst internals = {};\n\nexports.describe = function (schema) {\n // Type\n const desc = {\n type: schema.type,\n flags: {},\n rules: []\n }; // Flags\n\n for (const flag in schema._flags) {\n if (flag[0] !== '_' && schema._flags[flag] !== internals.flagDefaults(desc.type, flag)) {\n desc.flags[flag] = internals.describe(schema._flags[flag]);\n }\n }\n\n if (!Object.keys(desc.flags).length) {\n delete desc.flags;\n } // Preferences\n\n\n if (schema._preferences) {\n desc.preferences = Clone(schema._preferences, {\n shallow: ['messages']\n });\n delete desc.preferences[Common.symbols.prefs];\n\n if (desc.preferences.messages) {\n desc.preferences.messages = Messages.decompile(desc.preferences.messages);\n }\n } // Allow / Invalid\n\n\n if (schema._valids) {\n desc.allow = schema._valids.describe();\n }\n\n if (schema._invalids) {\n desc.invalid = schema._invalids.describe();\n } // Rules\n\n\n for (const rule of schema._rules) {\n if (rule.name === 'items') {\n continue;\n }\n\n const item = {\n name: rule.name\n };\n\n for (const custom of ['keep', 'message', 'warn']) {\n if (rule[custom] !== undefined) {\n item[custom] = internals.describe(rule[custom]);\n }\n }\n\n if (rule.args) {\n item.args = {};\n\n for (const key in rule.args) {\n const arg = rule.args[key];\n\n if (key === 'options' && !Object.keys(arg).length) {\n continue;\n }\n\n item.args[key] = internals.describe(arg, {\n assign: key\n });\n }\n\n if (!Object.keys(item.args).length) {\n delete item.args;\n }\n }\n\n desc.rules.push(item);\n }\n\n if (!desc.rules.length) {\n delete desc.rules;\n } // Terms\n\n\n for (const term in schema.$_terms) {\n if (term[0] === '_') {\n continue;\n }\n\n Assert(!desc[term], 'Cannot describe schema due to internal name conflict with', term);\n const items = schema.$_terms[term];\n\n if (!items) {\n continue;\n }\n\n if (items instanceof Map) {\n if (items.size) {\n desc[term] = [...items.entries()];\n }\n\n continue;\n }\n\n if (Common.isValues(items)) {\n if (items.length) {\n desc[term] = items.describe();\n }\n\n continue;\n }\n\n if (!items.length && term !== 'keys') {\n continue;\n }\n\n let normalized = [];\n\n for (const item of items) {\n normalized.push(internals.describe(item));\n }\n\n if (term === 'keys') {\n const mapped = {};\n\n for (const item of normalized) {\n mapped[item.key] = item.schema;\n }\n\n normalized = mapped;\n }\n\n desc[term] = term === 'link' ? normalized[0] : normalized;\n }\n\n internals.validate(schema._root, desc);\n return desc;\n};\n\ninternals.describe = function (item) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (item === Common.symbols.deepDefault) {\n return {\n special: 'deep'\n };\n }\n\n if (typeof item !== 'object') {\n return item;\n }\n\n if (options.assign === 'options' || Array.isArray(item)) {\n return Clone(item);\n }\n\n if (Buffer && Buffer.isBuffer(item)) {\n // $lab:coverage:ignore$\n return {\n buffer: item.toString('binary')\n };\n }\n\n if (item instanceof Date) {\n return item.toISOString();\n }\n\n if (item instanceof RegExp) {\n if (options.assign === 'regex') {\n return item.toString();\n }\n\n return {\n regex: item.toString()\n };\n }\n\n if (item[Common.symbols.literal]) {\n return {\n function: item.literal,\n options: {\n literal: true\n }\n };\n }\n\n if (typeof item.describe === 'function') {\n if (options.assign === 'ref') {\n return item.describe().ref;\n }\n\n return item.describe();\n }\n\n const normalized = {};\n\n for (const key in item) {\n const value = item[key];\n\n if (value === undefined || value === null) {\n continue;\n }\n\n normalized[key] = internals.describe(value, {\n assign: key\n });\n }\n\n return normalized;\n};\n\nexports.build = function (joi, desc) {\n const builder = new internals.Builder(joi);\n return builder.parse(desc);\n};\n\ninternals.Builder = class {\n constructor(joi) {\n this.joi = joi;\n }\n\n parse(desc) {\n internals.validate(this.joi, desc); // Type\n\n let schema = this.joi[desc.type]();\n const def = schema._definition; // Flags\n\n if (desc.flags) {\n for (const flag in desc.flags) {\n schema = schema[flag](this.build(desc.flags[flag]));\n }\n } // Preferences\n\n\n if (desc.preferences) {\n schema = schema.preferences(this.structure(desc.preferences));\n } // Allow / Invalid\n\n\n if (desc.allow) {\n schema = schema.allow(...this.build(desc.allow));\n }\n\n if (desc.invalid) {\n schema = schema.invalid(...this.build(desc.invalid));\n } // Rules\n\n\n if (desc.rules) {\n for (const rule of desc.rules) {\n Assert(typeof schema[rule.name] === 'function', 'Invalid rule', rule.name, 'for type', desc.type);\n const args = [];\n\n if (rule.args) {\n const built = {};\n\n for (const key in rule.args) {\n built[key] = this.build(rule.args[key], {\n assign: key\n });\n }\n\n const keys = Object.keys(built);\n const definition = def.rules[rule.name].args;\n\n if (definition) {\n Assert(keys.length <= definition.length, 'Invalid number of arguments for', desc.type, rule.name, '(expected up to', definition.length, ', found', keys.length, ')');\n\n for (const _ref of definition) {\n const {\n name\n } = _ref;\n args.push(built[name]);\n }\n } else {\n Assert(keys.length === 1, 'Invalid number of arguments for', desc.type, rule.name, '(expected up to 1, found', keys.length, ')');\n args.push(built[keys[0]]);\n }\n } // Apply\n\n\n schema = schema[rule.name](...args); // Ruleset\n\n const options = {};\n\n for (const custom of ['keep', 'message', 'warn']) {\n if (rule[custom] !== undefined) {\n options[custom] = this.build(rule[custom]);\n }\n }\n\n if (Object.keys(options).length) {\n schema = schema.rule(options);\n }\n }\n } // Terms\n\n\n const terms = {};\n\n for (const key in desc) {\n if (['allow', 'flags', 'invalid', 'keys', 'preferences', 'rules', 'type'].includes(key)) {\n continue;\n }\n\n if (['items', 'ordered'].includes(key)) {\n terms[key] = desc[key].map(item => this.parse(item));\n continue;\n }\n\n if (['falsy', 'truthy'].includes(key)) {\n terms[key] = desc[key].map(item => this.build(item));\n continue;\n }\n\n if (key === 'link') {\n terms.link = this.build(desc.link);\n continue;\n }\n\n const values = this.structure(desc[key]);\n\n if (['examples', 'externals', 'metas', 'notes', 'tags'].includes(key)) {\n for (const value of values) {\n schema = schema[key.slice(0, -1)](value);\n }\n } else if (key === 'alterations') {\n const alter = {};\n\n for (const _ref2 of values) {\n const {\n target,\n adjuster\n } = _ref2;\n alter[target] = adjuster;\n }\n\n schema = schema.alter(alter);\n } else {\n terms[key] = values;\n }\n }\n\n if (desc.keys) {\n terms.keys = {};\n\n for (const key in desc.keys) {\n terms.keys[key] = this.parse(desc.keys[key]);\n }\n }\n\n if (def.build && Object.keys(terms).length) {\n schema = def.build(schema, terms);\n }\n\n return schema;\n }\n\n build(desc) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (desc === null) {\n return null;\n }\n\n if (Array.isArray(desc)) {\n return desc.map(item => this.build(item));\n }\n\n if (options.assign === 'options') {\n return Clone(desc);\n }\n\n if (options.assign === 'regex') {\n return internals.regex(desc);\n }\n\n if (typeof desc !== 'object') {\n return desc;\n }\n\n if (desc.buffer) {\n Assert(Buffer, 'Buffers are not supported');\n return Buffer && Buffer.from(desc.buffer, 'binary'); // $lab:coverage:ignore$\n }\n\n if (desc.function) {\n return {\n [Common.symbols.literal]: true,\n literal: desc.function\n };\n }\n\n if (options.assign === 'ref') {\n return Ref.build(desc);\n }\n\n if (desc.ref) {\n return Ref.build(desc.ref);\n }\n\n if (desc.regex) {\n return internals.regex(desc.regex);\n }\n\n if (desc.special) {\n Assert(['deep'].includes(desc.special), 'Unknown special value', desc.special);\n return Common.symbols.deepDefault;\n }\n\n if (desc.type) {\n return this.parse(desc);\n }\n\n if (desc.value) {\n return Clone(desc.value);\n }\n\n if (desc.template) {\n return Template.build(desc);\n }\n }\n\n structure(desc) {\n if (typeof desc !== 'object') {\n return desc;\n }\n\n if (Array.isArray(desc)) {\n return desc.map(item => this.structure(item));\n }\n\n const normalized = {};\n\n for (const key in desc) {\n let value = this.build(desc[key], {\n assign: key\n });\n\n if (value === undefined) {\n value = this.structure(desc[key]);\n }\n\n normalized[key] = value;\n }\n\n return normalized;\n }\n\n};\n\ninternals.regex = function (string) {\n const end = string.lastIndexOf('/');\n const exp = string.slice(1, end);\n const flags = string.slice(end + 1);\n return new RegExp(exp, flags);\n};\n\ninternals.validate = function (joi, desc) {\n Schemas = Schemas || require('./schemas');\n joi.assert(desc, Schemas.description);\n};\n\ninternals.flagDefaults = function (type, flag) {\n if (type === 'boolean' && flag === 'insensitive') {\n return true;\n }\n\n if (['insensitive', 'only', 'single', 'sparse', 'strip', 'truncate', 'unknown', 'unsafe'].includes(flag)) {\n return false;\n }\n};" }, { "id": 20, @@ -6786,7 +6693,7 @@ "name": "../node_modules/@hapi/hoek/lib/merge.js", "index": 25, "index2": 21, - "size": 2246, + "size": 1895, "cacheable": true, "built": true, "optional": false, @@ -6795,7 +6702,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", - "issuerId": 31, + "issuerId": 30, "issuerName": "../lib/base.js", "issuerPath": [ { @@ -6803,8 +6710,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -6812,25 +6719,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/any.js", "name": "../lib/types/any.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 31, + "id": 30, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "name": "../lib/base.js", "profile": { - "factory": 767, - "building": 322, + "factory": 353, + "building": 264, "dependencies": 2 } } ], "profile": { - "factory": 169, - "building": 279, + "factory": 101, + "building": 141, "dependencies": 0 }, "failed": false, @@ -6839,22 +6746,22 @@ "assets": [], "reasons": [ { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/merge", - "loc": "27:12-43" + "loc": "9:14-45" }, { - "moduleId": 39, + "moduleId": 38, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/applyToDefaults.js", "module": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "moduleName": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "type": "cjs require", "userRequest": "./merge", - "loc": "9:12-30" + "loc": "7:14-32" } ], "usedExports": true, @@ -6863,7 +6770,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('./assert');\n\nvar Clone = require('./clone');\n\nvar Utils = require('./utils');\n\nvar internals = {};\n\nmodule.exports = internals.merge = function (target, source, options) {\n Assert(target && _typeof(target) === 'object', 'Invalid target value: must be an object');\n Assert(source === null || source === undefined || _typeof(source) === 'object', 'Invalid source value: must be null, undefined, or an object');\n\n if (!source) {\n return target;\n }\n\n options = Object.assign({\n nullOverride: true,\n mergeArrays: true\n }, options);\n\n if (Array.isArray(source)) {\n Assert(Array.isArray(target), 'Cannot merge array onto an object');\n\n if (!options.mergeArrays) {\n target.length = 0; // Must not change target assignment\n }\n\n for (var i = 0; i < source.length; ++i) {\n target.push(Clone(source[i], {\n symbols: options.symbols\n }));\n }\n\n return target;\n }\n\n var keys = Utils.keys(source, options);\n\n for (var _i = 0; _i < keys.length; ++_i) {\n var key = keys[_i];\n\n if (key === '__proto__' || !Object.prototype.propertyIsEnumerable.call(source, key)) {\n continue;\n }\n\n var value = source[key];\n\n if (value && _typeof(value) === 'object') {\n if (!target[key] || _typeof(target[key]) !== 'object' || Array.isArray(target[key]) !== Array.isArray(value) || value instanceof Date || Buffer && Buffer.isBuffer(value) || // $lab:coverage:ignore$\n value instanceof RegExp) {\n target[key] = Clone(value, {\n symbols: options.symbols\n });\n } else {\n internals.merge(target[key], value, options);\n }\n } else {\n if (value !== null && value !== undefined) {\n // Explicit to preserve empty strings\n target[key] = value;\n } else if (options.nullOverride) {\n target[key] = value;\n }\n }\n }\n\n return target;\n};" + "source": "'use strict';\n\nconst Assert = require('./assert');\n\nconst Clone = require('./clone');\n\nconst Utils = require('./utils');\n\nconst internals = {};\n\nmodule.exports = internals.merge = function (target, source, options) {\n Assert(target && typeof target === 'object', 'Invalid target value: must be an object');\n Assert(source === null || source === undefined || typeof source === 'object', 'Invalid source value: must be null, undefined, or an object');\n\n if (!source) {\n return target;\n }\n\n options = Object.assign({\n nullOverride: true,\n mergeArrays: true\n }, options);\n\n if (Array.isArray(source)) {\n Assert(Array.isArray(target), 'Cannot merge array onto an object');\n\n if (!options.mergeArrays) {\n target.length = 0; // Must not change target assignment\n }\n\n for (let i = 0; i < source.length; ++i) {\n target.push(Clone(source[i], {\n symbols: options.symbols\n }));\n }\n\n return target;\n }\n\n const keys = Utils.keys(source, options);\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n\n if (key === '__proto__' || !Object.prototype.propertyIsEnumerable.call(source, key)) {\n continue;\n }\n\n const value = source[key];\n\n if (value && typeof value === 'object') {\n if (!target[key] || typeof target[key] !== 'object' || Array.isArray(target[key]) !== Array.isArray(value) || value instanceof Date || Buffer && Buffer.isBuffer(value) || // $lab:coverage:ignore$\n value instanceof RegExp) {\n target[key] = Clone(value, {\n symbols: options.symbols\n });\n } else {\n internals.merge(target[key], value, options);\n }\n } else {\n if (value !== null && value !== undefined) {\n // Explicit to preserve empty strings\n target[key] = value;\n } else if (options.nullOverride) {\n target[key] = value;\n }\n }\n }\n\n return target;\n};" }, { "id": 21, @@ -6871,7 +6778,7 @@ "name": "../lib/values.js", "index": 29, "index2": 25, - "size": 11148, + "size": 4449, "cacheable": true, "built": true, "optional": false, @@ -6880,7 +6787,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", - "issuerId": 36, + "issuerId": 35, "issuerName": "../lib/types/boolean.js", "issuerPath": [ { @@ -6888,24 +6795,24 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 36, + "id": 35, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", "name": "../lib/types/boolean.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 496, - "building": 358, + "factory": 333, + "building": 276, "dependencies": 0 }, "failed": false, @@ -6914,22 +6821,22 @@ "assets": [], "reasons": [ { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./values", - "loc": "49:13-32" + "loc": "31:15-34" }, { - "moduleId": 36, + "moduleId": 35, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", "module": "../lib/types/boolean.js", "moduleName": "../lib/types/boolean.js", "type": "cjs require", "userRequest": "../values", - "loc": "17:13-33" + "loc": "9:15-35" } ], "usedExports": true, @@ -6938,7 +6845,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Common = require('./common');\n\nvar internals = {};\n\nmodule.exports = internals.Values =\n/*#__PURE__*/\nfunction () {\n function _class(from) {\n _classCallCheck(this, _class);\n\n this._set = new Set(from);\n this._resolve = false;\n }\n\n _createClass(_class, [{\n key: \"add\",\n value: function add(value, refs) {\n if (this.has(value, null, null, false)) {\n return;\n }\n\n if (refs !== undefined) {\n // If it's a merge, we don't have any refs\n refs.register(value);\n }\n\n this._set.add(value);\n\n if (Common.isResolvable(value)) {\n this._resolve = true;\n }\n }\n }, {\n key: \"remove\",\n value: function remove(value) {\n this._set.delete(value);\n }\n }, {\n key: \"has\",\n value: function has(value, state, prefs, insensitive) {\n return !!this.get(value, state, prefs, insensitive);\n }\n }, {\n key: \"get\",\n value: function get(value, state, prefs, insensitive) {\n if (!this._set.size) {\n return false;\n }\n\n var hasValue = this._set.has(value);\n\n if (hasValue) {\n return {\n value: value\n };\n }\n\n if (!this._resolve && !insensitive && _typeof(value) !== 'object') {\n return false;\n }\n\n var extendedCheck = internals.extendedCheckForValue(value, insensitive);\n\n if (!extendedCheck) {\n if (state && this._resolve) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = this._set[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var item = _step.value;\n\n if (Common.isResolvable(item)) {\n item = [].concat(item.resolve(value, state, prefs));\n var found = item.indexOf(value);\n\n if (found >= 0) {\n return {\n value: item[found]\n };\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n\n return false;\n }\n\n return this._has(value, state, prefs, extendedCheck);\n }\n }, {\n key: \"_has\",\n value: function _has(value, state, prefs, check) {\n var checkRef = !!(state && this._resolve);\n\n var isReallyEqual = function isReallyEqual(item) {\n if (value === item) {\n return true;\n }\n\n return check(item);\n };\n\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = this._set[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var item = _step2.value;\n\n if (checkRef && Common.isResolvable(item)) {\n // Only resolve references if there is a state, otherwise it's a merge\n item = item.resolve(value, state, prefs);\n\n if (Array.isArray(item)) {\n var found = item.findIndex(isReallyEqual);\n\n if (found >= 0) {\n return {\n value: item[found]\n };\n }\n\n continue;\n }\n }\n\n if (isReallyEqual(item)) {\n return {\n value: item\n };\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return false;\n }\n }, {\n key: \"values\",\n value: function values(options) {\n if (options && options.stripUndefined) {\n var values = [];\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = this._set[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var item = _step3.value;\n\n if (item !== undefined) {\n values.push(item);\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n return values;\n }\n\n return Array.from(this._set);\n }\n }, {\n key: \"clone\",\n value: function clone() {\n var set = new internals.Values(this._set);\n set._resolve = this._resolve;\n return set;\n }\n }, {\n key: \"concat\",\n value: function concat(source) {\n var set = new internals.Values([].concat(_toConsumableArray(this._set), _toConsumableArray(source._set)));\n set._resolve = this._resolve || source._resolve;\n return set;\n }\n }, {\n key: \"describe\",\n value: function describe() {\n var normalized = [];\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = this._set.values()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var value = _step4.value;\n normalized.push(Common.isResolvable(value) ? value.describe() : value && _typeof(value) === 'object' ? {\n value: value\n } : value);\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n\n return normalized;\n }\n }, {\n key: \"length\",\n get: function get() {\n return this._set.size;\n }\n }], [{\n key: \"merge\",\n value: function merge(target, add, remove) {\n target = target || new internals.Values();\n\n if (add) {\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = add._set[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var item = _step5.value;\n target.add(item);\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n }\n\n if (remove) {\n var _iteratorNormalCompletion6 = true;\n var _didIteratorError6 = false;\n var _iteratorError6 = undefined;\n\n try {\n for (var _iterator6 = remove._set[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {\n var _item = _step6.value;\n target.remove(_item);\n }\n } catch (err) {\n _didIteratorError6 = true;\n _iteratorError6 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion6 && _iterator6.return != null) {\n _iterator6.return();\n }\n } finally {\n if (_didIteratorError6) {\n throw _iteratorError6;\n }\n }\n }\n }\n\n return target.length ? target : null;\n }\n }]);\n\n return _class;\n}();\n\ninternals.Values.prototype[Common.symbols.values] = true; // Aliases\n\ninternals.Values.prototype.slice = internals.Values.prototype.clone;\n\ninternals.extendedCheckForValue = function (value, insensitive) {\n var valueType = _typeof(value);\n\n if (valueType === 'object') {\n if (value instanceof Date) {\n return function (item) {\n return item instanceof Date && value.getTime() === item.getTime();\n };\n }\n\n if (Buffer && Buffer.isBuffer(value)) {\n // $lab:coverage:ignore$\n return function (item) {\n return Buffer.isBuffer(item) && value.length === item.length && value.toString('binary') === item.toString('binary');\n };\n }\n } else if (insensitive && valueType === 'string') {\n var lowercaseValue = value.toLowerCase();\n return function (item) {\n return typeof item === 'string' && lowercaseValue === item.toLowerCase();\n };\n }\n\n return null;\n};" + "source": "'use strict';\n\nconst Common = require('./common');\n\nconst internals = {};\nmodule.exports = internals.Values = class {\n constructor(from) {\n this._set = new Set(from);\n this._resolve = false;\n }\n\n get length() {\n return this._set.size;\n }\n\n add(value, refs) {\n if (this.has(value, null, null, false)) {\n return;\n }\n\n if (refs !== undefined) {\n // If it's a merge, we don't have any refs\n refs.register(value);\n }\n\n this._set.add(value);\n\n if (Common.isResolvable(value)) {\n this._resolve = true;\n }\n }\n\n static merge(target, add, remove) {\n target = target || new internals.Values();\n\n if (add) {\n for (const item of add._set) {\n target.add(item);\n }\n }\n\n if (remove) {\n for (const item of remove._set) {\n target.remove(item);\n }\n }\n\n return target.length ? target : null;\n }\n\n remove(value) {\n this._set.delete(value);\n }\n\n has(value, state, prefs, insensitive) {\n return !!this.get(value, state, prefs, insensitive);\n }\n\n get(value, state, prefs, insensitive) {\n if (!this._set.size) {\n return false;\n }\n\n const hasValue = this._set.has(value);\n\n if (hasValue) {\n return {\n value\n };\n }\n\n if (!this._resolve && !insensitive && typeof value !== 'object') {\n return false;\n }\n\n const extendedCheck = internals.extendedCheckForValue(value, insensitive);\n\n if (!extendedCheck) {\n if (state && this._resolve) {\n for (let item of this._set) {\n if (Common.isResolvable(item)) {\n item = [].concat(item.resolve(value, state, prefs));\n const found = item.indexOf(value);\n\n if (found >= 0) {\n return {\n value: item[found]\n };\n }\n }\n }\n }\n\n return false;\n }\n\n return this._has(value, state, prefs, extendedCheck);\n }\n\n _has(value, state, prefs, check) {\n const checkRef = !!(state && this._resolve);\n\n const isReallyEqual = function isReallyEqual(item) {\n if (value === item) {\n return true;\n }\n\n return check(item);\n };\n\n for (let item of this._set) {\n if (checkRef && Common.isResolvable(item)) {\n // Only resolve references if there is a state, otherwise it's a merge\n item = item.resolve(value, state, prefs);\n\n if (Array.isArray(item)) {\n const found = item.findIndex(isReallyEqual);\n\n if (found >= 0) {\n return {\n value: item[found]\n };\n }\n\n continue;\n }\n }\n\n if (isReallyEqual(item)) {\n return {\n value: item\n };\n }\n }\n\n return false;\n }\n\n values(options) {\n if (options && options.stripUndefined) {\n const values = [];\n\n for (const item of this._set) {\n if (item !== undefined) {\n values.push(item);\n }\n }\n\n return values;\n }\n\n return Array.from(this._set);\n }\n\n clone() {\n const set = new internals.Values(this._set);\n set._resolve = this._resolve;\n return set;\n }\n\n concat(source) {\n const set = new internals.Values([...this._set, ...source._set]);\n set._resolve = this._resolve || source._resolve;\n return set;\n }\n\n describe() {\n const normalized = [];\n\n for (const value of this._set.values()) {\n normalized.push(Common.isResolvable(value) ? value.describe() : value && typeof value === 'object' ? {\n value\n } : value);\n }\n\n return normalized;\n }\n\n};\ninternals.Values.prototype[Common.symbols.values] = true; // Aliases\n\ninternals.Values.prototype.slice = internals.Values.prototype.clone;\n\ninternals.extendedCheckForValue = function (value, insensitive) {\n const valueType = typeof value;\n\n if (valueType === 'object') {\n if (value instanceof Date) {\n return item => {\n return item instanceof Date && value.getTime() === item.getTime();\n };\n }\n\n if (Buffer && Buffer.isBuffer(value)) {\n // $lab:coverage:ignore$\n return item => {\n return Buffer.isBuffer(item) && value.length === item.length && value.toString('binary') === item.toString('binary');\n };\n }\n } else if (insensitive && valueType === 'string') {\n const lowercaseValue = value.toLowerCase();\n return item => {\n return typeof item === 'string' && lowercaseValue === item.toLowerCase();\n };\n }\n\n return null;\n};" }, { "id": 22, @@ -6946,7 +6853,7 @@ "name": "../node_modules/@hapi/bourne/lib/index.js", "index": 31, "index2": 29, - "size": 2156, + "size": 1744, "cacheable": true, "built": true, "optional": false, @@ -6955,7 +6862,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", - "issuerId": 35, + "issuerId": 34, "issuerName": "../lib/types/array.js", "issuerPath": [ { @@ -6963,25 +6870,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 35, + "id": 34, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "name": "../lib/types/array.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1026, - "building": 91, - "dependencies": 298 + "factory": 574, + "building": 43, + "dependencies": 24 }, "failed": false, "errors": 0, @@ -6995,16 +6902,16 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "@hapi/bourne", - "loc": "43:13-36" + "loc": "7:15-38" }, { - "moduleId": 35, + "moduleId": 34, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "module": "../lib/types/array.js", "moduleName": "../lib/types/array.js", "type": "cjs require", "userRequest": "@hapi/bourne", - "loc": "15:13-36" + "loc": "5:15-38" } ], "usedExports": true, @@ -7013,7 +6920,7 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar internals = {\n suspectRx: /\"(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])(?:p|\\\\u0070)(?:r|\\\\u0072)(?:o|\\\\u006[Ff])(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])\"\\s*\\:/\n};\n\nexports.parse = function (text, reviver, options) {\n // Normalize arguments\n if (!options) {\n if (reviver && _typeof(reviver) === 'object') {\n options = reviver;\n reviver = undefined;\n } else {\n options = {};\n }\n } // Parse normally, allowing exceptions\n\n\n var obj = JSON.parse(text, reviver); // options.protoAction: 'error' (default) / 'remove' / 'ignore'\n\n if (options.protoAction === 'ignore') {\n return obj;\n } // Ignore null and non-objects\n\n\n if (!obj || _typeof(obj) !== 'object') {\n return obj;\n } // Check original string for potential exploit\n\n\n if (!text.match(internals.suspectRx)) {\n return obj;\n } // Scan result for proto keys\n\n\n exports.scan(obj, options);\n return obj;\n};\n\nexports.scan = function (obj, options) {\n options = options || {};\n var next = [obj];\n\n while (next.length) {\n var nodes = next;\n next = [];\n\n for (var _i = 0, _nodes = nodes; _i < _nodes.length; _i++) {\n var node = _nodes[_i];\n\n if (Object.prototype.hasOwnProperty.call(node, '__proto__')) {\n // Avoid calling node.hasOwnProperty directly\n if (options.protoAction !== 'remove') {\n throw new SyntaxError('Object contains forbidden prototype property');\n }\n\n delete node.__proto__;\n }\n\n for (var key in node) {\n var value = node[key];\n\n if (value && _typeof(value) === 'object') {\n next.push(node[key]);\n }\n }\n }\n }\n};\n\nexports.safeParse = function (text, reviver) {\n try {\n return exports.parse(text, reviver);\n } catch (ignoreError) {\n return null;\n }\n};" + "source": "'use strict';\n\nconst internals = {\n suspectRx: /\"(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])(?:p|\\\\u0070)(?:r|\\\\u0072)(?:o|\\\\u006[Ff])(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:_|\\\\u005[Ff])(?:_|\\\\u005[Ff])\"\\s*\\:/\n};\n\nexports.parse = function (text, reviver, options) {\n // Normalize arguments\n if (!options) {\n if (reviver && typeof reviver === 'object') {\n options = reviver;\n reviver = undefined;\n } else {\n options = {};\n }\n } // Parse normally, allowing exceptions\n\n\n const obj = JSON.parse(text, reviver); // options.protoAction: 'error' (default) / 'remove' / 'ignore'\n\n if (options.protoAction === 'ignore') {\n return obj;\n } // Ignore null and non-objects\n\n\n if (!obj || typeof obj !== 'object') {\n return obj;\n } // Check original string for potential exploit\n\n\n if (!text.match(internals.suspectRx)) {\n return obj;\n } // Scan result for proto keys\n\n\n exports.scan(obj, options);\n return obj;\n};\n\nexports.scan = function (obj, options) {\n options = options || {};\n let next = [obj];\n\n while (next.length) {\n const nodes = next;\n next = [];\n\n for (const node of nodes) {\n if (Object.prototype.hasOwnProperty.call(node, '__proto__')) {\n // Avoid calling node.hasOwnProperty directly\n if (options.protoAction !== 'remove') {\n throw new SyntaxError('Object contains forbidden prototype property');\n }\n\n delete node.__proto__;\n }\n\n for (const key in node) {\n const value = node[key];\n\n if (value && typeof value === 'object') {\n next.push(node[key]);\n }\n }\n }\n }\n};\n\nexports.safeParse = function (text, reviver) {\n try {\n return exports.parse(text, reviver);\n } catch (ignoreError) {\n return null;\n }\n};" }, { "id": 23, @@ -7021,7 +6928,7 @@ "name": "../lib/types/object.js", "index": 35, "index2": 35, - "size": 55029, + "size": 32847, "cacheable": true, "built": true, "optional": false, @@ -7038,15 +6945,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -7060,16 +6967,16 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/object", - "loc": "46:12-37" + "loc": "32:12-37" }, { - "moduleId": 38, + "moduleId": 37, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/function.js", "module": "../lib/types/function.js", "moduleName": "../lib/types/function.js", "type": "cjs require", "userRequest": "./object", - "loc": "5:17-36" + "loc": "5:19-38" } ], "usedExports": true, @@ -7078,108 +6985,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar ApplyToDefaults = require('@hapi/hoek/lib/applyToDefaults');\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Bourne = require('@hapi/bourne');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Topo = require('@hapi/topo');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar Compile = require('../compile');\n\nvar Errors = require('../errors');\n\nvar Ref = require('../ref');\n\nvar Template = require('../template');\n\nvar internals = {\n renameDefaults: {\n alias: false,\n // Keep old value in place\n multiple: false,\n // Allow renaming multiple keys into the same target\n override: false // Overrides an existing key\n\n }\n};\nmodule.exports = Any.extend({\n type: 'object',\n properties: {\n typeof: 'object'\n },\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.dependencies = null;\n schema.$_terms.keys = null;\n schema.$_terms.patterns = null;\n schema.$_terms.renames = null;\n },\n args: function args(schema, keys) {\n return schema.keys(keys);\n },\n // Coerce\n coerce: {\n from: 'string',\n method: function method(schema, value, helpers) {\n if (value[0] !== '{' && !/^\\s*\\{/.test(value)) {\n return;\n }\n\n try {\n return {\n value: Bourne.parse(value)\n };\n } catch (ignoreErr) {}\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n var error = _ref.error,\n state = _ref.state,\n prefs = _ref.prefs;\n\n if (!value || _typeof(value) !== schema.$_property('typeof') || Array.isArray(value)) {\n return {\n value: value,\n errors: error('object.base', {\n type: schema.$_property('typeof')\n })\n };\n } // Skip if there are no other rules to test\n\n\n if (!schema.$_terms.renames && !schema.$_terms.dependencies && !schema.$_terms.keys && // null allows any keys\n !schema.$_terms.patterns && !schema.$_terms.externals) {\n return;\n } // Shallow clone value\n\n\n value = internals.clone(value, prefs);\n var errors = []; // Rename keys\n\n if (schema.$_terms.renames && !internals.rename(schema, value, state, prefs, errors)) {\n return {\n value: value,\n errors: errors\n };\n } // Anything allowed\n\n\n if (!schema.$_terms.keys && // null allows any keys\n !schema.$_terms.patterns && !schema.$_terms.dependencies) {\n return {\n value: value,\n errors: errors\n };\n } // Defined keys\n\n\n var unprocessed = new Set(Object.keys(value));\n\n if (schema.$_terms.keys) {\n var ancestors = [value].concat(_toConsumableArray(state.ancestors));\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = schema.$_terms.keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var child = _step.value;\n var key = child.key;\n var item = value[key];\n unprocessed.delete(key);\n var localState = state.localize([].concat(_toConsumableArray(state.path), [key]), ancestors, child.schema);\n var result = child.schema.$_validate(item, localState, prefs);\n\n if (result.errors) {\n if (prefs.abortEarly) {\n return {\n value: value,\n errors: result.errors\n };\n }\n\n errors.push.apply(errors, _toConsumableArray(result.errors));\n } else if (child.schema._flags.result === 'strip' || result.value === undefined && item !== undefined) {\n delete value[key];\n } else if (result.value !== undefined) {\n value[key] = result.value;\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n } // Unknown keys\n\n\n if (unprocessed.size) {\n var early = internals.unknown(schema, value, unprocessed, errors, state, prefs);\n\n if (early) {\n return early;\n }\n } // Validate dependencies\n\n\n if (schema.$_terms.dependencies) {\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = schema.$_terms.dependencies[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var dep = _step2.value;\n\n if (dep.key && dep.key.resolve(value, state, prefs, null, {\n shadow: false\n }) === undefined) {\n continue;\n }\n\n var failed = internals.dependencies[dep.type](schema, dep, value, state, prefs);\n\n if (failed) {\n var report = schema.$_createError(failed.code, value, failed.context, state, prefs);\n\n if (prefs.abortEarly) {\n return {\n value: value,\n errors: report\n };\n }\n\n errors.push(report);\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n\n return {\n value: value,\n errors: errors\n };\n },\n // Rules\n rules: {\n and: {\n method: function method()\n /*, [options] */\n {\n for (var _len = arguments.length, peers = new Array(_len), _key = 0; _key < _len; _key++) {\n peers[_key] = arguments[_key];\n }\n\n Common.verifyFlat(peers, 'and');\n return internals.dependency(this, 'and', null, peers);\n }\n },\n append: {\n method: function method(schema) {\n if (schema === null || schema === undefined || Object.keys(schema).length === 0) {\n return this;\n }\n\n return this.keys(schema);\n }\n },\n assert: {\n method: function method(ref, schema, message) {\n ref = Compile.ref(ref);\n Assert(ref.type === 'global' || ref.depth > 1, 'Cannot use assertions for root level references - use direct key rules instead');\n message = message || 'pass the assertion test';\n Assert(typeof message === 'string', 'Message must be a string');\n schema = this.$_compile(schema, {\n appendPath: true\n });\n var path = ref.path.join('.');\n var obj = this.$_addRule({\n name: 'assert',\n args: {\n ref: ref,\n schema: schema,\n message: message\n },\n path: path\n });\n obj.$_mutateRegister(schema);\n return obj;\n },\n validate: function validate(value, _ref2, _ref3, _ref4) {\n var error = _ref2.error,\n prefs = _ref2.prefs,\n state = _ref2.state;\n var ref = _ref3.ref,\n schema = _ref3.schema,\n message = _ref3.message;\n var path = _ref4.path;\n var entryState = state.entry(schema, value);\n\n if (schema.$_match(ref.resolve(null, {\n ancestors: [value].concat(_toConsumableArray(state.ancestors))\n }), entryState, prefs)) {\n return value;\n }\n\n return error('object.assert', {\n ref: path,\n message: message\n });\n },\n args: ['ref', 'schema', 'message'],\n multi: true\n },\n instance: {\n method: function method(constructor, name) {\n Assert(typeof constructor === 'function', 'constructor must be a function');\n name = name || constructor.name;\n return this.$_addRule({\n name: 'instance',\n args: {\n constructor: constructor,\n name: name\n }\n });\n },\n validate: function validate(value, helpers, _ref5) {\n var constructor = _ref5.constructor,\n name = _ref5.name;\n\n if (value instanceof constructor) {\n return value;\n }\n\n return helpers.error('object.instance', {\n type: name,\n value: value\n });\n },\n args: ['constructor', 'name']\n },\n keys: {\n method: function method(schema) {\n var _this = this;\n\n Assert(schema === undefined || _typeof(schema) === 'object', 'Object schema must be a valid object');\n Assert(!Common.isSchema(schema), 'Object schema cannot be a joi schema');\n var obj = this.clone();\n\n if (!schema) {\n // Allow all\n obj.$_terms.keys = null;\n } else if (!Object.keys(schema).length) {\n // Allow none\n obj.$_terms.keys = [];\n } else {\n obj.$_terms.keys = obj.$_terms.keys ? obj.$_terms.keys.filter(function (child) {\n return !schema.hasOwnProperty(child.key);\n }) : [];\n\n var _loop = function _loop(key) {\n Common.tryWithPath(function () {\n return obj.$_terms.keys.push({\n key: key,\n schema: _this.$_compile(schema[key])\n });\n }, key);\n };\n\n for (var key in schema) {\n _loop(key);\n }\n }\n\n return obj.$_mutateRebuild();\n }\n },\n length: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'length',\n args: {\n limit: limit\n },\n operator: '='\n });\n },\n validate: function validate(value, helpers, _ref6, _ref7) {\n var limit = _ref6.limit;\n var name = _ref7.name,\n operator = _ref7.operator,\n args = _ref7.args;\n\n if (Common.compare(Object.keys(value).length, limit, operator)) {\n return value;\n }\n\n return helpers.error('object.' + name, {\n limit: args.limit,\n value: value\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.limit,\n message: 'must be a positive integer'\n }]\n },\n max: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'max',\n method: 'length',\n args: {\n limit: limit\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'min',\n method: 'length',\n args: {\n limit: limit\n },\n operator: '>='\n });\n }\n },\n nand: {\n method: function method()\n /*, [options] */\n {\n for (var _len2 = arguments.length, peers = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n peers[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(peers, 'nand');\n return internals.dependency(this, 'nand', null, peers);\n }\n },\n or: {\n method: function method()\n /*, [options] */\n {\n for (var _len3 = arguments.length, peers = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n peers[_key3] = arguments[_key3];\n }\n\n Common.verifyFlat(peers, 'or');\n return internals.dependency(this, 'or', null, peers);\n }\n },\n oxor: {\n method: function method()\n /*, [options] */\n {\n for (var _len4 = arguments.length, peers = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n peers[_key4] = arguments[_key4];\n }\n\n return internals.dependency(this, 'oxor', null, peers);\n }\n },\n pattern: {\n method: function method(pattern, schema) {\n var _config;\n\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var isRegExp = pattern instanceof RegExp;\n Assert(isRegExp || Common.isSchema(pattern), 'pattern must be a regex or schema');\n Assert(schema !== undefined, 'Invalid rule');\n Common.assertOptions(options, ['exclusive', 'matches']);\n\n if (isRegExp) {\n Assert(!pattern.flags.includes('g') && !pattern.flags.includes('y'), 'pattern should not use global or sticky mode');\n }\n\n schema = this.$_compile(schema, {\n appendPath: true\n });\n var obj = this.clone();\n obj.$_terms.patterns = obj.$_terms.patterns || [];\n var config = (_config = {}, _defineProperty(_config, isRegExp ? 'regex' : 'schema', pattern), _defineProperty(_config, \"rule\", schema), _config);\n\n if (options.matches) {\n config.matches = this.$_compile(options.matches);\n obj.$_mutateRegister(config.matches);\n }\n\n if (options.exclusive) {\n config.exclusive = true;\n }\n\n obj.$_terms.patterns.push(config);\n obj.$_mutateRegister(schema);\n return obj;\n }\n },\n ref: {\n method: function method() {\n return this.$_addRule('ref');\n },\n validate: function validate(value, helpers) {\n if (Ref.isRef(value)) {\n return value;\n }\n\n return helpers.error('object.refType', {\n value: value\n });\n }\n },\n rename: {\n method: function method(from, to) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(typeof from === 'string' || from instanceof RegExp, 'Rename missing the from argument');\n Assert(typeof to === 'string' || to instanceof Template, 'Invalid rename to argument');\n Assert(to !== from, 'Cannot rename key to same name:', from);\n Common.assertOptions(options, ['alias', 'ignoreUndefined', 'override', 'multiple']);\n var obj = this.clone();\n obj.$_terms.renames = obj.$_terms.renames || [];\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = obj.$_terms.renames[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var rename = _step3.value;\n Assert(rename.from !== from, 'Cannot rename the same key multiple times');\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n if (to instanceof Template) {\n obj.$_mutateRegister(to);\n }\n\n obj.$_terms.renames.push({\n from: from,\n to: to,\n options: ApplyToDefaults(internals.renameDefaults, options)\n });\n return obj;\n }\n },\n schema: {\n method: function method() {\n var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'any';\n return this.$_addRule({\n name: 'schema',\n args: {\n type: type\n }\n });\n },\n validate: function validate(value, helpers, _ref8) {\n var type = _ref8.type;\n\n if (Common.isSchema(value) && (type === 'any' || value.type === type)) {\n return value;\n }\n\n return helpers.error('object.schema', {\n type: type\n });\n }\n },\n unknown: {\n method: function method(allow) {\n return this.$_setFlag('unknown', allow !== false);\n }\n },\n with: {\n method: function method(key, peers) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return internals.dependency(this, 'with', key, peers, options);\n }\n },\n without: {\n method: function method(key, peers) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return internals.dependency(this, 'without', key, peers, options);\n }\n },\n xor: {\n method: function method()\n /*, [options] */\n {\n for (var _len5 = arguments.length, peers = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {\n peers[_key5] = arguments[_key5];\n }\n\n Common.verifyFlat(peers, 'xor');\n return internals.dependency(this, 'xor', null, peers);\n }\n }\n },\n // Overrides\n overrides: {\n default: function _default(value, options) {\n if (value === undefined) {\n value = Common.symbols.deepDefault;\n }\n\n return this.super.default(value, options);\n },\n tailor: function tailor(targets) {\n var obj = this.super.tailor(targets);\n\n if (obj === this) {\n obj = this.clone();\n }\n\n if (obj.$_terms.keys) {\n for (var i = 0; i < obj.$_terms.keys.length; ++i) {\n var child = obj.$_terms.keys[i];\n obj.$_terms.keys[i] = Object.assign({}, child, {\n schema: child.schema.tailor(targets)\n });\n }\n }\n\n if (obj.$_terms.patterns) {\n for (var _i = 0; _i < obj.$_terms.patterns.length; ++_i) {\n var pattern = obj.$_terms.patterns[_i];\n\n for (var _i2 = 0, _arr = ['schema', 'rule', 'matches']; _i2 < _arr.length; _i2++) {\n var key = _arr[_i2];\n\n if (pattern[key]) {\n obj.$_terms.patterns[_i] = Object.assign({}, pattern, _defineProperty({}, key, pattern[key].tailor(targets)));\n }\n }\n }\n }\n\n obj = obj.$_replaceRules('assert', function (rule) {\n var clone = Clone(rule);\n clone.options.args.schema = clone.options.args.schema.tailor(targets);\n return clone;\n });\n return obj.$_mutateRebuild();\n }\n },\n // Cast\n cast: {\n map: {\n from: function from(value) {\n return value && _typeof(value) === 'object';\n },\n to: function to(value, helpers) {\n return new Map(Object.entries(value));\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n if (desc.keys) {\n obj = obj.keys(desc.keys);\n }\n\n if (desc.dependencies) {\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = desc.dependencies[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var _step4$value = _step4.value,\n type = _step4$value.type,\n _step4$value$key = _step4$value.key,\n key = _step4$value$key === void 0 ? null : _step4$value$key,\n peers = _step4$value.peers,\n options = _step4$value.options;\n obj = internals.dependency(obj, type, key, peers, options);\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n }\n\n if (desc.patterns) {\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = desc.patterns[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var _step5$value = _step5.value,\n regex = _step5$value.regex,\n schema = _step5$value.schema,\n rule = _step5$value.rule,\n exclusive = _step5$value.exclusive,\n matches = _step5$value.matches;\n obj = obj.pattern(regex || schema, rule, {\n exclusive: exclusive,\n matches: matches\n });\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n }\n\n if (desc.renames) {\n var _iteratorNormalCompletion6 = true;\n var _didIteratorError6 = false;\n var _iteratorError6 = undefined;\n\n try {\n for (var _iterator6 = desc.renames[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {\n var _step6$value = _step6.value,\n from = _step6$value.from,\n to = _step6$value.to,\n options = _step6$value.options;\n obj = obj.rename(from, to, options);\n }\n } catch (err) {\n _didIteratorError6 = true;\n _iteratorError6 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion6 && _iterator6.return != null) {\n _iterator6.return();\n }\n } finally {\n if (_didIteratorError6) {\n throw _iteratorError6;\n }\n }\n }\n }\n\n return obj;\n },\n // Modify\n modify: function modify(schema, id, replacement) {\n if (schema.$_terms.keys) {\n var _iteratorNormalCompletion7 = true;\n var _didIteratorError7 = false;\n var _iteratorError7 = undefined;\n\n try {\n for (var _iterator7 = schema.$_terms.keys[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {\n var child = _step7.value;\n var childId = child.schema._flags.id || child.key;\n\n if (id === childId) {\n return schema.keys(_defineProperty({}, child.key, replacement));\n }\n }\n } catch (err) {\n _didIteratorError7 = true;\n _iteratorError7 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion7 && _iterator7.return != null) {\n _iterator7.return();\n }\n } finally {\n if (_didIteratorError7) {\n throw _iteratorError7;\n }\n }\n }\n }\n\n if (schema.$_terms.patterns) {\n for (var i = 0; i < schema.$_terms.patterns.length; ++i) {\n var pattern = schema.$_terms.patterns[i];\n\n for (var _i3 = 0, _arr2 = ['schema', 'rule', 'matches']; _i3 < _arr2.length; _i3++) {\n var key = _arr2[_i3];\n\n if (pattern[key] && id === pattern[key]._flags.id) {\n var obj = schema.clone();\n obj.$_terms.patterns[i] = Object.assign({}, pattern, _defineProperty({}, key, replacement));\n return obj.$_mutateRebuild();\n }\n }\n }\n }\n\n var modified = schema.$_replaceRules('assert', function (rule) {\n if (id === rule.options.args.schema._flags.id) {\n var clone = Clone(rule);\n clone.options.args.schema = replacement;\n clone.args = clone.options.args;\n return clone;\n }\n });\n\n if (modified !== schema) {\n return modified;\n }\n },\n rebuild: function rebuild(schema) {\n if (schema.$_terms.keys) {\n (function () {\n var topo = new Topo();\n var _iteratorNormalCompletion8 = true;\n var _didIteratorError8 = false;\n var _iteratorError8 = undefined;\n\n try {\n var _loop2 = function _loop2() {\n var child = _step8.value;\n Common.tryWithPath(function () {\n return topo.add(child, {\n after: child.schema.$_rootReferences(),\n group: child.key\n });\n }, child.key);\n schema.$_mutateRegister(child.schema, {\n key: child.key\n });\n };\n\n for (var _iterator8 = schema.$_terms.keys[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {\n _loop2();\n }\n } catch (err) {\n _didIteratorError8 = true;\n _iteratorError8 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion8 && _iterator8.return != null) {\n _iterator8.return();\n }\n } finally {\n if (_didIteratorError8) {\n throw _iteratorError8;\n }\n }\n }\n\n schema.$_terms.keys = _construct(internals.Keys, _toConsumableArray(topo.nodes));\n })();\n }\n\n if (schema.$_terms.patterns) {\n var _iteratorNormalCompletion9 = true;\n var _didIteratorError9 = false;\n var _iteratorError9 = undefined;\n\n try {\n for (var _iterator9 = schema.$_terms.patterns[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {\n var pattern = _step9.value;\n\n for (var _i4 = 0, _arr3 = ['schema', 'rule', 'matches']; _i4 < _arr3.length; _i4++) {\n var key = _arr3[_i4];\n schema.$_mutateRegister(pattern[key]);\n }\n }\n } catch (err) {\n _didIteratorError9 = true;\n _iteratorError9 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion9 && _iterator9.return != null) {\n _iterator9.return();\n }\n } finally {\n if (_didIteratorError9) {\n throw _iteratorError9;\n }\n }\n }\n }\n\n var assertions = schema.$_getRules('assert');\n var _iteratorNormalCompletion10 = true;\n var _didIteratorError10 = false;\n var _iteratorError10 = undefined;\n\n try {\n for (var _iterator10 = assertions[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {\n var assertion = _step10.value;\n schema.$_mutateRegister(assertion.args.schema);\n }\n } catch (err) {\n _didIteratorError10 = true;\n _iteratorError10 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion10 && _iterator10.return != null) {\n _iterator10.return();\n }\n } finally {\n if (_didIteratorError10) {\n throw _iteratorError10;\n }\n }\n }\n\n return schema;\n },\n // Errors\n messages: {\n 'object.and': '\"{{#label}}\" contains {{#presentWithLabels}} without its required peers {{#missingWithLabels}}',\n 'object.assert': '\"{{#label}}\" is invalid because \"{{#ref}}\" failed to {{#message}}',\n 'object.base': '\"{{#label}}\" must be of type {{#type}}',\n 'object.instance': '\"{{#label}}\" must be an instance of \"{{#type}}\"',\n 'object.length': '\"{{#label}}\" must have {{#limit}} keys',\n 'object.max': '\"{{#label}}\" must have less than or equal to {{#limit}} keys',\n 'object.min': '\"{{#label}}\" must have at least {{#limit}} keys',\n 'object.missing': '\"{{#label}}\" must contain at least one of {{#peersWithLabels}}',\n 'object.nand': '\"{{#mainWithLabel}}\" must not exist simultaneously with {{#peersWithLabels}}',\n 'object.oxor': '\"{{#label}}\" contains a conflict between optional exclusive peers {{#peersWithLabels}}',\n 'object.pattern.match': '\"{{#label}}\" keys failed to match pattern requirements',\n 'object.refType': '\"{{#label}}\" must be a Joi reference',\n 'object.rename.multiple': '\"{{#label}}\" cannot rename \"{{#from}}\" because multiple renames are disabled and another key was already renamed to \"{{#to}}\"',\n 'object.rename.override': '\"{{#label}}\" cannot rename \"{{#from}}\" because override is disabled and target \"{{#to}}\" exists',\n 'object.schema': '\"{{#label}}\" must be a Joi schema of {{#type}} type',\n 'object.unknown': '\"{{#label}}\" is not allowed',\n 'object.with': '\"{{#mainWithLabel}}\" missing required peer \"{{#peerWithLabel}}\"',\n 'object.without': '\"{{#mainWithLabel}}\" conflict with forbidden peer \"{{#peerWithLabel}}\"',\n 'object.xor': '\"{{#label}}\" contains a conflict between exclusive peers {{#peersWithLabels}}'\n }\n}); // Helpers\n\ninternals.clone = function (value, prefs) {\n // Object\n if (_typeof(value) === 'object') {\n if (prefs.nonEnumerables) {\n return Clone(value, {\n shallow: true\n });\n }\n\n var _clone = Object.create(Object.getPrototypeOf(value));\n\n Object.assign(_clone, value);\n return _clone;\n } // Function\n\n\n var clone = function clone() {\n for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {\n args[_key6] = arguments[_key6];\n }\n\n return value.apply(this, args);\n };\n\n clone.prototype = Clone(value.prototype);\n Object.defineProperty(clone, 'name', {\n value: value.name,\n writable: false\n });\n Object.defineProperty(clone, 'length', {\n value: value.length,\n writable: false\n });\n Object.assign(clone, value);\n return clone;\n};\n\ninternals.dependency = function (schema, type, key, peers, options) {\n Assert(key === null || typeof key === 'string', type, 'key must be a strings'); // Extract options from peers array\n\n if (!options) {\n options = peers.length > 1 && _typeof(peers[peers.length - 1]) === 'object' ? peers.pop() : {};\n }\n\n Common.assertOptions(options, ['separator']);\n peers = [].concat(peers); // Cast peer paths\n\n var separator = Common.default(options.separator, '.');\n var paths = [];\n var _iteratorNormalCompletion11 = true;\n var _didIteratorError11 = false;\n var _iteratorError11 = undefined;\n\n try {\n for (var _iterator11 = peers[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {\n var peer = _step11.value;\n Assert(typeof peer === 'string', type, 'peers must be a string or a reference');\n paths.push(Compile.ref(peer, {\n separator: separator,\n ancestor: 0\n }));\n } // Cast key\n\n } catch (err) {\n _didIteratorError11 = true;\n _iteratorError11 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion11 && _iterator11.return != null) {\n _iterator11.return();\n }\n } finally {\n if (_didIteratorError11) {\n throw _iteratorError11;\n }\n }\n }\n\n if (key !== null) {\n key = Compile.ref(key, {\n separator: separator,\n ancestor: 0\n });\n } // Add rule\n\n\n var obj = schema.clone();\n obj.$_terms.dependencies = obj.$_terms.dependencies || [];\n obj.$_terms.dependencies.push(new internals.Dependency(type, key, paths, peers));\n return obj;\n};\n\ninternals.dependencies = {\n and: function and(schema, dep, value, state, prefs) {\n var missing = [];\n var present = [];\n var count = dep.peers.length;\n var _iteratorNormalCompletion12 = true;\n var _didIteratorError12 = false;\n var _iteratorError12 = undefined;\n\n try {\n for (var _iterator12 = dep.peers[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {\n var peer = _step12.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) === undefined) {\n missing.push(peer.key);\n } else {\n present.push(peer.key);\n }\n }\n } catch (err) {\n _didIteratorError12 = true;\n _iteratorError12 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion12 && _iterator12.return != null) {\n _iterator12.return();\n }\n } finally {\n if (_didIteratorError12) {\n throw _iteratorError12;\n }\n }\n }\n\n if (missing.length !== count && present.length !== count) {\n return {\n code: 'object.and',\n context: {\n present: present,\n presentWithLabels: internals.keysToLabels(schema, present),\n missing: missing,\n missingWithLabels: internals.keysToLabels(schema, missing)\n }\n };\n }\n },\n nand: function nand(schema, dep, value, state, prefs) {\n var present = [];\n var _iteratorNormalCompletion13 = true;\n var _didIteratorError13 = false;\n var _iteratorError13 = undefined;\n\n try {\n for (var _iterator13 = dep.peers[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {\n var peer = _step13.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n present.push(peer.key);\n }\n }\n } catch (err) {\n _didIteratorError13 = true;\n _iteratorError13 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion13 && _iterator13.return != null) {\n _iterator13.return();\n }\n } finally {\n if (_didIteratorError13) {\n throw _iteratorError13;\n }\n }\n }\n\n if (present.length !== dep.peers.length) {\n return;\n }\n\n var main = dep.paths[0];\n var values = dep.paths.slice(1);\n return {\n code: 'object.nand',\n context: {\n main: main,\n mainWithLabel: internals.keysToLabels(schema, main),\n peers: values,\n peersWithLabels: internals.keysToLabels(schema, values)\n }\n };\n },\n or: function or(schema, dep, value, state, prefs) {\n var _iteratorNormalCompletion14 = true;\n var _didIteratorError14 = false;\n var _iteratorError14 = undefined;\n\n try {\n for (var _iterator14 = dep.peers[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {\n var peer = _step14.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n return;\n }\n }\n } catch (err) {\n _didIteratorError14 = true;\n _iteratorError14 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion14 && _iterator14.return != null) {\n _iterator14.return();\n }\n } finally {\n if (_didIteratorError14) {\n throw _iteratorError14;\n }\n }\n }\n\n return {\n code: 'object.missing',\n context: {\n peers: dep.paths,\n peersWithLabels: internals.keysToLabels(schema, dep.paths)\n }\n };\n },\n oxor: function oxor(schema, dep, value, state, prefs) {\n var present = [];\n var _iteratorNormalCompletion15 = true;\n var _didIteratorError15 = false;\n var _iteratorError15 = undefined;\n\n try {\n for (var _iterator15 = dep.peers[Symbol.iterator](), _step15; !(_iteratorNormalCompletion15 = (_step15 = _iterator15.next()).done); _iteratorNormalCompletion15 = true) {\n var peer = _step15.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n present.push(peer.key);\n }\n }\n } catch (err) {\n _didIteratorError15 = true;\n _iteratorError15 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion15 && _iterator15.return != null) {\n _iterator15.return();\n }\n } finally {\n if (_didIteratorError15) {\n throw _iteratorError15;\n }\n }\n }\n\n if (!present.length || present.length === 1) {\n return;\n }\n\n var context = {\n peers: dep.paths,\n peersWithLabels: internals.keysToLabels(schema, dep.paths)\n };\n context.present = present;\n context.presentWithLabels = internals.keysToLabels(schema, present);\n return {\n code: 'object.oxor',\n context: context\n };\n },\n with: function _with(schema, dep, value, state, prefs) {\n var _iteratorNormalCompletion16 = true;\n var _didIteratorError16 = false;\n var _iteratorError16 = undefined;\n\n try {\n for (var _iterator16 = dep.peers[Symbol.iterator](), _step16; !(_iteratorNormalCompletion16 = (_step16 = _iterator16.next()).done); _iteratorNormalCompletion16 = true) {\n var peer = _step16.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) === undefined) {\n return {\n code: 'object.with',\n context: {\n main: dep.key.key,\n mainWithLabel: internals.keysToLabels(schema, dep.key.key),\n peer: peer.key,\n peerWithLabel: internals.keysToLabels(schema, peer.key)\n }\n };\n }\n }\n } catch (err) {\n _didIteratorError16 = true;\n _iteratorError16 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion16 && _iterator16.return != null) {\n _iterator16.return();\n }\n } finally {\n if (_didIteratorError16) {\n throw _iteratorError16;\n }\n }\n }\n },\n without: function without(schema, dep, value, state, prefs) {\n var _iteratorNormalCompletion17 = true;\n var _didIteratorError17 = false;\n var _iteratorError17 = undefined;\n\n try {\n for (var _iterator17 = dep.peers[Symbol.iterator](), _step17; !(_iteratorNormalCompletion17 = (_step17 = _iterator17.next()).done); _iteratorNormalCompletion17 = true) {\n var peer = _step17.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n return {\n code: 'object.without',\n context: {\n main: dep.key.key,\n mainWithLabel: internals.keysToLabels(schema, dep.key.key),\n peer: peer.key,\n peerWithLabel: internals.keysToLabels(schema, peer.key)\n }\n };\n }\n }\n } catch (err) {\n _didIteratorError17 = true;\n _iteratorError17 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion17 && _iterator17.return != null) {\n _iterator17.return();\n }\n } finally {\n if (_didIteratorError17) {\n throw _iteratorError17;\n }\n }\n }\n },\n xor: function xor(schema, dep, value, state, prefs) {\n var present = [];\n var _iteratorNormalCompletion18 = true;\n var _didIteratorError18 = false;\n var _iteratorError18 = undefined;\n\n try {\n for (var _iterator18 = dep.peers[Symbol.iterator](), _step18; !(_iteratorNormalCompletion18 = (_step18 = _iterator18.next()).done); _iteratorNormalCompletion18 = true) {\n var peer = _step18.value;\n\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n present.push(peer.key);\n }\n }\n } catch (err) {\n _didIteratorError18 = true;\n _iteratorError18 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion18 && _iterator18.return != null) {\n _iterator18.return();\n }\n } finally {\n if (_didIteratorError18) {\n throw _iteratorError18;\n }\n }\n }\n\n if (present.length === 1) {\n return;\n }\n\n var context = {\n peers: dep.paths,\n peersWithLabels: internals.keysToLabels(schema, dep.paths)\n };\n\n if (present.length === 0) {\n return {\n code: 'object.missing',\n context: context\n };\n }\n\n context.present = present;\n context.presentWithLabels = internals.keysToLabels(schema, present);\n return {\n code: 'object.xor',\n context: context\n };\n }\n};\n\ninternals.keysToLabels = function (schema, keys) {\n if (Array.isArray(keys)) {\n return keys.map(function (key) {\n return schema.$_mapLabels(key);\n });\n }\n\n return schema.$_mapLabels(keys);\n};\n\ninternals.rename = function (schema, value, state, prefs, errors) {\n var renamed = {};\n var _iteratorNormalCompletion19 = true;\n var _didIteratorError19 = false;\n var _iteratorError19 = undefined;\n\n try {\n for (var _iterator19 = schema.$_terms.renames[Symbol.iterator](), _step19; !(_iteratorNormalCompletion19 = (_step19 = _iterator19.next()).done); _iteratorNormalCompletion19 = true) {\n var rename = _step19.value;\n var matches = [];\n var pattern = typeof rename.from !== 'string';\n\n if (!pattern) {\n if (Object.prototype.hasOwnProperty.call(value, rename.from) && (value[rename.from] !== undefined || !rename.options.ignoreUndefined)) {\n matches.push(rename);\n }\n } else {\n for (var from in value) {\n if (value[from] === undefined && rename.options.ignoreUndefined) {\n continue;\n }\n\n if (from === rename.to) {\n continue;\n }\n\n var match = rename.from.exec(from);\n\n if (!match) {\n continue;\n }\n\n matches.push({\n from: from,\n to: rename.to,\n match: match\n });\n }\n }\n\n for (var _i5 = 0, _matches = matches; _i5 < _matches.length; _i5++) {\n var _match = _matches[_i5];\n var _from = _match.from;\n var to = _match.to;\n\n if (to instanceof Template) {\n to = to.render(value, state, prefs, _match.match);\n }\n\n if (_from === to) {\n continue;\n }\n\n if (!rename.options.multiple && renamed[to]) {\n errors.push(schema.$_createError('object.rename.multiple', value, {\n from: _from,\n to: to,\n pattern: pattern\n }, state, prefs));\n\n if (prefs.abortEarly) {\n return false;\n }\n }\n\n if (Object.prototype.hasOwnProperty.call(value, to) && !rename.options.override && !renamed[to]) {\n errors.push(schema.$_createError('object.rename.override', value, {\n from: _from,\n to: to,\n pattern: pattern\n }, state, prefs));\n\n if (prefs.abortEarly) {\n return false;\n }\n }\n\n if (value[_from] === undefined) {\n delete value[to];\n } else {\n value[to] = value[_from];\n }\n\n renamed[to] = true;\n\n if (!rename.options.alias) {\n delete value[_from];\n }\n }\n }\n } catch (err) {\n _didIteratorError19 = true;\n _iteratorError19 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion19 && _iterator19.return != null) {\n _iterator19.return();\n }\n } finally {\n if (_didIteratorError19) {\n throw _iteratorError19;\n }\n }\n }\n\n return true;\n};\n\ninternals.unknown = function (schema, value, unprocessed, errors, state, prefs) {\n if (schema.$_terms.patterns) {\n var hasMatches = false;\n var matches = schema.$_terms.patterns.map(function (pattern) {\n if (pattern.matches) {\n hasMatches = true;\n return [];\n }\n });\n var ancestors = [value];\n var _iteratorNormalCompletion20 = true;\n var _didIteratorError20 = false;\n var _iteratorError20 = undefined;\n\n try {\n for (var _iterator20 = unprocessed[Symbol.iterator](), _step20; !(_iteratorNormalCompletion20 = (_step20 = _iterator20.next()).done); _iteratorNormalCompletion20 = true) {\n var key = _step20.value;\n var item = value[key];\n var path = [].concat(_toConsumableArray(state.path), [key]);\n\n for (var _i6 = 0; _i6 < schema.$_terms.patterns.length; ++_i6) {\n var pattern = schema.$_terms.patterns[_i6];\n\n var _match2 = pattern.regex ? pattern.regex.test(key) : pattern.schema.$_match(key, state.nest(pattern.schema), prefs);\n\n if (!_match2) {\n continue;\n }\n\n unprocessed.delete(key);\n\n var _localState = state.localize(path, ancestors, pattern.rule);\n\n var _result = pattern.rule.$_validate(item, _localState, prefs);\n\n if (_result.errors) {\n if (prefs.abortEarly) {\n return {\n value: value,\n errors: _result.errors\n };\n }\n\n errors.push.apply(errors, _toConsumableArray(_result.errors));\n }\n\n if (pattern.matches) {\n matches[_i6].push(key);\n }\n\n value[key] = _result.value;\n\n if (pattern.exclusive) {\n break;\n }\n }\n } // Validate pattern matches rules\n\n } catch (err) {\n _didIteratorError20 = true;\n _iteratorError20 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion20 && _iterator20.return != null) {\n _iterator20.return();\n }\n } finally {\n if (_didIteratorError20) {\n throw _iteratorError20;\n }\n }\n }\n\n if (hasMatches) {\n for (var i = 0; i < matches.length; ++i) {\n var match = matches[i];\n\n if (!match) {\n continue;\n }\n\n var localState = state.localize(state.path, ancestors, schema.$_terms.patterns[i].matches);\n var result = schema.$_terms.patterns[i].matches.$_validate(match, localState, prefs);\n\n if (result.errors) {\n var details = Errors.details(result.errors, {\n override: false\n });\n details.matches = match;\n var report = schema.$_createError('object.pattern.match', value, details, state, prefs);\n\n if (prefs.abortEarly) {\n return {\n value: value,\n errors: report\n };\n }\n\n errors.push(report);\n }\n }\n }\n }\n\n if (!unprocessed.size || !schema.$_terms.keys && !schema.$_terms.patterns) {\n // If no keys or patterns specified, unknown keys allowed\n return;\n }\n\n if (prefs.stripUnknown && !schema._flags.unknown || prefs.skipFunctions) {\n var stripUnknown = prefs.stripUnknown ? prefs.stripUnknown === true ? true : !!prefs.stripUnknown.objects : false;\n var _iteratorNormalCompletion21 = true;\n var _didIteratorError21 = false;\n var _iteratorError21 = undefined;\n\n try {\n for (var _iterator21 = unprocessed[Symbol.iterator](), _step21; !(_iteratorNormalCompletion21 = (_step21 = _iterator21.next()).done); _iteratorNormalCompletion21 = true) {\n var _key7 = _step21.value;\n\n if (stripUnknown) {\n delete value[_key7];\n unprocessed.delete(_key7);\n } else if (typeof value[_key7] === 'function') {\n unprocessed.delete(_key7);\n }\n }\n } catch (err) {\n _didIteratorError21 = true;\n _iteratorError21 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion21 && _iterator21.return != null) {\n _iterator21.return();\n }\n } finally {\n if (_didIteratorError21) {\n throw _iteratorError21;\n }\n }\n }\n }\n\n var forbidUnknown = !Common.default(schema._flags.unknown, prefs.allowUnknown);\n\n if (forbidUnknown) {\n var _iteratorNormalCompletion22 = true;\n var _didIteratorError22 = false;\n var _iteratorError22 = undefined;\n\n try {\n for (var _iterator22 = unprocessed[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {\n var unprocessedKey = _step22.value;\n\n var _localState2 = state.localize([].concat(_toConsumableArray(state.path), [unprocessedKey]), []);\n\n var _report = schema.$_createError('object.unknown', value[unprocessedKey], {\n child: unprocessedKey\n }, _localState2, prefs, {\n flags: false\n });\n\n if (prefs.abortEarly) {\n return {\n value: value,\n errors: _report\n };\n }\n\n errors.push(_report);\n }\n } catch (err) {\n _didIteratorError22 = true;\n _iteratorError22 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion22 && _iterator22.return != null) {\n _iterator22.return();\n }\n } finally {\n if (_didIteratorError22) {\n throw _iteratorError22;\n }\n }\n }\n }\n};\n\ninternals.Dependency =\n/*#__PURE__*/\nfunction () {\n function _class(type, key, peers, paths) {\n _classCallCheck(this, _class);\n\n this.type = type;\n this.key = key;\n this.peers = peers;\n this.paths = paths;\n }\n\n _createClass(_class, [{\n key: \"describe\",\n value: function describe() {\n var desc = {\n type: this.type,\n peers: this.paths\n };\n\n if (this.key !== null) {\n desc.key = this.key.key;\n }\n\n if (this.peers[0].separator !== '.') {\n desc.options = {\n separator: this.peers[0].separator\n };\n }\n\n return desc;\n }\n }]);\n\n return _class;\n}();\n\ninternals.Keys =\n/*#__PURE__*/\nfunction (_Array) {\n _inherits(_class2, _Array);\n\n function _class2() {\n _classCallCheck(this, _class2);\n\n return _possibleConstructorReturn(this, _getPrototypeOf(_class2).apply(this, arguments));\n }\n\n _createClass(_class2, [{\n key: \"concat\",\n value: function concat(source) {\n var result = this.slice();\n var keys = new Map();\n\n for (var i = 0; i < result.length; ++i) {\n keys.set(result[i].key, i);\n }\n\n var _iteratorNormalCompletion23 = true;\n var _didIteratorError23 = false;\n var _iteratorError23 = undefined;\n\n try {\n for (var _iterator23 = source[Symbol.iterator](), _step23; !(_iteratorNormalCompletion23 = (_step23 = _iterator23.next()).done); _iteratorNormalCompletion23 = true) {\n var item = _step23.value;\n var key = item.key;\n var pos = keys.get(key);\n\n if (pos >= 0) {\n result[pos] = {\n key: key,\n schema: result[pos].schema.concat(item.schema)\n };\n } else {\n result.push(item);\n }\n }\n } catch (err) {\n _didIteratorError23 = true;\n _iteratorError23 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion23 && _iterator23.return != null) {\n _iterator23.return();\n }\n } finally {\n if (_didIteratorError23) {\n throw _iteratorError23;\n }\n }\n }\n\n return result;\n }\n }]);\n\n return _class2;\n}(_wrapNativeSuper(Array));" + "source": "'use strict';\n\nconst ApplyToDefaults = require('@hapi/hoek/lib/applyToDefaults');\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Bourne = require('@hapi/bourne');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Topo = require('@hapi/topo');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst Compile = require('../compile');\n\nconst Errors = require('../errors');\n\nconst Ref = require('../ref');\n\nconst Template = require('../template');\n\nconst internals = {\n renameDefaults: {\n alias: false,\n // Keep old value in place\n multiple: false,\n // Allow renaming multiple keys into the same target\n override: false // Overrides an existing key\n\n }\n};\nmodule.exports = Any.extend({\n type: 'object',\n properties: {\n typeof: 'object'\n },\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.dependencies = null;\n schema.$_terms.keys = null;\n schema.$_terms.patterns = null;\n schema.$_terms.renames = null;\n },\n args: function args(schema, keys) {\n return schema.keys(keys);\n },\n // Coerce\n coerce: {\n from: 'string',\n method: function method(schema, value, helpers) {\n if (value[0] !== '{' && !/^\\s*\\{/.test(value)) {\n return;\n }\n\n try {\n return {\n value: Bourne.parse(value)\n };\n } catch (ignoreErr) {}\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n let {\n error,\n state,\n prefs\n } = _ref;\n\n if (!value || typeof value !== schema.$_property('typeof') || Array.isArray(value)) {\n return {\n value,\n errors: error('object.base', {\n type: schema.$_property('typeof')\n })\n };\n } // Skip if there are no other rules to test\n\n\n if (!schema.$_terms.renames && !schema.$_terms.dependencies && !schema.$_terms.keys && // null allows any keys\n !schema.$_terms.patterns && !schema.$_terms.externals) {\n return;\n } // Shallow clone value\n\n\n value = internals.clone(value, prefs);\n const errors = []; // Rename keys\n\n if (schema.$_terms.renames && !internals.rename(schema, value, state, prefs, errors)) {\n return {\n value,\n errors\n };\n } // Anything allowed\n\n\n if (!schema.$_terms.keys && // null allows any keys\n !schema.$_terms.patterns && !schema.$_terms.dependencies) {\n return {\n value,\n errors\n };\n } // Defined keys\n\n\n const unprocessed = new Set(Object.keys(value));\n\n if (schema.$_terms.keys) {\n const ancestors = [value, ...state.ancestors];\n\n for (const child of schema.$_terms.keys) {\n const key = child.key;\n const item = value[key];\n unprocessed.delete(key);\n const localState = state.localize([...state.path, key], ancestors, child.schema);\n const result = child.schema.$_validate(item, localState, prefs);\n\n if (result.errors) {\n if (prefs.abortEarly) {\n return {\n value,\n errors: result.errors\n };\n }\n\n errors.push(...result.errors);\n } else if (child.schema._flags.result === 'strip' || result.value === undefined && item !== undefined) {\n delete value[key];\n } else if (result.value !== undefined) {\n value[key] = result.value;\n }\n }\n } // Unknown keys\n\n\n if (unprocessed.size) {\n const early = internals.unknown(schema, value, unprocessed, errors, state, prefs);\n\n if (early) {\n return early;\n }\n } // Validate dependencies\n\n\n if (schema.$_terms.dependencies) {\n for (const dep of schema.$_terms.dependencies) {\n if (dep.key && dep.key.resolve(value, state, prefs, null, {\n shadow: false\n }) === undefined) {\n continue;\n }\n\n const failed = internals.dependencies[dep.type](schema, dep, value, state, prefs);\n\n if (failed) {\n const report = schema.$_createError(failed.code, value, failed.context, state, prefs);\n\n if (prefs.abortEarly) {\n return {\n value,\n errors: report\n };\n }\n\n errors.push(report);\n }\n }\n }\n\n return {\n value,\n errors\n };\n },\n // Rules\n rules: {\n and: {\n method: function method()\n /*, [options] */\n {\n for (var _len = arguments.length, peers = new Array(_len), _key = 0; _key < _len; _key++) {\n peers[_key] = arguments[_key];\n }\n\n Common.verifyFlat(peers, 'and');\n return internals.dependency(this, 'and', null, peers);\n }\n },\n append: {\n method: function method(schema) {\n if (schema === null || schema === undefined || Object.keys(schema).length === 0) {\n return this;\n }\n\n return this.keys(schema);\n }\n },\n assert: {\n method: function method(ref, schema, message) {\n ref = Compile.ref(ref);\n Assert(ref.type === 'global' || ref.depth > 1, 'Cannot use assertions for root level references - use direct key rules instead');\n message = message || 'pass the assertion test';\n Assert(typeof message === 'string', 'Message must be a string');\n schema = this.$_compile(schema, {\n appendPath: true\n });\n const path = ref.path.join('.');\n const obj = this.$_addRule({\n name: 'assert',\n args: {\n ref,\n schema,\n message\n },\n path\n });\n obj.$_mutateRegister(schema);\n return obj;\n },\n validate: function validate(value, _ref2, _ref3, _ref4) {\n let {\n error,\n prefs,\n state\n } = _ref2;\n let {\n ref,\n schema,\n message\n } = _ref3;\n let {\n path\n } = _ref4;\n const entryState = state.entry(schema, value);\n\n if (schema.$_match(ref.resolve(null, {\n ancestors: [value, ...state.ancestors]\n }), entryState, prefs)) {\n return value;\n }\n\n return error('object.assert', {\n ref: path,\n message\n });\n },\n args: ['ref', 'schema', 'message'],\n multi: true\n },\n instance: {\n method: function method(constructor, name) {\n Assert(typeof constructor === 'function', 'constructor must be a function');\n name = name || constructor.name;\n return this.$_addRule({\n name: 'instance',\n args: {\n constructor,\n name\n }\n });\n },\n validate: function validate(value, helpers, _ref5) {\n let {\n constructor,\n name\n } = _ref5;\n\n if (value instanceof constructor) {\n return value;\n }\n\n return helpers.error('object.instance', {\n type: name,\n value\n });\n },\n args: ['constructor', 'name']\n },\n keys: {\n method: function method(schema) {\n Assert(schema === undefined || typeof schema === 'object', 'Object schema must be a valid object');\n Assert(!Common.isSchema(schema), 'Object schema cannot be a joi schema');\n const obj = this.clone();\n\n if (!schema) {\n // Allow all\n obj.$_terms.keys = null;\n } else if (!Object.keys(schema).length) {\n // Allow none\n obj.$_terms.keys = [];\n } else {\n obj.$_terms.keys = obj.$_terms.keys ? obj.$_terms.keys.filter(child => !schema.hasOwnProperty(child.key)) : [];\n\n for (const key in schema) {\n Common.tryWithPath(() => obj.$_terms.keys.push({\n key,\n schema: this.$_compile(schema[key])\n }), key);\n }\n }\n\n return obj.$_mutateRebuild();\n }\n },\n length: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'length',\n args: {\n limit\n },\n operator: '='\n });\n },\n validate: function validate(value, helpers, _ref6, _ref7) {\n let {\n limit\n } = _ref6;\n let {\n name,\n operator,\n args\n } = _ref7;\n\n if (Common.compare(Object.keys(value).length, limit, operator)) {\n return value;\n }\n\n return helpers.error('object.' + name, {\n limit: args.limit,\n value\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.limit,\n message: 'must be a positive integer'\n }]\n },\n max: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'max',\n method: 'length',\n args: {\n limit\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'min',\n method: 'length',\n args: {\n limit\n },\n operator: '>='\n });\n }\n },\n nand: {\n method: function method()\n /*, [options] */\n {\n for (var _len2 = arguments.length, peers = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n peers[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(peers, 'nand');\n return internals.dependency(this, 'nand', null, peers);\n }\n },\n or: {\n method: function method()\n /*, [options] */\n {\n for (var _len3 = arguments.length, peers = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n peers[_key3] = arguments[_key3];\n }\n\n Common.verifyFlat(peers, 'or');\n return internals.dependency(this, 'or', null, peers);\n }\n },\n oxor: {\n method: function method()\n /*, [options] */\n {\n for (var _len4 = arguments.length, peers = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n peers[_key4] = arguments[_key4];\n }\n\n return internals.dependency(this, 'oxor', null, peers);\n }\n },\n pattern: {\n method: function method(pattern, schema) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n const isRegExp = pattern instanceof RegExp;\n Assert(isRegExp || Common.isSchema(pattern), 'pattern must be a regex or schema');\n Assert(schema !== undefined, 'Invalid rule');\n Common.assertOptions(options, ['exclusive', 'matches']);\n\n if (isRegExp) {\n Assert(!pattern.flags.includes('g') && !pattern.flags.includes('y'), 'pattern should not use global or sticky mode');\n }\n\n schema = this.$_compile(schema, {\n appendPath: true\n });\n const obj = this.clone();\n obj.$_terms.patterns = obj.$_terms.patterns || [];\n const config = {\n [isRegExp ? 'regex' : 'schema']: pattern,\n rule: schema\n };\n\n if (options.matches) {\n config.matches = this.$_compile(options.matches);\n obj.$_mutateRegister(config.matches);\n }\n\n if (options.exclusive) {\n config.exclusive = true;\n }\n\n obj.$_terms.patterns.push(config);\n obj.$_mutateRegister(schema);\n return obj;\n }\n },\n ref: {\n method: function method() {\n return this.$_addRule('ref');\n },\n validate: function validate(value, helpers) {\n if (Ref.isRef(value)) {\n return value;\n }\n\n return helpers.error('object.refType', {\n value\n });\n }\n },\n rename: {\n method: function method(from, to) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(typeof from === 'string' || from instanceof RegExp, 'Rename missing the from argument');\n Assert(typeof to === 'string' || to instanceof Template, 'Invalid rename to argument');\n Assert(to !== from, 'Cannot rename key to same name:', from);\n Common.assertOptions(options, ['alias', 'ignoreUndefined', 'override', 'multiple']);\n const obj = this.clone();\n obj.$_terms.renames = obj.$_terms.renames || [];\n\n for (const rename of obj.$_terms.renames) {\n Assert(rename.from !== from, 'Cannot rename the same key multiple times');\n }\n\n if (to instanceof Template) {\n obj.$_mutateRegister(to);\n }\n\n obj.$_terms.renames.push({\n from,\n to,\n options: ApplyToDefaults(internals.renameDefaults, options)\n });\n return obj;\n }\n },\n schema: {\n method: function method() {\n let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'any';\n return this.$_addRule({\n name: 'schema',\n args: {\n type\n }\n });\n },\n validate: function validate(value, helpers, _ref8) {\n let {\n type\n } = _ref8;\n\n if (Common.isSchema(value) && (type === 'any' || value.type === type)) {\n return value;\n }\n\n return helpers.error('object.schema', {\n type\n });\n }\n },\n unknown: {\n method: function method(allow) {\n return this.$_setFlag('unknown', allow !== false);\n }\n },\n with: {\n method: function method(key, peers) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return internals.dependency(this, 'with', key, peers, options);\n }\n },\n without: {\n method: function method(key, peers) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n return internals.dependency(this, 'without', key, peers, options);\n }\n },\n xor: {\n method: function method()\n /*, [options] */\n {\n for (var _len5 = arguments.length, peers = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {\n peers[_key5] = arguments[_key5];\n }\n\n Common.verifyFlat(peers, 'xor');\n return internals.dependency(this, 'xor', null, peers);\n }\n }\n },\n // Overrides\n overrides: {\n default: function _default(value, options) {\n if (value === undefined) {\n value = Common.symbols.deepDefault;\n }\n\n return this.super.default(value, options);\n },\n tailor: function tailor(targets) {\n let obj = this.super.tailor(targets);\n\n if (obj === this) {\n obj = this.clone();\n }\n\n if (obj.$_terms.keys) {\n for (let i = 0; i < obj.$_terms.keys.length; ++i) {\n const child = obj.$_terms.keys[i];\n obj.$_terms.keys[i] = Object.assign({}, child, {\n schema: child.schema.tailor(targets)\n });\n }\n }\n\n if (obj.$_terms.patterns) {\n for (let i = 0; i < obj.$_terms.patterns.length; ++i) {\n const pattern = obj.$_terms.patterns[i];\n\n for (const key of ['schema', 'rule', 'matches']) {\n if (pattern[key]) {\n obj.$_terms.patterns[i] = Object.assign({}, pattern, {\n [key]: pattern[key].tailor(targets)\n });\n }\n }\n }\n }\n\n obj = obj.$_replaceRules('assert', rule => {\n const clone = Clone(rule);\n clone.options.args.schema = clone.options.args.schema.tailor(targets);\n return clone;\n });\n return obj.$_mutateRebuild();\n }\n },\n // Cast\n cast: {\n map: {\n from: value => value && typeof value === 'object',\n to: function to(value, helpers) {\n return new Map(Object.entries(value));\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n if (desc.keys) {\n obj = obj.keys(desc.keys);\n }\n\n if (desc.dependencies) {\n for (const _ref9 of desc.dependencies) {\n const {\n type,\n key = null,\n peers,\n options\n } = _ref9;\n obj = internals.dependency(obj, type, key, peers, options);\n }\n }\n\n if (desc.patterns) {\n for (const _ref10 of desc.patterns) {\n const {\n regex,\n schema,\n rule,\n exclusive,\n matches\n } = _ref10;\n obj = obj.pattern(regex || schema, rule, {\n exclusive,\n matches\n });\n }\n }\n\n if (desc.renames) {\n for (const _ref11 of desc.renames) {\n const {\n from,\n to,\n options\n } = _ref11;\n obj = obj.rename(from, to, options);\n }\n }\n\n return obj;\n },\n // Modify\n modify: function modify(schema, id, replacement) {\n if (schema.$_terms.keys) {\n for (const child of schema.$_terms.keys) {\n const childId = child.schema._flags.id || child.key;\n\n if (id === childId) {\n return schema.keys({\n [child.key]: replacement\n });\n }\n }\n }\n\n if (schema.$_terms.patterns) {\n for (let i = 0; i < schema.$_terms.patterns.length; ++i) {\n const pattern = schema.$_terms.patterns[i];\n\n for (const key of ['schema', 'rule', 'matches']) {\n if (pattern[key] && id === pattern[key]._flags.id) {\n const obj = schema.clone();\n obj.$_terms.patterns[i] = Object.assign({}, pattern, {\n [key]: replacement\n });\n return obj.$_mutateRebuild();\n }\n }\n }\n }\n\n const modified = schema.$_replaceRules('assert', rule => {\n if (id === rule.options.args.schema._flags.id) {\n const clone = Clone(rule);\n clone.options.args.schema = replacement;\n clone.args = clone.options.args;\n return clone;\n }\n });\n\n if (modified !== schema) {\n return modified;\n }\n },\n rebuild: function rebuild(schema) {\n if (schema.$_terms.keys) {\n const topo = new Topo();\n\n for (const child of schema.$_terms.keys) {\n Common.tryWithPath(() => topo.add(child, {\n after: child.schema.$_rootReferences(),\n group: child.key\n }), child.key);\n schema.$_mutateRegister(child.schema, {\n key: child.key\n });\n }\n\n schema.$_terms.keys = new internals.Keys(...topo.nodes);\n }\n\n if (schema.$_terms.patterns) {\n for (const pattern of schema.$_terms.patterns) {\n for (const key of ['schema', 'rule', 'matches']) {\n schema.$_mutateRegister(pattern[key]);\n }\n }\n }\n\n const assertions = schema.$_getRules('assert');\n\n for (const assertion of assertions) {\n schema.$_mutateRegister(assertion.args.schema);\n }\n\n return schema;\n },\n // Errors\n messages: {\n 'object.and': '\"{{#label}}\" contains {{#presentWithLabels}} without its required peers {{#missingWithLabels}}',\n 'object.assert': '\"{{#label}}\" is invalid because \"{{#ref}}\" failed to {{#message}}',\n 'object.base': '\"{{#label}}\" must be of type {{#type}}',\n 'object.instance': '\"{{#label}}\" must be an instance of \"{{#type}}\"',\n 'object.length': '\"{{#label}}\" must have {{#limit}} keys',\n 'object.max': '\"{{#label}}\" must have less than or equal to {{#limit}} keys',\n 'object.min': '\"{{#label}}\" must have at least {{#limit}} keys',\n 'object.missing': '\"{{#label}}\" must contain at least one of {{#peersWithLabels}}',\n 'object.nand': '\"{{#mainWithLabel}}\" must not exist simultaneously with {{#peersWithLabels}}',\n 'object.oxor': '\"{{#label}}\" contains a conflict between optional exclusive peers {{#peersWithLabels}}',\n 'object.pattern.match': '\"{{#label}}\" keys failed to match pattern requirements',\n 'object.refType': '\"{{#label}}\" must be a Joi reference',\n 'object.rename.multiple': '\"{{#label}}\" cannot rename \"{{#from}}\" because multiple renames are disabled and another key was already renamed to \"{{#to}}\"',\n 'object.rename.override': '\"{{#label}}\" cannot rename \"{{#from}}\" because override is disabled and target \"{{#to}}\" exists',\n 'object.schema': '\"{{#label}}\" must be a Joi schema of {{#type}} type',\n 'object.unknown': '\"{{#label}}\" is not allowed',\n 'object.with': '\"{{#mainWithLabel}}\" missing required peer \"{{#peerWithLabel}}\"',\n 'object.without': '\"{{#mainWithLabel}}\" conflict with forbidden peer \"{{#peerWithLabel}}\"',\n 'object.xor': '\"{{#label}}\" contains a conflict between exclusive peers {{#peersWithLabels}}'\n }\n}); // Helpers\n\ninternals.clone = function (value, prefs) {\n // Object\n if (typeof value === 'object') {\n if (prefs.nonEnumerables) {\n return Clone(value, {\n shallow: true\n });\n }\n\n const clone = Object.create(Object.getPrototypeOf(value));\n Object.assign(clone, value);\n return clone;\n } // Function\n\n\n const clone = function clone() {\n for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {\n args[_key6] = arguments[_key6];\n }\n\n return value.apply(this, args);\n };\n\n clone.prototype = Clone(value.prototype);\n Object.defineProperty(clone, 'name', {\n value: value.name,\n writable: false\n });\n Object.defineProperty(clone, 'length', {\n value: value.length,\n writable: false\n });\n Object.assign(clone, value);\n return clone;\n};\n\ninternals.dependency = function (schema, type, key, peers, options) {\n Assert(key === null || typeof key === 'string', type, 'key must be a strings'); // Extract options from peers array\n\n if (!options) {\n options = peers.length > 1 && typeof peers[peers.length - 1] === 'object' ? peers.pop() : {};\n }\n\n Common.assertOptions(options, ['separator']);\n peers = [].concat(peers); // Cast peer paths\n\n const separator = Common.default(options.separator, '.');\n const paths = [];\n\n for (const peer of peers) {\n Assert(typeof peer === 'string', type, 'peers must be a string or a reference');\n paths.push(Compile.ref(peer, {\n separator,\n ancestor: 0\n }));\n } // Cast key\n\n\n if (key !== null) {\n key = Compile.ref(key, {\n separator,\n ancestor: 0\n });\n } // Add rule\n\n\n const obj = schema.clone();\n obj.$_terms.dependencies = obj.$_terms.dependencies || [];\n obj.$_terms.dependencies.push(new internals.Dependency(type, key, paths, peers));\n return obj;\n};\n\ninternals.dependencies = {\n and: function and(schema, dep, value, state, prefs) {\n const missing = [];\n const present = [];\n const count = dep.peers.length;\n\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) === undefined) {\n missing.push(peer.key);\n } else {\n present.push(peer.key);\n }\n }\n\n if (missing.length !== count && present.length !== count) {\n return {\n code: 'object.and',\n context: {\n present,\n presentWithLabels: internals.keysToLabels(schema, present),\n missing,\n missingWithLabels: internals.keysToLabels(schema, missing)\n }\n };\n }\n },\n nand: function nand(schema, dep, value, state, prefs) {\n const present = [];\n\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n present.push(peer.key);\n }\n }\n\n if (present.length !== dep.peers.length) {\n return;\n }\n\n const main = dep.paths[0];\n const values = dep.paths.slice(1);\n return {\n code: 'object.nand',\n context: {\n main,\n mainWithLabel: internals.keysToLabels(schema, main),\n peers: values,\n peersWithLabels: internals.keysToLabels(schema, values)\n }\n };\n },\n or: function or(schema, dep, value, state, prefs) {\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n return;\n }\n }\n\n return {\n code: 'object.missing',\n context: {\n peers: dep.paths,\n peersWithLabels: internals.keysToLabels(schema, dep.paths)\n }\n };\n },\n oxor: function oxor(schema, dep, value, state, prefs) {\n const present = [];\n\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n present.push(peer.key);\n }\n }\n\n if (!present.length || present.length === 1) {\n return;\n }\n\n const context = {\n peers: dep.paths,\n peersWithLabels: internals.keysToLabels(schema, dep.paths)\n };\n context.present = present;\n context.presentWithLabels = internals.keysToLabels(schema, present);\n return {\n code: 'object.oxor',\n context\n };\n },\n with: function _with(schema, dep, value, state, prefs) {\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) === undefined) {\n return {\n code: 'object.with',\n context: {\n main: dep.key.key,\n mainWithLabel: internals.keysToLabels(schema, dep.key.key),\n peer: peer.key,\n peerWithLabel: internals.keysToLabels(schema, peer.key)\n }\n };\n }\n }\n },\n without: function without(schema, dep, value, state, prefs) {\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n return {\n code: 'object.without',\n context: {\n main: dep.key.key,\n mainWithLabel: internals.keysToLabels(schema, dep.key.key),\n peer: peer.key,\n peerWithLabel: internals.keysToLabels(schema, peer.key)\n }\n };\n }\n }\n },\n xor: function xor(schema, dep, value, state, prefs) {\n const present = [];\n\n for (const peer of dep.peers) {\n if (peer.resolve(value, state, prefs, null, {\n shadow: false\n }) !== undefined) {\n present.push(peer.key);\n }\n }\n\n if (present.length === 1) {\n return;\n }\n\n const context = {\n peers: dep.paths,\n peersWithLabels: internals.keysToLabels(schema, dep.paths)\n };\n\n if (present.length === 0) {\n return {\n code: 'object.missing',\n context\n };\n }\n\n context.present = present;\n context.presentWithLabels = internals.keysToLabels(schema, present);\n return {\n code: 'object.xor',\n context\n };\n }\n};\n\ninternals.keysToLabels = function (schema, keys) {\n if (Array.isArray(keys)) {\n return keys.map(key => schema.$_mapLabels(key));\n }\n\n return schema.$_mapLabels(keys);\n};\n\ninternals.rename = function (schema, value, state, prefs, errors) {\n const renamed = {};\n\n for (const rename of schema.$_terms.renames) {\n const matches = [];\n const pattern = typeof rename.from !== 'string';\n\n if (!pattern) {\n if (Object.prototype.hasOwnProperty.call(value, rename.from) && (value[rename.from] !== undefined || !rename.options.ignoreUndefined)) {\n matches.push(rename);\n }\n } else {\n for (const from in value) {\n if (value[from] === undefined && rename.options.ignoreUndefined) {\n continue;\n }\n\n if (from === rename.to) {\n continue;\n }\n\n const match = rename.from.exec(from);\n\n if (!match) {\n continue;\n }\n\n matches.push({\n from,\n to: rename.to,\n match\n });\n }\n }\n\n for (const match of matches) {\n const from = match.from;\n let to = match.to;\n\n if (to instanceof Template) {\n to = to.render(value, state, prefs, match.match);\n }\n\n if (from === to) {\n continue;\n }\n\n if (!rename.options.multiple && renamed[to]) {\n errors.push(schema.$_createError('object.rename.multiple', value, {\n from,\n to,\n pattern\n }, state, prefs));\n\n if (prefs.abortEarly) {\n return false;\n }\n }\n\n if (Object.prototype.hasOwnProperty.call(value, to) && !rename.options.override && !renamed[to]) {\n errors.push(schema.$_createError('object.rename.override', value, {\n from,\n to,\n pattern\n }, state, prefs));\n\n if (prefs.abortEarly) {\n return false;\n }\n }\n\n if (value[from] === undefined) {\n delete value[to];\n } else {\n value[to] = value[from];\n }\n\n renamed[to] = true;\n\n if (!rename.options.alias) {\n delete value[from];\n }\n }\n }\n\n return true;\n};\n\ninternals.unknown = function (schema, value, unprocessed, errors, state, prefs) {\n if (schema.$_terms.patterns) {\n let hasMatches = false;\n const matches = schema.$_terms.patterns.map(pattern => {\n if (pattern.matches) {\n hasMatches = true;\n return [];\n }\n });\n const ancestors = [value];\n\n for (const key of unprocessed) {\n const item = value[key];\n const path = [...state.path, key];\n\n for (let i = 0; i < schema.$_terms.patterns.length; ++i) {\n const pattern = schema.$_terms.patterns[i];\n const match = pattern.regex ? pattern.regex.test(key) : pattern.schema.$_match(key, state.nest(pattern.schema), prefs);\n\n if (!match) {\n continue;\n }\n\n unprocessed.delete(key);\n const localState = state.localize(path, ancestors, pattern.rule);\n const result = pattern.rule.$_validate(item, localState, prefs);\n\n if (result.errors) {\n if (prefs.abortEarly) {\n return {\n value,\n errors: result.errors\n };\n }\n\n errors.push(...result.errors);\n }\n\n if (pattern.matches) {\n matches[i].push(key);\n }\n\n value[key] = result.value;\n\n if (pattern.exclusive) {\n break;\n }\n }\n } // Validate pattern matches rules\n\n\n if (hasMatches) {\n for (let i = 0; i < matches.length; ++i) {\n const match = matches[i];\n\n if (!match) {\n continue;\n }\n\n const localState = state.localize(state.path, ancestors, schema.$_terms.patterns[i].matches);\n const result = schema.$_terms.patterns[i].matches.$_validate(match, localState, prefs);\n\n if (result.errors) {\n const details = Errors.details(result.errors, {\n override: false\n });\n details.matches = match;\n const report = schema.$_createError('object.pattern.match', value, details, state, prefs);\n\n if (prefs.abortEarly) {\n return {\n value,\n errors: report\n };\n }\n\n errors.push(report);\n }\n }\n }\n }\n\n if (!unprocessed.size || !schema.$_terms.keys && !schema.$_terms.patterns) {\n // If no keys or patterns specified, unknown keys allowed\n return;\n }\n\n if (prefs.stripUnknown && !schema._flags.unknown || prefs.skipFunctions) {\n const stripUnknown = prefs.stripUnknown ? prefs.stripUnknown === true ? true : !!prefs.stripUnknown.objects : false;\n\n for (const key of unprocessed) {\n if (stripUnknown) {\n delete value[key];\n unprocessed.delete(key);\n } else if (typeof value[key] === 'function') {\n unprocessed.delete(key);\n }\n }\n }\n\n const forbidUnknown = !Common.default(schema._flags.unknown, prefs.allowUnknown);\n\n if (forbidUnknown) {\n for (const unprocessedKey of unprocessed) {\n const localState = state.localize([...state.path, unprocessedKey], []);\n const report = schema.$_createError('object.unknown', value[unprocessedKey], {\n child: unprocessedKey\n }, localState, prefs, {\n flags: false\n });\n\n if (prefs.abortEarly) {\n return {\n value,\n errors: report\n };\n }\n\n errors.push(report);\n }\n }\n};\n\ninternals.Dependency = class {\n constructor(type, key, peers, paths) {\n this.type = type;\n this.key = key;\n this.peers = peers;\n this.paths = paths;\n }\n\n describe() {\n const desc = {\n type: this.type,\n peers: this.paths\n };\n\n if (this.key !== null) {\n desc.key = this.key.key;\n }\n\n if (this.peers[0].separator !== '.') {\n desc.options = {\n separator: this.peers[0].separator\n };\n }\n\n return desc;\n }\n\n};\ninternals.Keys = class extends Array {\n concat(source) {\n const result = this.slice();\n const keys = new Map();\n\n for (let i = 0; i < result.length; ++i) {\n keys.set(result[i].key, i);\n }\n\n for (const item of source) {\n const key = item.key;\n const pos = keys.get(key);\n\n if (pos >= 0) {\n result[pos] = {\n key,\n schema: result[pos].schema.concat(item.schema)\n };\n } else {\n result.push(item);\n }\n }\n\n return result;\n }\n\n};" }, { "id": 24, - "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/webpack/buildin/amd-options.js", - "name": "(webpack)/buildin/amd-options.js", - "index": 45, - "index2": 41, - "size": 80, - "cacheable": true, - "built": true, - "optional": false, - "prefetched": false, - "chunks": [ - 0 - ], - "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "issuerId": 45, - "issuerName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "issuerPath": [ - { - "id": 14, - "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", - "name": "../lib/index.js", - "profile": { - "factory": 32, - "building": 526 - } - }, - { - "id": 43, - "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", - "name": "../lib/types/string/index.js", - "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 - } - }, - { - "id": 44, - "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", - "name": "../node_modules/@hapi/address/lib/index.js", - "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 - } - }, - { - "id": 45, - "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "name": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "profile": { - "factory": 4, - "building": 95 - } - } - ], - "profile": { - "factory": 56, - "building": 8 - }, - "failed": false, - "errors": 0, - "warnings": 0, - "assets": [], - "reasons": [ - { - "moduleId": 45, - "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "module": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "moduleName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "type": "amd require", - "userRequest": "define.amd", - "loc": "540:45-55" - }, - { - "moduleId": 45, - "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "module": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "moduleName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "type": "amd require", - "userRequest": "define.amd", - "loc": "540:72-82" - } - ], - "usedExports": true, - "providedExports": null, - "optimizationBailout": [ - "ModuleConcatenation bailout: Module is not an ECMAScript module" - ], - "depth": 4, - "source": "/* globals __webpack_amd_options__ */\nmodule.exports = __webpack_amd_options__;\n" - }, - { - "id": 25, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/uri.js", "name": "../lib/types/string/uri.js", - "index": 51, - "index2": 48, - "size": 8404, + "index": 50, + "index2": 47, + "size": 8495, "cacheable": true, "built": true, "optional": false, @@ -7188,7 +7002,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", - "issuerId": 43, + "issuerId": 42, "issuerName": "../lib/types/string/index.js", "issuerPath": [ { @@ -7196,25 +7010,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 }, "failed": false, "errors": 0, @@ -7222,22 +7036,22 @@ "assets": [], "reasons": [ { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "./uri", - "loc": "25:10-26" + "loc": "23:12-28" }, { - "moduleId": 51, + "moduleId": 50, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/ip.js", "module": "../lib/types/string/ip.js", "moduleName": "../lib/types/string/ip.js", "type": "cjs require", "userRequest": "./uri", - "loc": "3:10-26" + "loc": "3:12-28" } ], "usedExports": true, @@ -7246,15 +7060,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar EscapeRegex = require('@hapi/hoek/lib/escapeRegex');\n\nvar internals = {};\n\ninternals.generate = function () {\n var rfc3986 = {};\n var hexDigit = '\\\\dA-Fa-f'; // HEXDIG = DIGIT / \"A\" / \"B\" / \"C\" / \"D\" / \"E\" / \"F\"\n\n var hexDigitOnly = '[' + hexDigit + ']';\n var unreserved = '\\\\w-\\\\.~'; // unreserved = ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\"\n\n var subDelims = '!\\\\$&\\'\\\\(\\\\)\\\\*\\\\+,;='; // sub-delims = \"!\" / \"$\" / \"&\" / \"'\" / \"(\" / \")\" / \"*\" / \"+\" / \",\" / \";\" / \"=\"\n\n var pctEncoded = '%' + hexDigit; // pct-encoded = \"%\" HEXDIG HEXDIG\n\n var pchar = unreserved + pctEncoded + subDelims + ':@'; // pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"\n\n var pcharOnly = '[' + pchar + ']';\n var decOctect = '(?:0{0,2}\\\\d|0?[1-9]\\\\d|1\\\\d\\\\d|2[0-4]\\\\d|25[0-5])'; // dec-octet = DIGIT / %x31-39 DIGIT / \"1\" 2DIGIT / \"2\" %x30-34 DIGIT / \"25\" %x30-35 ; 0-9 / 10-99 / 100-199 / 200-249 / 250-255\n\n rfc3986.ipv4address = '(?:' + decOctect + '\\\\.){3}' + decOctect; // IPv4address = dec-octet \".\" dec-octet \".\" dec-octet \".\" dec-octet\n\n /*\r\n h16 = 1*4HEXDIG ; 16 bits of address represented in hexadecimal\r\n ls32 = ( h16 \":\" h16 ) / IPv4address ; least-significant 32 bits of address\r\n IPv6address = 6( h16 \":\" ) ls32\r\n / \"::\" 5( h16 \":\" ) ls32\r\n / [ h16 ] \"::\" 4( h16 \":\" ) ls32\r\n / [ *1( h16 \":\" ) h16 ] \"::\" 3( h16 \":\" ) ls32\r\n / [ *2( h16 \":\" ) h16 ] \"::\" 2( h16 \":\" ) ls32\r\n / [ *3( h16 \":\" ) h16 ] \"::\" h16 \":\" ls32\r\n / [ *4( h16 \":\" ) h16 ] \"::\" ls32\r\n / [ *5( h16 \":\" ) h16 ] \"::\" h16\r\n / [ *6( h16 \":\" ) h16 ] \"::\"\r\n */\n\n var h16 = hexDigitOnly + '{1,4}';\n var ls32 = '(?:' + h16 + ':' + h16 + '|' + rfc3986.ipv4address + ')';\n var IPv6SixHex = '(?:' + h16 + ':){6}' + ls32;\n var IPv6FiveHex = '::(?:' + h16 + ':){5}' + ls32;\n var IPv6FourHex = '(?:' + h16 + ')?::(?:' + h16 + ':){4}' + ls32;\n var IPv6ThreeHex = '(?:(?:' + h16 + ':){0,1}' + h16 + ')?::(?:' + h16 + ':){3}' + ls32;\n var IPv6TwoHex = '(?:(?:' + h16 + ':){0,2}' + h16 + ')?::(?:' + h16 + ':){2}' + ls32;\n var IPv6OneHex = '(?:(?:' + h16 + ':){0,3}' + h16 + ')?::' + h16 + ':' + ls32;\n var IPv6NoneHex = '(?:(?:' + h16 + ':){0,4}' + h16 + ')?::' + ls32;\n var IPv6NoneHex2 = '(?:(?:' + h16 + ':){0,5}' + h16 + ')?::' + h16;\n var IPv6NoneHex3 = '(?:(?:' + h16 + ':){0,6}' + h16 + ')?::';\n rfc3986.ipv4Cidr = '\\\\d|[1-2]\\\\d|3[0-2]'; // IPv4 cidr = DIGIT / %x31-32 DIGIT / \"3\" %x30-32 ; 0-9 / 10-29 / 30-32\n\n rfc3986.ipv6Cidr = '(?:0{0,2}\\\\d|0?[1-9]\\\\d|1[01]\\\\d|12[0-8])'; // IPv6 cidr = DIGIT / %x31-39 DIGIT / \"1\" %x0-1 DIGIT / \"12\" %x0-8; 0-9 / 10-99 / 100-119 / 120-128\n\n rfc3986.ipv6address = '(?:' + IPv6SixHex + '|' + IPv6FiveHex + '|' + IPv6FourHex + '|' + IPv6ThreeHex + '|' + IPv6TwoHex + '|' + IPv6OneHex + '|' + IPv6NoneHex + '|' + IPv6NoneHex2 + '|' + IPv6NoneHex3 + ')';\n rfc3986.ipvFuture = 'v' + hexDigitOnly + '+\\\\.[' + unreserved + subDelims + ':]+'; // IPvFuture = \"v\" 1*HEXDIG \".\" 1*( unreserved / sub-delims / \":\" )\n\n rfc3986.scheme = '[a-zA-Z][a-zA-Z\\\\d+-\\\\.]*'; // scheme = ALPHA *( ALPHA / DIGIT / \"+\" / \"-\" / \".\" )\n\n rfc3986.schemeRegex = new RegExp(rfc3986.scheme);\n var userinfo = '[' + unreserved + pctEncoded + subDelims + ':]*'; // userinfo = *( unreserved / pct-encoded / sub-delims / \":\" )\n\n var IPLiteral = '\\\\[(?:' + rfc3986.ipv6address + '|' + rfc3986.ipvFuture + ')\\\\]'; // IP-literal = \"[\" ( IPv6address / IPvFuture ) \"]\"\n\n var regName = '[' + unreserved + pctEncoded + subDelims + ']{1,255}'; // reg-name = *( unreserved / pct-encoded / sub-delims )\n\n var host = '(?:' + IPLiteral + '|' + rfc3986.ipv4address + '|' + regName + ')'; // host = IP-literal / IPv4address / reg-name\n\n var port = '\\\\d*'; // port = *DIGIT\n\n var authority = '(?:' + userinfo + '@)?' + host + '(?::' + port + ')?'; // authority = [ userinfo \"@\" ] host [ \":\" port ]\n\n var authorityCapture = '(?:' + userinfo + '@)?(' + host + ')(?::' + port + ')?';\n /*\r\n segment = *pchar\r\n segment-nz = 1*pchar\r\n path = path-abempty ; begins with \"/\" '|' is empty\r\n / path-absolute ; begins with \"/\" but not \"//\"\r\n / path-noscheme ; begins with a non-colon segment\r\n / path-rootless ; begins with a segment\r\n / path-empty ; zero characters\r\n path-abempty = *( \"/\" segment )\r\n path-absolute = \"/\" [ segment-nz *( \"/\" segment ) ]\r\n path-rootless = segment-nz *( \"/\" segment )\r\n */\n\n var segment = pcharOnly + '*';\n var segmentNz = pcharOnly + '+';\n var segmentNzNc = '[' + unreserved + pctEncoded + subDelims + '@' + ']+';\n var pathEmpty = '';\n var pathAbEmpty = '(?:\\\\/' + segment + ')*';\n var pathAbsolute = '\\\\/(?:' + segmentNz + pathAbEmpty + ')?';\n var pathRootless = segmentNz + pathAbEmpty;\n var pathNoScheme = segmentNzNc + pathAbEmpty;\n var pathAbNoAuthority = '(?:\\\\/\\\\/\\\\/' + segment + pathAbEmpty + ')'; // Used by file:///\n // hier-part = \"//\" authority path\n\n rfc3986.hierPart = '(?:' + '(?:\\\\/\\\\/' + authority + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathRootless + '|' + pathAbNoAuthority + ')';\n rfc3986.hierPartCapture = '(?:' + '(?:\\\\/\\\\/' + authorityCapture + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathRootless + ')'; // relative-part = \"//\" authority path-abempty / path-absolute / path-noscheme / path-empty\n\n rfc3986.relativeRef = '(?:' + '(?:\\\\/\\\\/' + authority + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathNoScheme + '|' + pathEmpty + ')'; // query = *( pchar / \"/\" / \"?\" )\n // query = *( pchar / \"[\" / \"]\" / \"/\" / \"?\" )\n\n rfc3986.query = '[' + pchar + '\\\\/\\\\?]*(?=#|$)'; //Finish matching either at the fragment part '|' end of the line.\n\n rfc3986.queryWithSquareBrackets = '[' + pchar + '\\\\[\\\\]\\\\/\\\\?]*(?=#|$)'; // fragment = *( pchar / \"/\" / \"?\" )\n\n rfc3986.fragment = '[' + pchar + '\\\\/\\\\?]*';\n return rfc3986;\n};\n\nmodule.exports = exports = internals.rfc3986 = internals.generate();\n\ninternals.createRegex = function (options) {\n var rfc = internals.rfc3986; // Construct expression\n\n var query = options.allowQuerySquareBrackets ? rfc.queryWithSquareBrackets : rfc.query;\n var suffix = '(?:\\\\?' + query + ')?' + '(?:#' + rfc.fragment + ')?$'; // relative-ref = relative-part [ \"?\" query ] [ \"#\" fragment ]\n\n if (options.relativeOnly) {\n return new RegExp('^' + rfc.relativeRef + suffix);\n } // Custom schemes\n\n\n var customScheme = '';\n\n if (options.scheme) {\n Assert(options.scheme instanceof RegExp || typeof options.scheme === 'string' || Array.isArray(options.scheme), 'scheme must be a RegExp, String, or Array');\n var schemes = [].concat(options.scheme);\n Assert(schemes.length >= 1, 'scheme must have at least 1 scheme specified'); // Flatten the array into a string to be used to match the schemes\n\n var selections = [];\n\n for (var i = 0; i < schemes.length; ++i) {\n var _scheme = schemes[i];\n Assert(_scheme instanceof RegExp || typeof _scheme === 'string', 'scheme at position ' + i + ' must be a RegExp or String');\n\n if (_scheme instanceof RegExp) {\n selections.push(_scheme.source.toString());\n } else {\n Assert(rfc.schemeRegex.test(_scheme), 'scheme at position ' + i + ' must be a valid scheme');\n selections.push(EscapeRegex(_scheme));\n }\n }\n\n customScheme = selections.join('|');\n } // URI = scheme \":\" hier-part [ \"?\" query ] [ \"#\" fragment ]\n\n\n var scheme = customScheme ? '(?:' + customScheme + ')' : rfc.scheme;\n var absolute = '(?:' + scheme + ':' + (options.domain ? rfc.hierPartCapture : rfc.hierPart) + ')';\n var prefix = options.allowRelative ? '(?:' + absolute + '|' + rfc.relativeRef + ')' : absolute;\n var regex = new RegExp('^' + prefix + suffix);\n regex.scheme = customScheme;\n return regex;\n};\n\ninternals.uriRegex = internals.createRegex({});\n\nexports.createRegex = function () {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n if (options.scheme || options.allowRelative || options.relativeOnly || options.allowQuerySquareBrackets || options.domain) {\n return internals.createRegex(options);\n }\n\n return internals.uriRegex;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst EscapeRegex = require('@hapi/hoek/lib/escapeRegex');\n\nconst internals = {};\n\ninternals.generate = function () {\n const rfc3986 = {};\n const hexDigit = '\\\\dA-Fa-f'; // HEXDIG = DIGIT / \"A\" / \"B\" / \"C\" / \"D\" / \"E\" / \"F\"\n\n const hexDigitOnly = '[' + hexDigit + ']';\n const unreserved = '\\\\w-\\\\.~'; // unreserved = ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\"\n\n const subDelims = '!\\\\$&\\'\\\\(\\\\)\\\\*\\\\+,;='; // sub-delims = \"!\" / \"$\" / \"&\" / \"'\" / \"(\" / \")\" / \"*\" / \"+\" / \",\" / \";\" / \"=\"\n\n const pctEncoded = '%' + hexDigit; // pct-encoded = \"%\" HEXDIG HEXDIG\n\n const pchar = unreserved + pctEncoded + subDelims + ':@'; // pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"\n\n const pcharOnly = '[' + pchar + ']';\n const decOctect = '(?:0{0,2}\\\\d|0?[1-9]\\\\d|1\\\\d\\\\d|2[0-4]\\\\d|25[0-5])'; // dec-octet = DIGIT / %x31-39 DIGIT / \"1\" 2DIGIT / \"2\" %x30-34 DIGIT / \"25\" %x30-35 ; 0-9 / 10-99 / 100-199 / 200-249 / 250-255\n\n rfc3986.ipv4address = '(?:' + decOctect + '\\\\.){3}' + decOctect; // IPv4address = dec-octet \".\" dec-octet \".\" dec-octet \".\" dec-octet\n\n /*\r\n h16 = 1*4HEXDIG ; 16 bits of address represented in hexadecimal\r\n ls32 = ( h16 \":\" h16 ) / IPv4address ; least-significant 32 bits of address\r\n IPv6address = 6( h16 \":\" ) ls32\r\n / \"::\" 5( h16 \":\" ) ls32\r\n / [ h16 ] \"::\" 4( h16 \":\" ) ls32\r\n / [ *1( h16 \":\" ) h16 ] \"::\" 3( h16 \":\" ) ls32\r\n / [ *2( h16 \":\" ) h16 ] \"::\" 2( h16 \":\" ) ls32\r\n / [ *3( h16 \":\" ) h16 ] \"::\" h16 \":\" ls32\r\n / [ *4( h16 \":\" ) h16 ] \"::\" ls32\r\n / [ *5( h16 \":\" ) h16 ] \"::\" h16\r\n / [ *6( h16 \":\" ) h16 ] \"::\"\r\n */\n\n const h16 = hexDigitOnly + '{1,4}';\n const ls32 = '(?:' + h16 + ':' + h16 + '|' + rfc3986.ipv4address + ')';\n const IPv6SixHex = '(?:' + h16 + ':){6}' + ls32;\n const IPv6FiveHex = '::(?:' + h16 + ':){5}' + ls32;\n const IPv6FourHex = '(?:' + h16 + ')?::(?:' + h16 + ':){4}' + ls32;\n const IPv6ThreeHex = '(?:(?:' + h16 + ':){0,1}' + h16 + ')?::(?:' + h16 + ':){3}' + ls32;\n const IPv6TwoHex = '(?:(?:' + h16 + ':){0,2}' + h16 + ')?::(?:' + h16 + ':){2}' + ls32;\n const IPv6OneHex = '(?:(?:' + h16 + ':){0,3}' + h16 + ')?::' + h16 + ':' + ls32;\n const IPv6NoneHex = '(?:(?:' + h16 + ':){0,4}' + h16 + ')?::' + ls32;\n const IPv6NoneHex2 = '(?:(?:' + h16 + ':){0,5}' + h16 + ')?::' + h16;\n const IPv6NoneHex3 = '(?:(?:' + h16 + ':){0,6}' + h16 + ')?::';\n rfc3986.ipv4Cidr = '\\\\d|[1-2]\\\\d|3[0-2]'; // IPv4 cidr = DIGIT / %x31-32 DIGIT / \"3\" %x30-32 ; 0-9 / 10-29 / 30-32\n\n rfc3986.ipv6Cidr = '(?:0{0,2}\\\\d|0?[1-9]\\\\d|1[01]\\\\d|12[0-8])'; // IPv6 cidr = DIGIT / %x31-39 DIGIT / \"1\" %x0-1 DIGIT / \"12\" %x0-8; 0-9 / 10-99 / 100-119 / 120-128\n\n rfc3986.ipv6address = '(?:' + IPv6SixHex + '|' + IPv6FiveHex + '|' + IPv6FourHex + '|' + IPv6ThreeHex + '|' + IPv6TwoHex + '|' + IPv6OneHex + '|' + IPv6NoneHex + '|' + IPv6NoneHex2 + '|' + IPv6NoneHex3 + ')';\n rfc3986.ipvFuture = 'v' + hexDigitOnly + '+\\\\.[' + unreserved + subDelims + ':]+'; // IPvFuture = \"v\" 1*HEXDIG \".\" 1*( unreserved / sub-delims / \":\" )\n\n rfc3986.scheme = '[a-zA-Z][a-zA-Z\\\\d+-\\\\.]*'; // scheme = ALPHA *( ALPHA / DIGIT / \"+\" / \"-\" / \".\" )\n\n rfc3986.schemeRegex = new RegExp(rfc3986.scheme);\n const userinfo = '[' + unreserved + pctEncoded + subDelims + ':]*'; // userinfo = *( unreserved / pct-encoded / sub-delims / \":\" )\n\n const IPLiteral = '\\\\[(?:' + rfc3986.ipv6address + '|' + rfc3986.ipvFuture + ')\\\\]'; // IP-literal = \"[\" ( IPv6address / IPvFuture ) \"]\"\n\n const regName = '[' + unreserved + pctEncoded + subDelims + ']{1,255}'; // reg-name = *( unreserved / pct-encoded / sub-delims )\n\n const host = '(?:' + IPLiteral + '|' + rfc3986.ipv4address + '|' + regName + ')'; // host = IP-literal / IPv4address / reg-name\n\n const port = '\\\\d*'; // port = *DIGIT\n\n const authority = '(?:' + userinfo + '@)?' + host + '(?::' + port + ')?'; // authority = [ userinfo \"@\" ] host [ \":\" port ]\n\n const authorityCapture = '(?:' + userinfo + '@)?(' + host + ')(?::' + port + ')?';\n /*\r\n segment = *pchar\r\n segment-nz = 1*pchar\r\n path = path-abempty ; begins with \"/\" '|' is empty\r\n / path-absolute ; begins with \"/\" but not \"//\"\r\n / path-noscheme ; begins with a non-colon segment\r\n / path-rootless ; begins with a segment\r\n / path-empty ; zero characters\r\n path-abempty = *( \"/\" segment )\r\n path-absolute = \"/\" [ segment-nz *( \"/\" segment ) ]\r\n path-rootless = segment-nz *( \"/\" segment )\r\n */\n\n const segment = pcharOnly + '*';\n const segmentNz = pcharOnly + '+';\n const segmentNzNc = '[' + unreserved + pctEncoded + subDelims + '@' + ']+';\n const pathEmpty = '';\n const pathAbEmpty = '(?:\\\\/' + segment + ')*';\n const pathAbsolute = '\\\\/(?:' + segmentNz + pathAbEmpty + ')?';\n const pathRootless = segmentNz + pathAbEmpty;\n const pathNoScheme = segmentNzNc + pathAbEmpty;\n const pathAbNoAuthority = '(?:\\\\/\\\\/\\\\/' + segment + pathAbEmpty + ')'; // Used by file:///\n // hier-part = \"//\" authority path\n\n rfc3986.hierPart = '(?:' + '(?:\\\\/\\\\/' + authority + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathRootless + '|' + pathAbNoAuthority + ')';\n rfc3986.hierPartCapture = '(?:' + '(?:\\\\/\\\\/' + authorityCapture + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathRootless + ')'; // relative-part = \"//\" authority path-abempty / path-absolute / path-noscheme / path-empty\n\n rfc3986.relativeRef = '(?:' + '(?:\\\\/\\\\/' + authority + pathAbEmpty + ')' + '|' + pathAbsolute + '|' + pathNoScheme + '|' + pathEmpty + ')'; // query = *( pchar / \"/\" / \"?\" )\n // query = *( pchar / \"[\" / \"]\" / \"/\" / \"?\" )\n\n rfc3986.query = '[' + pchar + '\\\\/\\\\?]*(?=#|$)'; //Finish matching either at the fragment part '|' end of the line.\n\n rfc3986.queryWithSquareBrackets = '[' + pchar + '\\\\[\\\\]\\\\/\\\\?]*(?=#|$)'; // fragment = *( pchar / \"/\" / \"?\" )\n\n rfc3986.fragment = '[' + pchar + '\\\\/\\\\?]*';\n return rfc3986;\n};\n\nmodule.exports = exports = internals.rfc3986 = internals.generate();\n\ninternals.createRegex = function (options) {\n const rfc = internals.rfc3986; // Construct expression\n\n const query = options.allowQuerySquareBrackets ? rfc.queryWithSquareBrackets : rfc.query;\n const suffix = '(?:\\\\?' + query + ')?' + '(?:#' + rfc.fragment + ')?$'; // relative-ref = relative-part [ \"?\" query ] [ \"#\" fragment ]\n\n if (options.relativeOnly) {\n return new RegExp('^' + rfc.relativeRef + suffix);\n } // Custom schemes\n\n\n let customScheme = '';\n\n if (options.scheme) {\n Assert(options.scheme instanceof RegExp || typeof options.scheme === 'string' || Array.isArray(options.scheme), 'scheme must be a RegExp, String, or Array');\n const schemes = [].concat(options.scheme);\n Assert(schemes.length >= 1, 'scheme must have at least 1 scheme specified'); // Flatten the array into a string to be used to match the schemes\n\n const selections = [];\n\n for (let i = 0; i < schemes.length; ++i) {\n const scheme = schemes[i];\n Assert(scheme instanceof RegExp || typeof scheme === 'string', 'scheme at position ' + i + ' must be a RegExp or String');\n\n if (scheme instanceof RegExp) {\n selections.push(scheme.source.toString());\n } else {\n Assert(rfc.schemeRegex.test(scheme), 'scheme at position ' + i + ' must be a valid scheme');\n selections.push(EscapeRegex(scheme));\n }\n }\n\n customScheme = selections.join('|');\n } // URI = scheme \":\" hier-part [ \"?\" query ] [ \"#\" fragment ]\n\n\n const scheme = customScheme ? '(?:' + customScheme + ')' : rfc.scheme;\n const absolute = '(?:' + scheme + ':' + (options.domain ? rfc.hierPartCapture : rfc.hierPart) + ')';\n const prefix = options.allowRelative ? '(?:' + absolute + '|' + rfc.relativeRef + ')' : absolute;\n const regex = new RegExp('^' + prefix + suffix);\n regex.scheme = customScheme;\n return regex;\n};\n\ninternals.uriRegex = internals.createRegex({});\n\nexports.createRegex = function () {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n if (options.scheme || options.allowRelative || options.relativeOnly || options.allowQuerySquareBrackets || options.domain) {\n return internals.createRegex(options);\n }\n\n return internals.uriRegex;\n};" }, { - "id": 26, + "id": 25, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/stringify.js", "name": "../node_modules/@hapi/hoek/lib/stringify.js", "index": 3, "index2": 0, - "size": 341, + "size": 343, "cacheable": true, "built": true, "optional": false, @@ -7271,8 +7085,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -7280,9 +7094,9 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/common.js", "name": "../lib/common.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { @@ -7290,15 +7104,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/error.js", "name": "../node_modules/@hapi/hoek/lib/error.js", "profile": { - "factory": 1398, - "building": 8, - "dependencies": 1 + "factory": 890, + "building": 9, + "dependencies": 0 } } ], "profile": { - "factory": 340, - "building": 120 + "factory": 168, + "building": 105 }, "failed": false, "errors": 0, @@ -7312,7 +7126,7 @@ "moduleName": "../node_modules/@hapi/hoek/lib/error.js", "type": "cjs require", "userRequest": "./stringify", - "loc": "25:16-38" + "loc": "3:18-40" } ], "usedExports": true, @@ -7321,15 +7135,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nvar internals = {};\n\nmodule.exports = function () {\n try {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return JSON.stringify.apply(null, args);\n } catch (err) {\n return '[Cannot display object: ' + err.message + ']';\n }\n};" + "source": "'use strict';\n\nconst internals = {};\n\nmodule.exports = function () {\n try {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return JSON.stringify.apply(null, args);\n } catch (err) {\n return '[Cannot display object: ' + err.message + ']';\n }\n};" }, { - "id": 27, + "id": 26, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/marker/lib/index.js", "name": "../node_modules/@hapi/marker/lib/index.js", "index": 10, "index2": 7, - "size": 290, + "size": 292, "cacheable": true, "built": true, "optional": false, @@ -7346,8 +7160,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -7355,16 +7169,16 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/common.js", "name": "../lib/common.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1398, - "building": 8, - "dependencies": 1 + "factory": 890, + "building": 9, + "dependencies": 0 }, "failed": false, "errors": 0, @@ -7378,7 +7192,7 @@ "moduleName": "../lib/common.js", "type": "cjs require", "userRequest": "@hapi/marker", - "loc": "23:13-36" + "loc": "7:15-38" } ], "usedExports": true, @@ -7387,15 +7201,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nvar internals = {\n symbols: new Map()\n};\n\nmodule.exports = exports = function exports(subject) {\n var symbol = internals.symbols.get(subject);\n\n if (symbol) {\n return symbol;\n }\n\n symbol = Symbol(subject);\n internals.symbols.set(subject, symbol);\n return symbol;\n};" + "source": "'use strict';\n\nconst internals = {\n symbols: new Map()\n};\n\nmodule.exports = exports = function exports(subject) {\n let symbol = internals.symbols.get(subject);\n\n if (symbol) {\n return symbol;\n }\n\n symbol = Symbol(subject);\n internals.symbols.set(subject, symbol);\n return symbol;\n};" }, { - "id": 28, + "id": 27, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/escapeHtml.js", "name": "../node_modules/@hapi/hoek/lib/escapeHtml.js", "index": 15, "index2": 10, - "size": 1409, + "size": 1419, "cacheable": true, "built": true, "optional": false, @@ -7412,8 +7226,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -7421,15 +7235,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/template.js", "name": "../lib/template.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1211, - "building": 77 + "factory": 680, + "building": 39 }, "failed": false, "errors": 0, @@ -7443,7 +7257,7 @@ "moduleName": "../lib/template.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/escapeHtml", - "loc": "31:17-53" + "loc": "7:19-55" } ], "usedExports": true, @@ -7452,15 +7266,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nvar internals = {};\n\nmodule.exports = function (input) {\n if (!input) {\n return '';\n }\n\n var escaped = '';\n\n for (var i = 0; i < input.length; ++i) {\n var charCode = input.charCodeAt(i);\n\n if (internals.isSafe(charCode)) {\n escaped += input[i];\n } else {\n escaped += internals.escapeHtmlChar(charCode);\n }\n }\n\n return escaped;\n};\n\ninternals.escapeHtmlChar = function (charCode) {\n var namedEscape = internals.namedHtml[charCode];\n\n if (typeof namedEscape !== 'undefined') {\n return namedEscape;\n }\n\n if (charCode >= 256) {\n return '&#' + charCode + ';';\n }\n\n var hexValue = charCode.toString(16).padStart(2, '0');\n return \"&#x\".concat(hexValue, \";\");\n};\n\ninternals.isSafe = function (charCode) {\n return typeof internals.safeCharCodes[charCode] !== 'undefined';\n};\n\ninternals.namedHtml = {\n '38': '&',\n '60': '<',\n '62': '>',\n '34': '"',\n '160': ' ',\n '162': '¢',\n '163': '£',\n '164': '¤',\n '169': '©',\n '174': '®'\n};\n\ninternals.safeCharCodes = function () {\n var safe = {};\n\n for (var i = 32; i < 123; ++i) {\n if (i >= 97 || // a-z\n i >= 65 && i <= 90 || // A-Z\n i >= 48 && i <= 57 || // 0-9\n i === 32 || // space\n i === 46 || // .\n i === 44 || // ,\n i === 45 || // -\n i === 58 || // :\n i === 95) {\n // _\n safe[i] = null;\n }\n }\n\n return safe;\n}();" + "source": "'use strict';\n\nconst internals = {};\n\nmodule.exports = function (input) {\n if (!input) {\n return '';\n }\n\n let escaped = '';\n\n for (let i = 0; i < input.length; ++i) {\n const charCode = input.charCodeAt(i);\n\n if (internals.isSafe(charCode)) {\n escaped += input[i];\n } else {\n escaped += internals.escapeHtmlChar(charCode);\n }\n }\n\n return escaped;\n};\n\ninternals.escapeHtmlChar = function (charCode) {\n const namedEscape = internals.namedHtml[charCode];\n\n if (typeof namedEscape !== 'undefined') {\n return namedEscape;\n }\n\n if (charCode >= 256) {\n return '&#' + charCode + ';';\n }\n\n const hexValue = charCode.toString(16).padStart(2, '0');\n return \"&#x\".concat(hexValue, \";\");\n};\n\ninternals.isSafe = function (charCode) {\n return typeof internals.safeCharCodes[charCode] !== 'undefined';\n};\n\ninternals.namedHtml = {\n '38': '&',\n '60': '<',\n '62': '>',\n '34': '"',\n '160': ' ',\n '162': '¢',\n '163': '£',\n '164': '¤',\n '169': '©',\n '174': '®'\n};\n\ninternals.safeCharCodes = function () {\n const safe = {};\n\n for (let i = 32; i < 123; ++i) {\n if (i >= 97 || // a-z\n i >= 65 && i <= 90 || // A-Z\n i >= 48 && i <= 57 || // 0-9\n i === 32 || // space\n i === 46 || // .\n i === 44 || // ,\n i === 45 || // -\n i === 58 || // :\n i === 95) {\n // _\n safe[i] = null;\n }\n }\n\n return safe;\n}();" }, { - "id": 29, + "id": 28, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/formula/lib/index.js", "name": "../node_modules/@hapi/formula/lib/index.js", "index": 16, "index2": 11, - "size": 15073, + "size": 10711, "cacheable": true, "built": true, "optional": false, @@ -7477,8 +7291,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -7486,15 +7300,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/template.js", "name": "../lib/template.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 1211, - "building": 77 + "factory": 680, + "building": 39 }, "failed": false, "errors": 0, @@ -7508,7 +7322,7 @@ "moduleName": "../lib/template.js", "type": "cjs require", "userRequest": "@hapi/formula", - "loc": "33:14-38" + "loc": "9:16-40" } ], "usedExports": true, @@ -7517,15 +7331,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar internals = {\n operators: ['!', '^', '*', '/', '%', '+', '-', '<', '<=', '>', '>=', '==', '!=', '&&', '||', '??'],\n operatorCharacters: ['!', '^', '*', '/', '%', '+', '-', '<', '=', '>', '&', '|', '?'],\n operatorsOrder: [['^'], ['*', '/', '%'], ['+', '-'], ['<', '<=', '>', '>='], ['==', '!='], ['&&'], ['||', '??']],\n operatorsPrefix: ['!', 'n'],\n literals: {\n '\"': '\"',\n '`': '`',\n '\\'': '\\'',\n '[': ']'\n },\n numberRx: /^(?:[0-9]*\\.?[0-9]*){1}$/,\n tokenRx: /^[\\w\\$\\#\\.\\@\\:\\{\\}]+$/,\n symbol: Symbol('formula'),\n settings: Symbol('settings')\n};\n\nexports = module.exports = internals.Formula =\n/*#__PURE__*/\nfunction () {\n function _class(string) {\n var _Object$assign;\n\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, _class);\n\n if (!options[internals.settings] && options.constants) {\n for (var constant in options.constants) {\n var value = options.constants[constant];\n\n if (value !== null && !['boolean', 'number', 'string'].includes(_typeof(value))) {\n throw new Error(\"Formula constant \".concat(constant, \" contains invalid \").concat(_typeof(value), \" value type\"));\n }\n }\n }\n\n this.settings = options[internals.settings] ? options : Object.assign((_Object$assign = {}, _defineProperty(_Object$assign, internals.settings, true), _defineProperty(_Object$assign, \"constants\", {}), _defineProperty(_Object$assign, \"functions\", {}), _Object$assign), options);\n this.single = null;\n this._parts = null;\n\n this._parse(string);\n }\n\n _createClass(_class, [{\n key: \"_parse\",\n value: function _parse(string) {\n var _this = this;\n\n var parts = [];\n var current = '';\n var parenthesis = 0;\n var literal = false;\n\n var flush = function flush(inner) {\n if (parenthesis) {\n throw new Error('Formula missing closing parenthesis');\n }\n\n var last = parts.length ? parts[parts.length - 1] : null;\n\n if (!literal && !current && !inner) {\n return;\n }\n\n if (last && last.type === 'reference' && inner === ')') {\n // Function\n last.type = 'function';\n last.value = _this._subFormula(current, last.value);\n current = '';\n return;\n }\n\n if (inner === ')') {\n // Segment\n var sub = new internals.Formula(current, _this.settings);\n parts.push({\n type: 'segment',\n value: sub\n });\n } else if (literal) {\n if (literal === ']') {\n // Reference\n parts.push({\n type: 'reference',\n value: current\n });\n current = '';\n return;\n }\n\n parts.push({\n type: 'literal',\n value: current\n }); // Literal\n } else if (internals.operatorCharacters.includes(current)) {\n // Operator\n if (last && last.type === 'operator' && internals.operators.includes(last.value + current)) {\n // 2 characters operator\n last.value += current;\n } else {\n parts.push({\n type: 'operator',\n value: current\n });\n }\n } else if (current.match(internals.numberRx)) {\n // Number\n parts.push({\n type: 'constant',\n value: parseFloat(current)\n });\n } else if (_this.settings.constants[current] !== undefined) {\n // Constant\n parts.push({\n type: 'constant',\n value: _this.settings.constants[current]\n });\n } else {\n // Reference\n if (!current.match(internals.tokenRx)) {\n throw new Error(\"Formula contains invalid token: \".concat(current));\n }\n\n parts.push({\n type: 'reference',\n value: current\n });\n }\n\n current = '';\n };\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = string[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var c = _step.value;\n\n if (literal) {\n if (c === literal) {\n flush();\n literal = false;\n } else {\n current += c;\n }\n } else if (parenthesis) {\n if (c === '(') {\n current += c;\n ++parenthesis;\n } else if (c === ')') {\n --parenthesis;\n\n if (!parenthesis) {\n flush(c);\n } else {\n current += c;\n }\n } else {\n current += c;\n }\n } else if (c in internals.literals) {\n literal = internals.literals[c];\n } else if (c === '(') {\n flush();\n ++parenthesis;\n } else if (internals.operatorCharacters.includes(c)) {\n flush();\n current = c;\n flush();\n } else if (c !== ' ') {\n current += c;\n } else {\n flush();\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n flush(); // Replace prefix - to internal negative operator\n\n parts = parts.map(function (part, i) {\n if (part.type !== 'operator' || part.value !== '-' || i && parts[i - 1].type !== 'operator') {\n return part;\n }\n\n return {\n type: 'operator',\n value: 'n'\n };\n }); // Validate tokens order\n\n var operator = false;\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = parts[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var part = _step2.value;\n\n if (part.type === 'operator') {\n if (internals.operatorsPrefix.includes(part.value)) {\n continue;\n }\n\n if (!operator) {\n throw new Error('Formula contains an operator in invalid position');\n }\n\n if (!internals.operators.includes(part.value)) {\n throw new Error(\"Formula contains an unknown operator \".concat(part.value));\n }\n } else if (operator) {\n throw new Error('Formula missing expected operator');\n }\n\n operator = !operator;\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (!operator) {\n throw new Error('Formula contains invalid trailing operator');\n } // Identify single part\n\n\n if (parts.length === 1 && ['reference', 'literal', 'constant'].includes(parts[0].type)) {\n this.single = {\n type: parts[0].type === 'reference' ? 'reference' : 'value',\n value: parts[0].value\n };\n } // Process parts\n\n\n this._parts = parts.map(function (part) {\n // Operators\n if (part.type === 'operator') {\n return internals.operatorsPrefix.includes(part.value) ? part : part.value;\n } // Literals, constants, segments\n\n\n if (part.type !== 'reference') {\n return part.value;\n } // References\n\n\n if (_this.settings.tokenRx && !_this.settings.tokenRx.test(part.value)) {\n throw new Error(\"Formula contains invalid reference \".concat(part.value));\n }\n\n if (_this.settings.reference) {\n return _this.settings.reference(part.value);\n }\n\n return internals.reference(part.value);\n });\n }\n }, {\n key: \"_subFormula\",\n value: function _subFormula(string, name) {\n var _this2 = this;\n\n var method = this.settings.functions[name];\n\n if (typeof method !== 'function') {\n throw new Error(\"Formula contains unknown function \".concat(name));\n }\n\n var args = [];\n\n if (string) {\n var current = '';\n var parenthesis = 0;\n var literal = false;\n\n var flush = function flush() {\n if (!current) {\n throw new Error(\"Formula contains function \".concat(name, \" with invalid arguments \").concat(string));\n }\n\n args.push(current);\n current = '';\n };\n\n for (var i = 0; i < string.length; ++i) {\n var c = string[i];\n\n if (literal) {\n current += c;\n\n if (c === literal) {\n literal = false;\n }\n } else if (c in internals.literals && !parenthesis) {\n current += c;\n literal = internals.literals[c];\n } else if (c === ',' && !parenthesis) {\n flush();\n } else {\n current += c;\n\n if (c === '(') {\n ++parenthesis;\n } else if (c === ')') {\n --parenthesis;\n }\n }\n }\n\n flush();\n }\n\n args = args.map(function (arg) {\n return new internals.Formula(arg, _this2.settings);\n });\n return function (context) {\n var innerValues = [];\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = args[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var arg = _step3.value;\n innerValues.push(arg.evaluate(context));\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n return method.apply(void 0, innerValues);\n };\n }\n }, {\n key: \"evaluate\",\n value: function evaluate(context) {\n var parts = this._parts.slice(); // Prefix operators\n\n\n for (var i = parts.length - 2; i >= 0; --i) {\n var part = parts[i];\n\n if (part && part.type === 'operator') {\n var current = parts[i + 1];\n parts.splice(i + 1, 1);\n var value = internals.evaluate(current, context);\n parts[i] = internals.single(part.value, value);\n }\n } // Left-right operators\n\n\n internals.operatorsOrder.forEach(function (set) {\n for (var _i = 1; _i < parts.length - 1;) {\n if (set.includes(parts[_i])) {\n var operator = parts[_i];\n var left = internals.evaluate(parts[_i - 1], context);\n var right = internals.evaluate(parts[_i + 1], context);\n parts.splice(_i, 2);\n var result = internals.calculate(operator, left, right);\n parts[_i - 1] = result === 0 ? 0 : result; // Convert -0\n } else {\n _i += 2;\n }\n }\n });\n return internals.evaluate(parts[0], context);\n }\n }]);\n\n return _class;\n}();\n\ninternals.Formula.prototype[internals.symbol] = true;\n\ninternals.reference = function (name) {\n return function (context) {\n return context && context[name] !== undefined ? context[name] : null;\n };\n};\n\ninternals.evaluate = function (part, context) {\n if (part === null) {\n return null;\n }\n\n if (typeof part === 'function') {\n return part(context);\n }\n\n if (part[internals.symbol]) {\n return part.evaluate(context);\n }\n\n return part;\n};\n\ninternals.single = function (operator, value) {\n if (operator === '!') {\n return value ? false : true;\n } // operator === 'n'\n\n\n var negative = -value;\n\n if (negative === 0) {\n // Override -0\n return 0;\n }\n\n return negative;\n};\n\ninternals.calculate = function (operator, left, right) {\n if (operator === '??') {\n return internals.exists(left) ? left : right;\n }\n\n if (typeof left === 'string' || typeof right === 'string') {\n if (operator === '+') {\n left = internals.exists(left) ? left : '';\n right = internals.exists(right) ? right : '';\n return left + right;\n }\n } else {\n switch (operator) {\n case '^':\n return Math.pow(left, right);\n\n case '*':\n return left * right;\n\n case '/':\n return left / right;\n\n case '%':\n return left % right;\n\n case '+':\n return left + right;\n\n case '-':\n return left - right;\n }\n }\n\n switch (operator) {\n case '<':\n return left < right;\n\n case '<=':\n return left <= right;\n\n case '>':\n return left > right;\n\n case '>=':\n return left >= right;\n\n case '==':\n return left === right;\n\n case '!=':\n return left !== right;\n\n case '&&':\n return left && right;\n\n case '||':\n return left || right;\n }\n\n return null;\n};\n\ninternals.exists = function (value) {\n return value !== null && value !== undefined;\n};" + "source": "'use strict';\n\nconst internals = {\n operators: ['!', '^', '*', '/', '%', '+', '-', '<', '<=', '>', '>=', '==', '!=', '&&', '||', '??'],\n operatorCharacters: ['!', '^', '*', '/', '%', '+', '-', '<', '=', '>', '&', '|', '?'],\n operatorsOrder: [['^'], ['*', '/', '%'], ['+', '-'], ['<', '<=', '>', '>='], ['==', '!='], ['&&'], ['||', '??']],\n operatorsPrefix: ['!', 'n'],\n literals: {\n '\"': '\"',\n '`': '`',\n '\\'': '\\'',\n '[': ']'\n },\n numberRx: /^(?:[0-9]*\\.?[0-9]*){1}$/,\n tokenRx: /^[\\w\\$\\#\\.\\@\\:\\{\\}]+$/,\n symbol: Symbol('formula'),\n settings: Symbol('settings')\n};\nexports = module.exports = internals.Formula = class {\n constructor(string) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!options[internals.settings] && options.constants) {\n for (const constant in options.constants) {\n const value = options.constants[constant];\n\n if (value !== null && !['boolean', 'number', 'string'].includes(typeof value)) {\n throw new Error(\"Formula constant \".concat(constant, \" contains invalid \").concat(typeof value, \" value type\"));\n }\n }\n }\n\n this.settings = options[internals.settings] ? options : Object.assign({\n [internals.settings]: true,\n constants: {},\n functions: {}\n }, options);\n this.single = null;\n this._parts = null;\n\n this._parse(string);\n }\n\n _parse(string) {\n let parts = [];\n let current = '';\n let parenthesis = 0;\n let literal = false;\n\n const flush = inner => {\n if (parenthesis) {\n throw new Error('Formula missing closing parenthesis');\n }\n\n const last = parts.length ? parts[parts.length - 1] : null;\n\n if (!literal && !current && !inner) {\n return;\n }\n\n if (last && last.type === 'reference' && inner === ')') {\n // Function\n last.type = 'function';\n last.value = this._subFormula(current, last.value);\n current = '';\n return;\n }\n\n if (inner === ')') {\n // Segment\n const sub = new internals.Formula(current, this.settings);\n parts.push({\n type: 'segment',\n value: sub\n });\n } else if (literal) {\n if (literal === ']') {\n // Reference\n parts.push({\n type: 'reference',\n value: current\n });\n current = '';\n return;\n }\n\n parts.push({\n type: 'literal',\n value: current\n }); // Literal\n } else if (internals.operatorCharacters.includes(current)) {\n // Operator\n if (last && last.type === 'operator' && internals.operators.includes(last.value + current)) {\n // 2 characters operator\n last.value += current;\n } else {\n parts.push({\n type: 'operator',\n value: current\n });\n }\n } else if (current.match(internals.numberRx)) {\n // Number\n parts.push({\n type: 'constant',\n value: parseFloat(current)\n });\n } else if (this.settings.constants[current] !== undefined) {\n // Constant\n parts.push({\n type: 'constant',\n value: this.settings.constants[current]\n });\n } else {\n // Reference\n if (!current.match(internals.tokenRx)) {\n throw new Error(\"Formula contains invalid token: \".concat(current));\n }\n\n parts.push({\n type: 'reference',\n value: current\n });\n }\n\n current = '';\n };\n\n for (const c of string) {\n if (literal) {\n if (c === literal) {\n flush();\n literal = false;\n } else {\n current += c;\n }\n } else if (parenthesis) {\n if (c === '(') {\n current += c;\n ++parenthesis;\n } else if (c === ')') {\n --parenthesis;\n\n if (!parenthesis) {\n flush(c);\n } else {\n current += c;\n }\n } else {\n current += c;\n }\n } else if (c in internals.literals) {\n literal = internals.literals[c];\n } else if (c === '(') {\n flush();\n ++parenthesis;\n } else if (internals.operatorCharacters.includes(c)) {\n flush();\n current = c;\n flush();\n } else if (c !== ' ') {\n current += c;\n } else {\n flush();\n }\n }\n\n flush(); // Replace prefix - to internal negative operator\n\n parts = parts.map((part, i) => {\n if (part.type !== 'operator' || part.value !== '-' || i && parts[i - 1].type !== 'operator') {\n return part;\n }\n\n return {\n type: 'operator',\n value: 'n'\n };\n }); // Validate tokens order\n\n let operator = false;\n\n for (const part of parts) {\n if (part.type === 'operator') {\n if (internals.operatorsPrefix.includes(part.value)) {\n continue;\n }\n\n if (!operator) {\n throw new Error('Formula contains an operator in invalid position');\n }\n\n if (!internals.operators.includes(part.value)) {\n throw new Error(\"Formula contains an unknown operator \".concat(part.value));\n }\n } else if (operator) {\n throw new Error('Formula missing expected operator');\n }\n\n operator = !operator;\n }\n\n if (!operator) {\n throw new Error('Formula contains invalid trailing operator');\n } // Identify single part\n\n\n if (parts.length === 1 && ['reference', 'literal', 'constant'].includes(parts[0].type)) {\n this.single = {\n type: parts[0].type === 'reference' ? 'reference' : 'value',\n value: parts[0].value\n };\n } // Process parts\n\n\n this._parts = parts.map(part => {\n // Operators\n if (part.type === 'operator') {\n return internals.operatorsPrefix.includes(part.value) ? part : part.value;\n } // Literals, constants, segments\n\n\n if (part.type !== 'reference') {\n return part.value;\n } // References\n\n\n if (this.settings.tokenRx && !this.settings.tokenRx.test(part.value)) {\n throw new Error(\"Formula contains invalid reference \".concat(part.value));\n }\n\n if (this.settings.reference) {\n return this.settings.reference(part.value);\n }\n\n return internals.reference(part.value);\n });\n }\n\n _subFormula(string, name) {\n const method = this.settings.functions[name];\n\n if (typeof method !== 'function') {\n throw new Error(\"Formula contains unknown function \".concat(name));\n }\n\n let args = [];\n\n if (string) {\n let current = '';\n let parenthesis = 0;\n let literal = false;\n\n const flush = () => {\n if (!current) {\n throw new Error(\"Formula contains function \".concat(name, \" with invalid arguments \").concat(string));\n }\n\n args.push(current);\n current = '';\n };\n\n for (let i = 0; i < string.length; ++i) {\n const c = string[i];\n\n if (literal) {\n current += c;\n\n if (c === literal) {\n literal = false;\n }\n } else if (c in internals.literals && !parenthesis) {\n current += c;\n literal = internals.literals[c];\n } else if (c === ',' && !parenthesis) {\n flush();\n } else {\n current += c;\n\n if (c === '(') {\n ++parenthesis;\n } else if (c === ')') {\n --parenthesis;\n }\n }\n }\n\n flush();\n }\n\n args = args.map(arg => new internals.Formula(arg, this.settings));\n return function (context) {\n const innerValues = [];\n\n for (const arg of args) {\n innerValues.push(arg.evaluate(context));\n }\n\n return method(...innerValues);\n };\n }\n\n evaluate(context) {\n const parts = this._parts.slice(); // Prefix operators\n\n\n for (let i = parts.length - 2; i >= 0; --i) {\n const part = parts[i];\n\n if (part && part.type === 'operator') {\n const current = parts[i + 1];\n parts.splice(i + 1, 1);\n const value = internals.evaluate(current, context);\n parts[i] = internals.single(part.value, value);\n }\n } // Left-right operators\n\n\n internals.operatorsOrder.forEach(set => {\n for (let i = 1; i < parts.length - 1;) {\n if (set.includes(parts[i])) {\n const operator = parts[i];\n const left = internals.evaluate(parts[i - 1], context);\n const right = internals.evaluate(parts[i + 1], context);\n parts.splice(i, 2);\n const result = internals.calculate(operator, left, right);\n parts[i - 1] = result === 0 ? 0 : result; // Convert -0\n } else {\n i += 2;\n }\n }\n });\n return internals.evaluate(parts[0], context);\n }\n\n};\ninternals.Formula.prototype[internals.symbol] = true;\n\ninternals.reference = function (name) {\n return function (context) {\n return context && context[name] !== undefined ? context[name] : null;\n };\n};\n\ninternals.evaluate = function (part, context) {\n if (part === null) {\n return null;\n }\n\n if (typeof part === 'function') {\n return part(context);\n }\n\n if (part[internals.symbol]) {\n return part.evaluate(context);\n }\n\n return part;\n};\n\ninternals.single = function (operator, value) {\n if (operator === '!') {\n return value ? false : true;\n } // operator === 'n'\n\n\n const negative = -value;\n\n if (negative === 0) {\n // Override -0\n return 0;\n }\n\n return negative;\n};\n\ninternals.calculate = function (operator, left, right) {\n if (operator === '??') {\n return internals.exists(left) ? left : right;\n }\n\n if (typeof left === 'string' || typeof right === 'string') {\n if (operator === '+') {\n left = internals.exists(left) ? left : '';\n right = internals.exists(right) ? right : '';\n return left + right;\n }\n } else {\n switch (operator) {\n case '^':\n return Math.pow(left, right);\n\n case '*':\n return left * right;\n\n case '/':\n return left / right;\n\n case '%':\n return left % right;\n\n case '+':\n return left + right;\n\n case '-':\n return left - right;\n }\n }\n\n switch (operator) {\n case '<':\n return left < right;\n\n case '<=':\n return left <= right;\n\n case '>':\n return left > right;\n\n case '>=':\n return left >= right;\n\n case '==':\n return left === right;\n\n case '!=':\n return left !== right;\n\n case '&&':\n return left && right;\n\n case '||':\n return left || right;\n }\n\n return null;\n};\n\ninternals.exists = function (value) {\n return value !== null && value !== undefined;\n};" }, { - "id": 30, + "id": 29, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/alternatives.js", "name": "../lib/types/alternatives.js", "index": 21, "index2": 28, - "size": 14536, + "size": 9018, "cacheable": true, "built": true, "optional": false, @@ -7542,15 +7356,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -7564,7 +7378,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/alternatives", - "loc": "38:18-49" + "loc": "24:18-49" } ], "usedExports": true, @@ -7573,15 +7387,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar Compile = require('../compile');\n\nvar Errors = require('../errors');\n\nvar Ref = require('../ref');\n\nvar internals = {};\nmodule.exports = Any.extend({\n type: 'alternatives',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.matches = [];\n },\n args: function args(schema, schemas) {\n return schema.try(schemas);\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n var error = _ref.error,\n state = _ref.state,\n prefs = _ref.prefs;\n var errors = [];\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = schema.$_terms.matches[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var item = _step.value;\n\n if (item.schema) {\n var result = item.schema.$_validate(value, state.nest(item.schema), prefs);\n\n if (!result.errors) {\n return result;\n }\n\n errors.push.apply(errors, _toConsumableArray(result.errors));\n continue;\n }\n\n var is = item.peek || item.is;\n var input = item.is ? item.ref.resolve(value, state, prefs) : value;\n\n if (!is.$_match(input, state.entry(is, state.ancestors[0]), prefs)) {\n if (item.otherwise) {\n return item.otherwise.$_validate(value, state.nest(item.otherwise), prefs);\n }\n } else if (item.then) {\n return item.then.$_validate(value, state.nest(item.then), prefs);\n }\n } // Nothing matched due to type criteria rules\n\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n if (!errors.length) {\n return {\n errors: error('alternatives.base')\n };\n } // Single error\n\n\n if (errors.length === 1) {\n return {\n errors: errors\n };\n } // All rules are base types\n\n\n var types = [];\n\n for (var _i = 0, _errors = errors; _i < _errors.length; _i++) {\n var report = _errors[_i];\n\n if (report instanceof Errors.Report === false) {\n return {\n errors: error('alternatives.match', Errors.details(errors, {\n override: false\n }))\n };\n }\n\n var _report$code$split = report.code.split('.'),\n _report$code$split2 = _slicedToArray(_report$code$split, 2),\n type = _report$code$split2[0],\n code = _report$code$split2[1];\n\n if (code !== 'base') {\n return {\n errors: error('alternatives.match', Errors.details(errors, {\n override: false\n }))\n };\n }\n\n types.push(type);\n } // Complex reasons\n\n\n return {\n errors: error('alternatives.types', {\n types: types\n })\n };\n },\n // Rules\n rules: {\n try: {\n method: function method(schemas) {\n Assert(schemas, 'Missing alternative schemas');\n Assert(!this._flags._endedSwitch, 'Unreachable condition');\n\n if (!Array.isArray(schemas)) {\n schemas = [schemas];\n }\n\n var obj = this.clone();\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = schemas[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var schema = _step2.value;\n obj.$_terms.matches.push({\n schema: obj.$_compile(schema)\n });\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return obj.$_mutateRebuild();\n }\n }\n },\n // Overrides\n overrides: {\n label: function label(name) {\n var obj = this.super.label(name);\n obj.$_terms.matches = obj.$_terms.matches.map(function (match) {\n if (match.schema) {\n return {\n schema: match.schema.label(name)\n };\n }\n\n match = Object.assign({}, match);\n\n if (match.then) {\n match.then = match.then.label(name);\n }\n\n if (match.otherwise) {\n match.otherwise = match.otherwise.label(name);\n }\n\n return match;\n });\n return obj;\n },\n tailor: function tailor(targets) {\n var obj = this.super.tailor(targets);\n\n if (obj === this) {\n obj = this.clone();\n }\n\n for (var i = 0; i < obj.$_terms.matches.length; ++i) {\n var match = Object.assign({}, obj.$_terms.matches[i]);\n obj.$_terms.matches[i] = match;\n\n for (var _i2 = 0, _arr2 = ['schema', 'peek', 'is', 'then', 'otherwise']; _i2 < _arr2.length; _i2++) {\n var key = _arr2[_i2];\n\n if (match[key]) {\n match[key] = match[key].tailor(targets);\n }\n }\n }\n\n return obj.$_mutateRebuild();\n },\n when: function when(condition, options) {\n if (Array.isArray(options)) {\n options = {\n switch: options\n };\n }\n\n Common.assertOptions(options, ['is', 'then', 'otherwise', 'switch']);\n var schemaCondition = Common.isSchema(condition);\n Assert(!this._flags._endedSwitch, 'Unreachable condition');\n Assert(Ref.isRef(condition) || typeof condition === 'string' || schemaCondition, 'Invalid condition:', condition);\n Assert(!options.switch || options.is === undefined, 'Cannot combine \"switch\" with \"is\"');\n Assert(!options.switch || options.then === undefined, 'Cannot combine \"switch\" with \"then\"');\n Assert(options.switch !== undefined || options.then !== undefined || options.otherwise !== undefined, 'options must have at least one of \"then\", \"otherwise\", or \"switch\"');\n Assert(!schemaCondition || options.is === undefined, '\"is\" can not be used with a schema condition');\n Assert(!schemaCondition || options.switch === undefined, '\"switch\" can not be used with a schema condition');\n Assert(schemaCondition || options.is !== undefined || options.switch !== undefined, 'Missing \"is\" or \"switch\" option');\n Assert(options.switch === undefined || Array.isArray(options.switch), '\"switch\" must be an array');\n var obj = this.clone();\n\n var normalize = function normalize(match, settings) {\n var isSchema = Common.isSchema(match);\n var item = {\n ref: !isSchema ? Compile.ref(match) : null,\n peek: isSchema ? match : null,\n then: settings.then !== undefined ? obj.$_compile(settings.then) : undefined,\n otherwise: settings.otherwise !== undefined ? obj.$_compile(settings.otherwise) : undefined\n };\n\n if (settings.is !== undefined) {\n item.is = obj.$_compile(settings.is);\n\n if (settings.is === null || !(Ref.isRef(settings.is) || Common.isSchema(settings.is))) {\n item.is = item.is.required(); // Only apply required if this wasn't already a schema or a ref\n }\n }\n\n if (item.then && item.otherwise) {\n obj.$_setFlag('_endedSwitch', true, {\n clone: false\n });\n }\n\n return item;\n }; // Single case\n\n\n if (options.switch === undefined) {\n obj.$_terms.matches.push(normalize(condition, options));\n return obj.$_mutateRebuild();\n } // Switch statement\n\n\n for (var i = 0; i < options.switch.length; ++i) {\n var test = options.switch[i];\n Assert(test.is !== undefined, 'Switch statement missing \"is\"');\n Assert(test.then !== undefined, 'Switch statement missing \"then\"');\n\n if (i + 1 !== options.switch.length) {\n Common.assertOptions(test, ['is', 'then']);\n obj.$_terms.matches.push(normalize(condition, test));\n } else {\n // Last\n Common.assertOptions(test, ['is', 'then', 'otherwise']);\n Assert(options.otherwise === undefined || test.otherwise === undefined, 'Cannot specify \"otherwise\" inside and outside a \"switch\"');\n var otherwise = options.otherwise !== undefined ? options.otherwise : test.otherwise;\n obj.$_terms.matches.push(normalize(condition, {\n is: test.is,\n then: test.then,\n otherwise: otherwise\n }));\n }\n }\n\n return obj.$_mutateRebuild();\n }\n },\n // Build\n build: function build(obj, desc) {\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = desc.matches[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var _step3$value = _step3.value,\n schema = _step3$value.schema,\n ref = _step3$value.ref,\n peek = _step3$value.peek,\n is = _step3$value.is,\n then = _step3$value.then,\n otherwise = _step3$value.otherwise;\n\n if (schema) {\n obj = obj.try(schema);\n } else {\n obj = obj.when(ref || peek, {\n is: is,\n then: then,\n otherwise: otherwise\n });\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n return obj;\n },\n // Modify\n modify: function modify(schema, id, replacement) {\n var i = 0;\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = schema.$_terms.matches[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var match = _step4.value;\n\n for (var _i3 = 0, _arr3 = ['schema', 'peek', 'is', 'then', 'otherwise']; _i3 < _arr3.length; _i3++) {\n var key = _arr3[_i3];\n\n if (match[key] && id === match[key]._flags.id) {\n var obj = schema.clone();\n obj.$_terms.matches[i] = Object.assign({}, match, _defineProperty({}, key, replacement));\n return obj.$_mutateRebuild();\n }\n }\n\n ++i;\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n },\n rebuild: function rebuild(schema) {\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = schema.$_terms.matches[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var match = _step5.value;\n\n for (var _i4 = 0, _arr4 = ['schema', 'ref', 'peek', 'is', 'then', 'otherwise']; _i4 < _arr4.length; _i4++) {\n var key = _arr4[_i4];\n schema.$_mutateRegister(match[key], {\n family: Ref.toSibling\n });\n } // Flag when an alternative type is an array\n\n\n for (var _i5 = 0, _arr5 = ['schema', 'then', 'otherwise']; _i5 < _arr5.length; _i5++) {\n var _key = _arr5[_i5];\n\n if (match[_key] && match[_key].type === 'array') {\n schema.$_setFlag('_arrayItems', true, {\n clone: false\n });\n break;\n }\n }\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n\n return schema;\n },\n // Errors\n messages: {\n 'alternatives.base': '\"{{#label}}\" does not match any of the allowed types',\n 'alternatives.match': '\"{{#label}}\" does not match any of the allowed types',\n 'alternatives.types': '\"{{#label}}\" must be one of {{#types}}'\n }\n});" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst Compile = require('../compile');\n\nconst Errors = require('../errors');\n\nconst Ref = require('../ref');\n\nconst internals = {};\nmodule.exports = Any.extend({\n type: 'alternatives',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.matches = [];\n },\n args: function args(schema, schemas) {\n return schema.try(schemas);\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n let {\n error,\n state,\n prefs\n } = _ref;\n const errors = [];\n\n for (const item of schema.$_terms.matches) {\n if (item.schema) {\n const result = item.schema.$_validate(value, state.nest(item.schema), prefs);\n\n if (!result.errors) {\n return result;\n }\n\n errors.push(...result.errors);\n continue;\n }\n\n const is = item.peek || item.is;\n const input = item.is ? item.ref.resolve(value, state, prefs) : value;\n\n if (!is.$_match(input, state.entry(is, state.ancestors[0]), prefs)) {\n if (item.otherwise) {\n return item.otherwise.$_validate(value, state.nest(item.otherwise), prefs);\n }\n } else if (item.then) {\n return item.then.$_validate(value, state.nest(item.then), prefs);\n }\n } // Nothing matched due to type criteria rules\n\n\n if (!errors.length) {\n return {\n errors: error('alternatives.base')\n };\n } // Single error\n\n\n if (errors.length === 1) {\n return {\n errors\n };\n } // All rules are base types\n\n\n const types = [];\n\n for (const report of errors) {\n if (report instanceof Errors.Report === false) {\n return {\n errors: error('alternatives.match', Errors.details(errors, {\n override: false\n }))\n };\n }\n\n const [type, code] = report.code.split('.');\n\n if (code !== 'base') {\n return {\n errors: error('alternatives.match', Errors.details(errors, {\n override: false\n }))\n };\n }\n\n types.push(type);\n } // Complex reasons\n\n\n return {\n errors: error('alternatives.types', {\n types\n })\n };\n },\n // Rules\n rules: {\n try: {\n method: function method(schemas) {\n Assert(schemas, 'Missing alternative schemas');\n Assert(!this._flags._endedSwitch, 'Unreachable condition');\n\n if (!Array.isArray(schemas)) {\n schemas = [schemas];\n }\n\n const obj = this.clone();\n\n for (const schema of schemas) {\n obj.$_terms.matches.push({\n schema: obj.$_compile(schema)\n });\n }\n\n return obj.$_mutateRebuild();\n }\n }\n },\n // Overrides\n overrides: {\n label(name) {\n const obj = this.super.label(name);\n obj.$_terms.matches = obj.$_terms.matches.map(match => {\n if (match.schema) {\n return {\n schema: match.schema.label(name)\n };\n }\n\n match = Object.assign({}, match);\n\n if (match.then) {\n match.then = match.then.label(name);\n }\n\n if (match.otherwise) {\n match.otherwise = match.otherwise.label(name);\n }\n\n return match;\n });\n return obj;\n },\n\n tailor(targets) {\n let obj = this.super.tailor(targets);\n\n if (obj === this) {\n obj = this.clone();\n }\n\n for (let i = 0; i < obj.$_terms.matches.length; ++i) {\n const match = Object.assign({}, obj.$_terms.matches[i]);\n obj.$_terms.matches[i] = match;\n\n for (const key of ['schema', 'peek', 'is', 'then', 'otherwise']) {\n if (match[key]) {\n match[key] = match[key].tailor(targets);\n }\n }\n }\n\n return obj.$_mutateRebuild();\n },\n\n when(condition, options) {\n if (Array.isArray(options)) {\n options = {\n switch: options\n };\n }\n\n Common.assertOptions(options, ['is', 'then', 'otherwise', 'switch']);\n const schemaCondition = Common.isSchema(condition);\n Assert(!this._flags._endedSwitch, 'Unreachable condition');\n Assert(Ref.isRef(condition) || typeof condition === 'string' || schemaCondition, 'Invalid condition:', condition);\n Assert(!options.switch || options.is === undefined, 'Cannot combine \"switch\" with \"is\"');\n Assert(!options.switch || options.then === undefined, 'Cannot combine \"switch\" with \"then\"');\n Assert(options.switch !== undefined || options.then !== undefined || options.otherwise !== undefined, 'options must have at least one of \"then\", \"otherwise\", or \"switch\"');\n Assert(!schemaCondition || options.is === undefined, '\"is\" can not be used with a schema condition');\n Assert(!schemaCondition || options.switch === undefined, '\"switch\" can not be used with a schema condition');\n Assert(schemaCondition || options.is !== undefined || options.switch !== undefined, 'Missing \"is\" or \"switch\" option');\n Assert(options.switch === undefined || Array.isArray(options.switch), '\"switch\" must be an array');\n const obj = this.clone();\n\n const normalize = (match, settings) => {\n const isSchema = Common.isSchema(match);\n const item = {\n ref: !isSchema ? Compile.ref(match) : null,\n peek: isSchema ? match : null,\n then: settings.then !== undefined ? obj.$_compile(settings.then) : undefined,\n otherwise: settings.otherwise !== undefined ? obj.$_compile(settings.otherwise) : undefined\n };\n\n if (settings.is !== undefined) {\n item.is = obj.$_compile(settings.is);\n\n if (settings.is === null || !(Ref.isRef(settings.is) || Common.isSchema(settings.is))) {\n item.is = item.is.required(); // Only apply required if this wasn't already a schema or a ref\n }\n }\n\n if (item.then && item.otherwise) {\n obj.$_setFlag('_endedSwitch', true, {\n clone: false\n });\n }\n\n return item;\n }; // Single case\n\n\n if (options.switch === undefined) {\n obj.$_terms.matches.push(normalize(condition, options));\n return obj.$_mutateRebuild();\n } // Switch statement\n\n\n for (let i = 0; i < options.switch.length; ++i) {\n const test = options.switch[i];\n Assert(test.is !== undefined, 'Switch statement missing \"is\"');\n Assert(test.then !== undefined, 'Switch statement missing \"then\"');\n\n if (i + 1 !== options.switch.length) {\n Common.assertOptions(test, ['is', 'then']);\n obj.$_terms.matches.push(normalize(condition, test));\n } else {\n // Last\n Common.assertOptions(test, ['is', 'then', 'otherwise']);\n Assert(options.otherwise === undefined || test.otherwise === undefined, 'Cannot specify \"otherwise\" inside and outside a \"switch\"');\n const otherwise = options.otherwise !== undefined ? options.otherwise : test.otherwise;\n obj.$_terms.matches.push(normalize(condition, {\n is: test.is,\n then: test.then,\n otherwise\n }));\n }\n }\n\n return obj.$_mutateRebuild();\n }\n\n },\n // Build\n build: function build(obj, desc) {\n for (const _ref2 of desc.matches) {\n const {\n schema,\n ref,\n peek,\n is,\n then,\n otherwise\n } = _ref2;\n\n if (schema) {\n obj = obj.try(schema);\n } else {\n obj = obj.when(ref || peek, {\n is,\n then,\n otherwise\n });\n }\n }\n\n return obj;\n },\n // Modify\n modify: function modify(schema, id, replacement) {\n let i = 0;\n\n for (const match of schema.$_terms.matches) {\n for (const key of ['schema', 'peek', 'is', 'then', 'otherwise']) {\n if (match[key] && id === match[key]._flags.id) {\n const obj = schema.clone();\n obj.$_terms.matches[i] = Object.assign({}, match, {\n [key]: replacement\n });\n return obj.$_mutateRebuild();\n }\n }\n\n ++i;\n }\n },\n rebuild: function rebuild(schema) {\n for (const match of schema.$_terms.matches) {\n for (const key of ['schema', 'ref', 'peek', 'is', 'then', 'otherwise']) {\n schema.$_mutateRegister(match[key], {\n family: Ref.toSibling\n });\n } // Flag when an alternative type is an array\n\n\n for (const key of ['schema', 'then', 'otherwise']) {\n if (match[key] && match[key].type === 'array') {\n schema.$_setFlag('_arrayItems', true, {\n clone: false\n });\n break;\n }\n }\n }\n\n return schema;\n },\n // Errors\n messages: {\n 'alternatives.base': '\"{{#label}}\" does not match any of the allowed types',\n 'alternatives.match': '\"{{#label}}\" does not match any of the allowed types',\n 'alternatives.types': '\"{{#label}}\" must be one of {{#types}}'\n }\n});" }, { - "id": 31, + "id": 30, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "name": "../lib/base.js", "index": 23, "index2": 26, - "size": 33168, + "size": 23126, "cacheable": true, "built": true, "optional": false, @@ -7598,8 +7412,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -7607,15 +7421,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/any.js", "name": "../lib/types/any.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 767, - "building": 322, + "factory": 353, + "building": 264, "dependencies": 2 }, "failed": false, @@ -7630,7 +7444,7 @@ "moduleName": "../lib/types/any.js", "type": "cjs require", "userRequest": "../base", - "loc": "5:11-29" + "loc": "5:13-31" } ], "usedExports": true, @@ -7639,15 +7453,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar DeepEqual = require('@hapi/hoek/lib/deepEqual');\n\nvar Merge = require('@hapi/hoek/lib/merge');\n\nvar Cache = require('./cache');\n\nvar Common = require('./common');\n\nvar Compile = require('./compile');\n\nvar Errors = require('./errors');\n\nvar Extend = require('./extend');\n\nvar Manifest = require('./manifest');\n\nvar Messages = require('./messages');\n\nvar Modify = require('./modify');\n\nvar Ref = require('./ref');\n\nvar Validator = require('./validator');\n\nvar Values = require('./values');\n\nvar internals = {};\n\ninternals.Base =\n/*#__PURE__*/\nfunction () {\n function _class(type) {\n _classCallCheck(this, _class);\n\n // Naming: public, _private, $_extension, $_mutate{action}\n this.type = type;\n this._definition = {};\n this._ids = new Modify.Ids();\n this._preferences = null;\n this._refs = new Ref.Manager();\n this._cache = null;\n this._valids = null;\n this._invalids = null;\n this._flags = {};\n this._rules = [];\n this._singleRules = new Map(); // The rule options passed for non-multi rules\n\n this._ruleset = null; // null: use last, false: error, number: start position\n\n this.$_terms = {\n // Hash of arrays of immutable objects (extended by other types)\n alterations: null,\n examples: null,\n externals: null,\n metas: [],\n notes: [],\n tags: []\n };\n } // Manifest\n\n\n _createClass(_class, [{\n key: \"describe\",\n value: function describe() {\n return Manifest.describe(this);\n } // Rules\n\n }, {\n key: \"allow\",\n value: function allow() {\n for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {\n values[_key] = arguments[_key];\n }\n\n Common.verifyFlat(values, 'allow');\n var obj = this.clone();\n\n if (!obj._valids) {\n obj._valids = new Values();\n }\n\n for (var _i = 0, _values = values; _i < _values.length; _i++) {\n var value = _values[_i];\n Assert(value !== undefined, 'Cannot call allow/valid/invalid with undefined');\n\n if (obj._invalids) {\n obj._invalids.remove(value);\n\n if (!obj._invalids.length) {\n obj._invalids = null;\n }\n }\n\n obj._valids.add(value, obj._refs);\n }\n\n return obj;\n }\n }, {\n key: \"alter\",\n value: function alter(targets) {\n Assert(targets && _typeof(targets) === 'object' && !Array.isArray(targets), 'Invalid targets argument');\n Assert(!this._inRuleset(), 'Cannot set alterations inside a ruleset');\n var obj = this.clone();\n obj.$_terms.alterations = obj.$_terms.alterations || [];\n\n for (var target in targets) {\n var adjuster = targets[target];\n Assert(typeof adjuster === 'function', 'Alteration adjuster for', target, 'must be a function');\n obj.$_terms.alterations.push({\n target: target,\n adjuster: adjuster\n });\n }\n\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"cast\",\n value: function cast(to) {\n Assert(to === false || this._definition.cast[to], 'Type', this.type, 'does not support casting to', to);\n return this.$_setFlag('cast', to === false ? undefined : to);\n }\n }, {\n key: \"default\",\n value: function _default(value, options) {\n return this._default('default', value, options);\n }\n }, {\n key: \"description\",\n value: function description(desc) {\n Assert(desc && typeof desc === 'string', 'Description must be a non-empty string');\n return this.$_setFlag('description', desc);\n }\n }, {\n key: \"empty\",\n value: function empty(schema) {\n var obj = this.clone();\n\n if (schema !== undefined) {\n schema = obj.$_compile(schema);\n\n obj._refs.register(schema);\n }\n\n return obj.$_setFlag('empty', schema, {\n clone: false\n });\n }\n }, {\n key: \"error\",\n value: function error(err) {\n Assert(err, 'Missing error');\n Assert(err instanceof Error || typeof err === 'function', 'Must provide a valid Error object or a function');\n return this.$_setFlag('error', err);\n }\n }, {\n key: \"example\",\n value: function example(_example) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(_example !== undefined, 'Missing example');\n Common.assertOptions(options, ['override']);\n return this._inner('examples', _example, {\n single: true,\n override: options.override\n });\n }\n }, {\n key: \"external\",\n value: function external(method) {\n Assert(typeof method === 'function', 'Method must be a function');\n return this._inner('externals', method, {\n single: true\n });\n }\n }, {\n key: \"failover\",\n value: function failover(value, options) {\n return this._default('failover', value, options);\n }\n }, {\n key: \"forbidden\",\n value: function forbidden() {\n return this.presence('forbidden');\n }\n }, {\n key: \"id\",\n value: function id(_id) {\n Assert(_id && typeof _id === 'string', 'id must be a non-empty string');\n Assert(/^[^\\.]+$/.test(_id), 'id cannot contain period character');\n Assert(!this._flags.id, 'Cannot override schema id');\n return this.$_setFlag('id', _id);\n }\n }, {\n key: \"invalid\",\n value: function invalid() {\n for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n values[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(values, 'invalid');\n var obj = this.clone();\n\n if (!obj._invalids) {\n obj._invalids = new Values();\n }\n\n for (var _i2 = 0, _values2 = values; _i2 < _values2.length; _i2++) {\n var value = _values2[_i2];\n Assert(value !== undefined, 'Cannot call allow/valid/invalid with undefined');\n\n if (obj._valids) {\n obj._valids.remove(value);\n\n if (!obj._valids.length) {\n Assert(!obj._flags.only, 'Setting invalid value', value, 'leaves schema rejecting all values due to previous valid rule');\n obj._valids = null;\n }\n }\n\n obj._invalids.add(value, obj._refs);\n }\n\n return obj;\n }\n }, {\n key: \"keep\",\n value: function keep() {\n return this.rule({\n keep: true\n });\n }\n }, {\n key: \"label\",\n value: function label(name) {\n Assert(name && typeof name === 'string', 'Label name must be a non-empty string');\n return this.$_setFlag('label', name);\n }\n }, {\n key: \"meta\",\n value: function meta(_meta) {\n Assert(_meta !== undefined, 'Meta cannot be undefined');\n return this._inner('metas', _meta, {\n single: true\n });\n }\n }, {\n key: \"note\",\n value: function note() {\n for (var _len3 = arguments.length, notes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n notes[_key3] = arguments[_key3];\n }\n\n Assert(notes.length, 'Missing notes');\n\n for (var _i3 = 0, _notes = notes; _i3 < _notes.length; _i3++) {\n var note = _notes[_i3];\n Assert(note && typeof note === 'string', 'Notes must be non-empty strings');\n }\n\n return this._inner('notes', notes);\n }\n }, {\n key: \"only\",\n value: function only() {\n var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof mode === 'boolean', 'Invalid mode:', mode);\n return this.$_setFlag('only', mode);\n }\n }, {\n key: \"optional\",\n value: function optional() {\n return this.presence('optional');\n }\n }, {\n key: \"prefs\",\n value: function prefs(_prefs) {\n Assert(_prefs.context === undefined, 'Cannot override context');\n Assert(_prefs.externals === undefined, 'Cannot override externals');\n Assert(_prefs.warnings === undefined, 'Cannot override warnings');\n Common.checkPreferences(_prefs);\n var obj = this.clone();\n obj._preferences = Common.preferences(obj._preferences, _prefs);\n return obj;\n }\n }, {\n key: \"presence\",\n value: function presence(mode) {\n Assert(['optional', 'required', 'forbidden'].includes(mode), 'Unknown presence mode', mode);\n return this.$_setFlag('presence', mode);\n }\n }, {\n key: \"raw\",\n value: function raw() {\n var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n return this.$_setFlag('result', enabled ? 'raw' : undefined);\n }\n }, {\n key: \"result\",\n value: function result(mode) {\n Assert(['raw', 'strip'].includes(mode), 'Unknown result mode', mode);\n return this.$_setFlag('result', mode);\n }\n }, {\n key: \"required\",\n value: function required() {\n return this.presence('required');\n }\n }, {\n key: \"strict\",\n value: function strict(enabled) {\n var obj = this.clone();\n var convert = enabled === undefined ? false : !enabled;\n obj._preferences = Common.preferences(obj._preferences, {\n convert: convert\n });\n return obj;\n }\n }, {\n key: \"strip\",\n value: function strip() {\n var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n return this.$_setFlag('result', enabled ? 'strip' : undefined);\n }\n }, {\n key: \"tag\",\n value: function tag() {\n for (var _len4 = arguments.length, tags = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n tags[_key4] = arguments[_key4];\n }\n\n Assert(tags.length, 'Missing tags');\n\n for (var _i4 = 0, _tags = tags; _i4 < _tags.length; _i4++) {\n var tag = _tags[_i4];\n Assert(tag && typeof tag === 'string', 'Tags must be non-empty strings');\n }\n\n return this._inner('tags', tags);\n }\n }, {\n key: \"unit\",\n value: function unit(name) {\n Assert(name && typeof name === 'string', 'Unit name must be a non-empty string');\n return this.$_setFlag('unit', name);\n }\n }, {\n key: \"valid\",\n value: function valid() {\n return this.allow.apply(this, arguments).$_setFlag('only', true, {\n clone: false\n });\n }\n }, {\n key: \"when\",\n value: function when(condition, options) {\n var _this = this;\n\n if (Array.isArray(options)) {\n options = {\n switch: options\n };\n }\n\n Common.assertOptions(options, ['is', 'then', 'otherwise', 'switch']);\n Assert(options.then || options.otherwise || options.switch, 'At least one of then, otherwise, or switch is required');\n\n var process = function process(settings) {\n var item = {\n is: settings.is,\n then: settings.then && _this.concat(_this.$_compile(settings.then))\n };\n\n if (settings.otherwise) {\n item.otherwise = _this.concat(_this.$_compile(settings.otherwise));\n }\n\n return item;\n };\n\n var alt = process(options);\n\n if (options.switch) {\n Assert(Array.isArray(options.switch), '\"switch\" must be an array');\n alt.switch = options.switch.map(process);\n var last = alt.switch[alt.switch.length - 1];\n\n if (!alt.otherwise && !last.otherwise) {\n last.otherwise = this;\n }\n } else {\n if (!alt.then) {\n alt.then = this;\n } else if (!alt.otherwise) {\n alt.otherwise = this;\n }\n }\n\n return this._root.alternatives().when(condition, alt);\n } // Helpers\n\n }, {\n key: \"cache\",\n value: function cache(_cache) {\n Assert(!this._inRuleset(), 'Cannot set caching inside a ruleset');\n Assert(!this._cache, 'Cannot override schema cache');\n var obj = this.clone();\n obj._cache = _cache || Cache.provider.provision();\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"clone\",\n value: function clone() {\n var obj = Object.create(Object.getPrototypeOf(this));\n return this._assign(obj);\n }\n }, {\n key: \"concat\",\n value: function concat(source) {\n Assert(Common.isSchema(source), 'Invalid schema object');\n Assert(this.type === 'any' || source.type === 'any' || source.type === this.type, 'Cannot merge type', this.type, 'with another type:', source.type);\n var obj = this.clone();\n\n if (this.type === 'any' && source.type !== 'any') {\n // Change obj to match source type\n var tmpObj = source.clone();\n\n for (var _i5 = 0, _Object$keys = Object.keys(obj); _i5 < _Object$keys.length; _i5++) {\n var key = _Object$keys[_i5];\n\n if (key !== 'type') {\n tmpObj[key] = obj[key];\n }\n }\n\n obj = tmpObj;\n }\n\n obj._ids.concat(source._ids);\n\n obj._preferences = obj._preferences ? Common.preferences(obj._preferences, source._preferences) : source._preferences;\n obj._valids = Values.merge(obj._valids, source._valids, source._invalids);\n obj._invalids = Values.merge(obj._invalids, source._invalids, source._valids);\n\n obj._refs.register(source, Ref.toSibling); // Remove unique rules present in source\n\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n var _loop = function _loop() {\n var name = _step.value;\n\n if (obj._singleRules.has(name)) {\n obj._rules = obj._rules.filter(function (target) {\n return target.name !== name;\n });\n\n obj._singleRules.delete(name);\n }\n };\n\n for (var _iterator = source._singleRules.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n _loop();\n } // Adjust ruleset\n\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n if (source._ruleset !== null) {\n Assert(!obj._inRuleset(), 'Cannot concatenate onto a schema with open ruleset');\n obj._ruleset = source._ruleset === false ? false : source._ruleset + obj._rules.length;\n } // Rules\n\n\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = source._rules[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var test = _step2.value;\n\n if (!source._definition.rules[test.method].multi) {\n obj._singleRules.set(test.name, test.options);\n }\n\n obj._rules.push(test);\n } // Flags\n\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (obj._flags.empty && source._flags.empty) {\n obj._flags.empty = obj._flags.empty.concat(source._flags.empty);\n var flags = Object.assign({}, source._flags);\n delete flags.empty;\n Merge(obj._flags, flags);\n } else if (source._flags.empty) {\n obj._flags.empty = source._flags.empty;\n\n var _flags = Object.assign({}, source._flags);\n\n delete _flags.empty;\n Merge(obj._flags, _flags);\n } else {\n Merge(obj._flags, source._flags);\n } // Terms\n\n\n for (var _key5 in source.$_terms) {\n var terms = source.$_terms[_key5];\n\n if (!terms) {\n if (!obj.$_terms[_key5]) {\n obj.$_terms[_key5] = terms;\n }\n\n continue;\n }\n\n if (!obj.$_terms[_key5]) {\n obj.$_terms[_key5] = terms.slice();\n continue;\n }\n\n obj.$_terms[_key5] = obj.$_terms[_key5].concat(terms);\n }\n\n return obj.$_mutateRebuild();\n }\n }, {\n key: \"extend\",\n value: function extend(options) {\n return Extend.type(this, options);\n }\n }, {\n key: \"extract\",\n value: function extract(path) {\n path = Array.isArray(path) ? path : path.split('.');\n return this._ids.reach(path);\n }\n }, {\n key: \"fork\",\n value: function fork(paths, adjuster) {\n Assert(!this._inRuleset(), 'Cannot fork inside a ruleset');\n var obj = this; // eslint-disable-line consistent-this\n\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = [].concat(paths)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var path = _step3.value;\n path = Array.isArray(path) ? path : path.split('.');\n obj = obj._ids.fork(path, adjuster, obj);\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"message\",\n value: function message(_message) {\n return this.rule({\n message: _message\n });\n }\n }, {\n key: \"rule\",\n value: function rule(options) {\n Common.assertOptions(options, ['keep', 'message', 'warn']);\n Assert(this._ruleset !== false, 'Cannot apply rules to empty ruleset');\n var start = this._ruleset === null ? this._rules.length - 1 : this._ruleset;\n Assert(start >= 0 && start < this._rules.length, 'Cannot apply rules to empty ruleset');\n options = Object.assign({}, options); // Shallow cloned\n\n if (options.message) {\n options.message = Messages.compile(options.message);\n }\n\n var obj = this.clone();\n\n for (var i = start; i < obj._rules.length; ++i) {\n obj._rules[i] = Object.assign({}, obj._rules[i], options);\n }\n\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"tailor\",\n value: function tailor(targets) {\n Assert(!this._inRuleset(), 'Cannot tailor inside a ruleset');\n\n if (!this.$_terms.alterations) {\n return this;\n }\n\n targets = [].concat(targets);\n var obj = this; // eslint-disable-line consistent-this\n\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = this.$_terms.alterations[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var _step4$value = _step4.value,\n target = _step4$value.target,\n adjuster = _step4$value.adjuster;\n\n if (targets.includes(target)) {\n obj = adjuster(obj);\n Assert(Common.isSchema(obj), 'Alteration adjuster for', target, 'failed to return a schema object');\n }\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"validate\",\n value: function validate(value, options) {\n return Validator.entry(value, this, options);\n }\n }, {\n key: \"validateAsync\",\n value: function validateAsync(value, options) {\n return Validator.entryAsync(value, this, options);\n }\n }, {\n key: \"warn\",\n value: function warn() {\n return this.rule({\n warn: true\n });\n } // Extensions\n\n }, {\n key: \"$_addRule\",\n value: function $_addRule(options) {\n // Normalize rule\n if (typeof options === 'string') {\n options = {\n name: options\n };\n }\n\n Assert(options && _typeof(options) === 'object', 'Invalid options');\n Assert(options.name && typeof options.name === 'string', 'Invalid rule name');\n var rule = {\n name: options.name,\n method: options.method || options.name,\n args: options.args,\n resolve: [],\n warn: options.warn,\n options: options\n };\n var definition = this._definition.rules[rule.method];\n Assert(definition, 'Unknown rule', rule.method);\n Assert(!rule.args || Object.keys(rule.args).length === 1 || Object.keys(rule.args).length === this._definition.rules[rule.name].args.length, 'Invalid rule definition for', this.type, rule.name); // Check for unique changes\n\n if (!definition.multi && this._singleRules.has(rule.name) && DeepEqual(rule.options, this._singleRules.get(rule.name))) {\n return this;\n } // Args\n\n\n var obj = this.clone();\n var args = rule.args;\n\n if (args) {\n for (var key in args) {\n var arg = args[key];\n\n if (arg === undefined) {\n delete args[key];\n continue;\n }\n\n if (definition.argsByName) {\n var resolver = definition.argsByName.get(key);\n\n if (resolver.ref) {\n if (Common.isResolvable(arg)) {\n rule.resolve.push(key);\n\n obj._refs.register(arg);\n } else {\n if (resolver.normalize) {\n arg = resolver.normalize(arg);\n rule.args[key] = arg;\n }\n\n Assert(resolver.assert(arg), key, resolver.message, 'or reference');\n }\n }\n }\n\n args[key] = arg;\n }\n } // Unique rules\n\n\n if (!definition.multi) {\n obj._ruleRemove(rule.name, {\n clone: false\n });\n\n obj._singleRules.set(rule.name, rule.options);\n }\n\n if (obj._ruleset === false) {\n obj._ruleset = null;\n }\n\n if (definition.priority) {\n obj._rules.unshift(rule);\n } else {\n obj._rules.push(rule);\n }\n\n return obj;\n }\n }, {\n key: \"$_compile\",\n value: function $_compile(schema, options) {\n return Compile.schema(this._root, schema, options);\n }\n }, {\n key: \"$_createError\",\n value: function $_createError(code, value, local, state, prefs) {\n var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};\n var flags = options.flags !== false ? this._flags : {};\n return new Errors.Report(code, value, local, flags, this._definition.messages, state, prefs);\n }\n }, {\n key: \"$_getFlag\",\n value: function $_getFlag(name) {\n return this._flags[name];\n }\n }, {\n key: \"$_getRule\",\n value: function $_getRule(name) {\n return this._singleRules.get(name);\n }\n }, {\n key: \"$_getRules\",\n value: function $_getRules(name) {\n var rules = [];\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = this._rules[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var test = _step5.value;\n\n if (test.name === name) {\n rules.push(test.options);\n }\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n\n return rules;\n }\n }, {\n key: \"$_mapLabels\",\n value: function $_mapLabels(path) {\n path = Array.isArray(path) ? path : path.split('.');\n return this._ids.labels(path);\n }\n }, {\n key: \"$_match\",\n value: function $_match(value, state, prefs) {\n prefs = Object.assign({}, prefs); // Shallow cloned\n\n prefs.abortEarly = true;\n prefs._externals = false;\n return !Validator.validate(value, this, state, prefs).errors;\n }\n }, {\n key: \"$_mutateRebuild\",\n value: function $_mutateRebuild() {\n if (!this._definition.rebuild) {\n return this;\n }\n\n Assert(!this._inRuleset(), 'Cannot add this rule inside a ruleset');\n\n this._refs.reset();\n\n this._ids.reset();\n\n this._definition.rebuild(this);\n\n this._ruleset = false;\n return this;\n }\n }, {\n key: \"$_mutateRegister\",\n value: function $_mutateRegister(schema) {\n var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n family = _ref.family,\n key = _ref.key;\n\n this._refs.register(schema, family);\n\n this._ids.register(schema, key);\n }\n }, {\n key: \"$_property\",\n value: function $_property(name) {\n return this._definition.properties[name];\n }\n }, {\n key: \"$_reach\",\n value: function $_reach(path) {\n return this._ids.reach(path);\n }\n }, {\n key: \"$_replaceRules\",\n value: function $_replaceRules(name, each) {\n var obj;\n\n for (var i = 0; i < this._rules.length; ++i) {\n var rule = this._rules[i];\n\n if (rule.name !== name) {\n continue;\n }\n\n var override = each(rule);\n\n if (override) {\n override.args = override.options.args;\n obj = obj || this.clone();\n obj._rules[i] = override;\n\n if (obj._singleRules.has(name)) {\n obj._singleRules.set(name, override.options);\n }\n }\n }\n\n if (obj) {\n return obj.$_mutateRebuild();\n }\n\n return this;\n }\n }, {\n key: \"$_rootReferences\",\n value: function $_rootReferences() {\n return this._refs.roots();\n }\n }, {\n key: \"$_setFlag\",\n value: function $_setFlag(name, value) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(!this._inRuleset(), 'Cannot set flag inside a ruleset');\n\n if (DeepEqual(value, this._flags[name])) {\n return this;\n }\n\n var obj = options.clone !== false ? this.clone() : this;\n\n if (value !== undefined) {\n obj._flags[name] = value;\n } else {\n delete obj._flags[name];\n }\n\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"$_validate\",\n value: function $_validate(value, state, prefs) {\n return Validator.validate(value, this, state, prefs);\n } // Internals\n\n }, {\n key: \"_assign\",\n value: function _assign(target) {\n target.type = this.type;\n target._root = this._root;\n target._ids = this._ids.clone();\n target._preferences = this._preferences;\n target._valids = this._valids && this._valids.clone();\n target._invalids = this._invalids && this._invalids.clone();\n target._rules = this._rules.slice();\n target._singleRules = Clone(this._singleRules, {\n shallow: true\n });\n target._ruleset = this._ruleset;\n target._refs = this._refs.clone();\n target._flags = Clone(this._flags);\n target._cache = null;\n target.$_terms = {};\n\n for (var key in this.$_terms) {\n target.$_terms[key] = this.$_terms[key] ? this.$_terms[key].slice() : null;\n }\n\n target.super = {};\n\n for (var override in this.super) {\n target.super[override] = this._super[override].bind(target);\n }\n\n return target;\n }\n }, {\n key: \"_default\",\n value: function _default(flag, value) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Common.assertOptions(options, 'literal');\n Assert(value !== undefined, 'Missing', flag, 'value');\n Assert(typeof value === 'function' || !options.literal, 'Only function value supports literal option');\n\n if (typeof value === 'function' && options.literal) {\n var _value;\n\n value = (_value = {}, _defineProperty(_value, Common.symbols.literal, true), _defineProperty(_value, \"literal\", value), _value);\n }\n\n var obj = this.$_setFlag(flag, value);\n\n obj._refs.register(value);\n\n return obj;\n }\n }, {\n key: \"_inner\",\n value: function _inner(type, values) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(!this._inRuleset(), \"Cannot set \".concat(type, \" inside a ruleset\"));\n var obj = this.clone();\n\n if (!obj.$_terms[type] || options.override) {\n obj.$_terms[type] = [];\n }\n\n if (options.single) {\n obj.$_terms[type].push(values);\n } else {\n var _obj$$_terms$type;\n\n (_obj$$_terms$type = obj.$_terms[type]).push.apply(_obj$$_terms$type, _toConsumableArray(values));\n }\n\n obj._ruleset = false;\n return obj;\n }\n }, {\n key: \"_inRuleset\",\n value: function _inRuleset() {\n return this._ruleset !== null && this._ruleset !== false;\n }\n }, {\n key: \"_ruleRemove\",\n value: function _ruleRemove(name) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!this._singleRules.has(name)) {\n return this;\n }\n\n var obj = options.clone !== false ? this.clone() : this;\n\n obj._singleRules.delete(name);\n\n var filtered = [];\n\n for (var i = 0; i < obj._rules.length; ++i) {\n var test = obj._rules[i];\n\n if (test.name === name && !test.keep) {\n if (obj._inRuleset() && i < obj._ruleset) {\n --obj._ruleset;\n }\n\n continue;\n }\n\n filtered.push(test);\n }\n\n obj._rules = filtered;\n return obj;\n }\n }, {\n key: \"ruleset\",\n get: function get() {\n Assert(!this._inRuleset(), 'Cannot start a new ruleset without closing the previous one');\n var obj = this.clone();\n obj._ruleset = obj._rules.length;\n return obj;\n }\n }, {\n key: \"$\",\n get: function get() {\n return this.ruleset;\n }\n }]);\n\n return _class;\n}();\n\ninternals.Base.prototype.isImmutable = true; // Prevents Hoek from deep cloning schema objects\n\ninternals.Base.prototype[Common.symbols.any] = {\n version: Common.version,\n compile: Compile.compile,\n root: '_root'\n}; // Aliases\n\ninternals.Base.prototype.disallow = internals.Base.prototype.invalids;\ninternals.Base.prototype.equal = internals.Base.prototype.valid;\ninternals.Base.prototype.exist = internals.Base.prototype.required;\ninternals.Base.prototype.not = internals.Base.prototype.invalid;\ninternals.Base.prototype.options = internals.Base.prototype.prefs;\ninternals.Base.prototype.preferences = internals.Base.prototype.prefs;\nmodule.exports = new internals.Base();" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst DeepEqual = require('@hapi/hoek/lib/deepEqual');\n\nconst Merge = require('@hapi/hoek/lib/merge');\n\nconst Cache = require('./cache');\n\nconst Common = require('./common');\n\nconst Compile = require('./compile');\n\nconst Errors = require('./errors');\n\nconst Extend = require('./extend');\n\nconst Manifest = require('./manifest');\n\nconst Messages = require('./messages');\n\nconst Modify = require('./modify');\n\nconst Ref = require('./ref');\n\nconst Validator = require('./validator');\n\nconst Values = require('./values');\n\nconst internals = {};\ninternals.Base = class {\n constructor(type) {\n // Naming: public, _private, $_extension, $_mutate{action}\n this.type = type;\n this._definition = {};\n this._ids = new Modify.Ids();\n this._preferences = null;\n this._refs = new Ref.Manager();\n this._cache = null;\n this._valids = null;\n this._invalids = null;\n this._flags = {};\n this._rules = [];\n this._singleRules = new Map(); // The rule options passed for non-multi rules\n\n this._ruleset = null; // null: use last, false: error, number: start position\n\n this.$_terms = {\n // Hash of arrays of immutable objects (extended by other types)\n alterations: null,\n examples: null,\n externals: null,\n metas: [],\n notes: [],\n tags: []\n };\n } // Manifest\n\n\n describe() {\n return Manifest.describe(this);\n } // Rules\n\n\n allow() {\n for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {\n values[_key] = arguments[_key];\n }\n\n Common.verifyFlat(values, 'allow');\n const obj = this.clone();\n\n if (!obj._valids) {\n obj._valids = new Values();\n }\n\n for (const value of values) {\n Assert(value !== undefined, 'Cannot call allow/valid/invalid with undefined');\n\n if (obj._invalids) {\n obj._invalids.remove(value);\n\n if (!obj._invalids.length) {\n obj._invalids = null;\n }\n }\n\n obj._valids.add(value, obj._refs);\n }\n\n return obj;\n }\n\n alter(targets) {\n Assert(targets && typeof targets === 'object' && !Array.isArray(targets), 'Invalid targets argument');\n Assert(!this._inRuleset(), 'Cannot set alterations inside a ruleset');\n const obj = this.clone();\n obj.$_terms.alterations = obj.$_terms.alterations || [];\n\n for (const target in targets) {\n const adjuster = targets[target];\n Assert(typeof adjuster === 'function', 'Alteration adjuster for', target, 'must be a function');\n obj.$_terms.alterations.push({\n target,\n adjuster\n });\n }\n\n obj._ruleset = false;\n return obj;\n }\n\n cast(to) {\n Assert(to === false || this._definition.cast[to], 'Type', this.type, 'does not support casting to', to);\n return this.$_setFlag('cast', to === false ? undefined : to);\n }\n\n default(value, options) {\n return this._default('default', value, options);\n }\n\n description(desc) {\n Assert(desc && typeof desc === 'string', 'Description must be a non-empty string');\n return this.$_setFlag('description', desc);\n }\n\n empty(schema) {\n const obj = this.clone();\n\n if (schema !== undefined) {\n schema = obj.$_compile(schema);\n\n obj._refs.register(schema);\n }\n\n return obj.$_setFlag('empty', schema, {\n clone: false\n });\n }\n\n error(err) {\n Assert(err, 'Missing error');\n Assert(err instanceof Error || typeof err === 'function', 'Must provide a valid Error object or a function');\n return this.$_setFlag('error', err);\n }\n\n example(example) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(example !== undefined, 'Missing example');\n Common.assertOptions(options, ['override']);\n return this._inner('examples', example, {\n single: true,\n override: options.override\n });\n }\n\n external(method) {\n Assert(typeof method === 'function', 'Method must be a function');\n return this._inner('externals', method, {\n single: true\n });\n }\n\n failover(value, options) {\n return this._default('failover', value, options);\n }\n\n forbidden() {\n return this.presence('forbidden');\n }\n\n id(id) {\n Assert(id && typeof id === 'string', 'id must be a non-empty string');\n Assert(/^[^\\.]+$/.test(id), 'id cannot contain period character');\n Assert(!this._flags.id, 'Cannot override schema id');\n return this.$_setFlag('id', id);\n }\n\n invalid() {\n for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n values[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(values, 'invalid');\n const obj = this.clone();\n\n if (!obj._invalids) {\n obj._invalids = new Values();\n }\n\n for (const value of values) {\n Assert(value !== undefined, 'Cannot call allow/valid/invalid with undefined');\n\n if (obj._valids) {\n obj._valids.remove(value);\n\n if (!obj._valids.length) {\n Assert(!obj._flags.only, 'Setting invalid value', value, 'leaves schema rejecting all values due to previous valid rule');\n obj._valids = null;\n }\n }\n\n obj._invalids.add(value, obj._refs);\n }\n\n return obj;\n }\n\n keep() {\n return this.rule({\n keep: true\n });\n }\n\n label(name) {\n Assert(name && typeof name === 'string', 'Label name must be a non-empty string');\n return this.$_setFlag('label', name);\n }\n\n meta(meta) {\n Assert(meta !== undefined, 'Meta cannot be undefined');\n return this._inner('metas', meta, {\n single: true\n });\n }\n\n note() {\n for (var _len3 = arguments.length, notes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n notes[_key3] = arguments[_key3];\n }\n\n Assert(notes.length, 'Missing notes');\n\n for (const note of notes) {\n Assert(note && typeof note === 'string', 'Notes must be non-empty strings');\n }\n\n return this._inner('notes', notes);\n }\n\n only() {\n let mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof mode === 'boolean', 'Invalid mode:', mode);\n return this.$_setFlag('only', mode);\n }\n\n optional() {\n return this.presence('optional');\n }\n\n prefs(prefs) {\n Assert(prefs.context === undefined, 'Cannot override context');\n Assert(prefs.externals === undefined, 'Cannot override externals');\n Assert(prefs.warnings === undefined, 'Cannot override warnings');\n Common.checkPreferences(prefs);\n const obj = this.clone();\n obj._preferences = Common.preferences(obj._preferences, prefs);\n return obj;\n }\n\n presence(mode) {\n Assert(['optional', 'required', 'forbidden'].includes(mode), 'Unknown presence mode', mode);\n return this.$_setFlag('presence', mode);\n }\n\n raw() {\n let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n return this.$_setFlag('result', enabled ? 'raw' : undefined);\n }\n\n result(mode) {\n Assert(['raw', 'strip'].includes(mode), 'Unknown result mode', mode);\n return this.$_setFlag('result', mode);\n }\n\n required() {\n return this.presence('required');\n }\n\n strict(enabled) {\n const obj = this.clone();\n const convert = enabled === undefined ? false : !enabled;\n obj._preferences = Common.preferences(obj._preferences, {\n convert\n });\n return obj;\n }\n\n strip() {\n let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n return this.$_setFlag('result', enabled ? 'strip' : undefined);\n }\n\n tag() {\n for (var _len4 = arguments.length, tags = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n tags[_key4] = arguments[_key4];\n }\n\n Assert(tags.length, 'Missing tags');\n\n for (const tag of tags) {\n Assert(tag && typeof tag === 'string', 'Tags must be non-empty strings');\n }\n\n return this._inner('tags', tags);\n }\n\n unit(name) {\n Assert(name && typeof name === 'string', 'Unit name must be a non-empty string');\n return this.$_setFlag('unit', name);\n }\n\n valid() {\n return this.allow(...arguments).$_setFlag('only', true, {\n clone: false\n });\n }\n\n when(condition, options) {\n if (Array.isArray(options)) {\n options = {\n switch: options\n };\n }\n\n Common.assertOptions(options, ['is', 'then', 'otherwise', 'switch']);\n Assert(options.then || options.otherwise || options.switch, 'At least one of then, otherwise, or switch is required');\n\n const process = settings => {\n const item = {\n is: settings.is,\n then: settings.then && this.concat(this.$_compile(settings.then))\n };\n\n if (settings.otherwise) {\n item.otherwise = this.concat(this.$_compile(settings.otherwise));\n }\n\n return item;\n };\n\n const alt = process(options);\n\n if (options.switch) {\n Assert(Array.isArray(options.switch), '\"switch\" must be an array');\n alt.switch = options.switch.map(process);\n const last = alt.switch[alt.switch.length - 1];\n\n if (!alt.otherwise && !last.otherwise) {\n last.otherwise = this;\n }\n } else {\n if (!alt.then) {\n alt.then = this;\n } else if (!alt.otherwise) {\n alt.otherwise = this;\n }\n }\n\n return this._root.alternatives().when(condition, alt);\n } // Helpers\n\n\n cache(cache) {\n Assert(!this._inRuleset(), 'Cannot set caching inside a ruleset');\n Assert(!this._cache, 'Cannot override schema cache');\n const obj = this.clone();\n obj._cache = cache || Cache.provider.provision();\n obj._ruleset = false;\n return obj;\n }\n\n clone() {\n const obj = Object.create(Object.getPrototypeOf(this));\n return this._assign(obj);\n }\n\n concat(source) {\n Assert(Common.isSchema(source), 'Invalid schema object');\n Assert(this.type === 'any' || source.type === 'any' || source.type === this.type, 'Cannot merge type', this.type, 'with another type:', source.type);\n let obj = this.clone();\n\n if (this.type === 'any' && source.type !== 'any') {\n // Change obj to match source type\n const tmpObj = source.clone();\n\n for (const key of Object.keys(obj)) {\n if (key !== 'type') {\n tmpObj[key] = obj[key];\n }\n }\n\n obj = tmpObj;\n }\n\n obj._ids.concat(source._ids);\n\n obj._preferences = obj._preferences ? Common.preferences(obj._preferences, source._preferences) : source._preferences;\n obj._valids = Values.merge(obj._valids, source._valids, source._invalids);\n obj._invalids = Values.merge(obj._invalids, source._invalids, source._valids);\n\n obj._refs.register(source, Ref.toSibling); // Remove unique rules present in source\n\n\n for (const name of source._singleRules.keys()) {\n if (obj._singleRules.has(name)) {\n obj._rules = obj._rules.filter(target => target.name !== name);\n\n obj._singleRules.delete(name);\n }\n } // Adjust ruleset\n\n\n if (source._ruleset !== null) {\n Assert(!obj._inRuleset(), 'Cannot concatenate onto a schema with open ruleset');\n obj._ruleset = source._ruleset === false ? false : source._ruleset + obj._rules.length;\n } // Rules\n\n\n for (const test of source._rules) {\n if (!source._definition.rules[test.method].multi) {\n obj._singleRules.set(test.name, test.options);\n }\n\n obj._rules.push(test);\n } // Flags\n\n\n if (obj._flags.empty && source._flags.empty) {\n obj._flags.empty = obj._flags.empty.concat(source._flags.empty);\n const flags = Object.assign({}, source._flags);\n delete flags.empty;\n Merge(obj._flags, flags);\n } else if (source._flags.empty) {\n obj._flags.empty = source._flags.empty;\n const flags = Object.assign({}, source._flags);\n delete flags.empty;\n Merge(obj._flags, flags);\n } else {\n Merge(obj._flags, source._flags);\n } // Terms\n\n\n for (const key in source.$_terms) {\n const terms = source.$_terms[key];\n\n if (!terms) {\n if (!obj.$_terms[key]) {\n obj.$_terms[key] = terms;\n }\n\n continue;\n }\n\n if (!obj.$_terms[key]) {\n obj.$_terms[key] = terms.slice();\n continue;\n }\n\n obj.$_terms[key] = obj.$_terms[key].concat(terms);\n }\n\n return obj.$_mutateRebuild();\n }\n\n extend(options) {\n return Extend.type(this, options);\n }\n\n extract(path) {\n path = Array.isArray(path) ? path : path.split('.');\n return this._ids.reach(path);\n }\n\n fork(paths, adjuster) {\n Assert(!this._inRuleset(), 'Cannot fork inside a ruleset');\n let obj = this; // eslint-disable-line consistent-this\n\n for (let path of [].concat(paths)) {\n path = Array.isArray(path) ? path : path.split('.');\n obj = obj._ids.fork(path, adjuster, obj);\n }\n\n obj._ruleset = false;\n return obj;\n }\n\n message(message) {\n return this.rule({\n message\n });\n }\n\n rule(options) {\n Common.assertOptions(options, ['keep', 'message', 'warn']);\n Assert(this._ruleset !== false, 'Cannot apply rules to empty ruleset');\n const start = this._ruleset === null ? this._rules.length - 1 : this._ruleset;\n Assert(start >= 0 && start < this._rules.length, 'Cannot apply rules to empty ruleset');\n options = Object.assign({}, options); // Shallow cloned\n\n if (options.message) {\n options.message = Messages.compile(options.message);\n }\n\n const obj = this.clone();\n\n for (let i = start; i < obj._rules.length; ++i) {\n obj._rules[i] = Object.assign({}, obj._rules[i], options);\n }\n\n obj._ruleset = false;\n return obj;\n }\n\n get ruleset() {\n Assert(!this._inRuleset(), 'Cannot start a new ruleset without closing the previous one');\n const obj = this.clone();\n obj._ruleset = obj._rules.length;\n return obj;\n }\n\n get $() {\n return this.ruleset;\n }\n\n tailor(targets) {\n Assert(!this._inRuleset(), 'Cannot tailor inside a ruleset');\n\n if (!this.$_terms.alterations) {\n return this;\n }\n\n targets = [].concat(targets);\n let obj = this; // eslint-disable-line consistent-this\n\n for (const _ref of this.$_terms.alterations) {\n const {\n target,\n adjuster\n } = _ref;\n\n if (targets.includes(target)) {\n obj = adjuster(obj);\n Assert(Common.isSchema(obj), 'Alteration adjuster for', target, 'failed to return a schema object');\n }\n }\n\n obj._ruleset = false;\n return obj;\n }\n\n validate(value, options) {\n return Validator.entry(value, this, options);\n }\n\n validateAsync(value, options) {\n return Validator.entryAsync(value, this, options);\n }\n\n warn() {\n return this.rule({\n warn: true\n });\n } // Extensions\n\n\n $_addRule(options) {\n // Normalize rule\n if (typeof options === 'string') {\n options = {\n name: options\n };\n }\n\n Assert(options && typeof options === 'object', 'Invalid options');\n Assert(options.name && typeof options.name === 'string', 'Invalid rule name');\n const rule = {\n name: options.name,\n method: options.method || options.name,\n args: options.args,\n resolve: [],\n warn: options.warn,\n options\n };\n const definition = this._definition.rules[rule.method];\n Assert(definition, 'Unknown rule', rule.method);\n Assert(!rule.args || Object.keys(rule.args).length === 1 || Object.keys(rule.args).length === this._definition.rules[rule.name].args.length, 'Invalid rule definition for', this.type, rule.name); // Check for unique changes\n\n if (!definition.multi && this._singleRules.has(rule.name) && DeepEqual(rule.options, this._singleRules.get(rule.name))) {\n return this;\n } // Args\n\n\n const obj = this.clone();\n const args = rule.args;\n\n if (args) {\n for (const key in args) {\n let arg = args[key];\n\n if (arg === undefined) {\n delete args[key];\n continue;\n }\n\n if (definition.argsByName) {\n const resolver = definition.argsByName.get(key);\n\n if (resolver.ref) {\n if (Common.isResolvable(arg)) {\n rule.resolve.push(key);\n\n obj._refs.register(arg);\n } else {\n if (resolver.normalize) {\n arg = resolver.normalize(arg);\n rule.args[key] = arg;\n }\n\n Assert(resolver.assert(arg), key, resolver.message, 'or reference');\n }\n }\n }\n\n args[key] = arg;\n }\n } // Unique rules\n\n\n if (!definition.multi) {\n obj._ruleRemove(rule.name, {\n clone: false\n });\n\n obj._singleRules.set(rule.name, rule.options);\n }\n\n if (obj._ruleset === false) {\n obj._ruleset = null;\n }\n\n if (definition.priority) {\n obj._rules.unshift(rule);\n } else {\n obj._rules.push(rule);\n }\n\n return obj;\n }\n\n $_compile(schema, options) {\n return Compile.schema(this._root, schema, options);\n }\n\n $_createError(code, value, local, state, prefs) {\n let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};\n const flags = options.flags !== false ? this._flags : {};\n return new Errors.Report(code, value, local, flags, this._definition.messages, state, prefs);\n }\n\n $_getFlag(name) {\n return this._flags[name];\n }\n\n $_getRule(name) {\n return this._singleRules.get(name);\n }\n\n $_getRules(name) {\n const rules = [];\n\n for (const test of this._rules) {\n if (test.name === name) {\n rules.push(test.options);\n }\n }\n\n return rules;\n }\n\n $_mapLabels(path) {\n path = Array.isArray(path) ? path : path.split('.');\n return this._ids.labels(path);\n }\n\n $_match(value, state, prefs) {\n prefs = Object.assign({}, prefs); // Shallow cloned\n\n prefs.abortEarly = true;\n prefs._externals = false;\n return !Validator.validate(value, this, state, prefs).errors;\n }\n\n $_mutateRebuild() {\n if (!this._definition.rebuild) {\n return this;\n }\n\n Assert(!this._inRuleset(), 'Cannot add this rule inside a ruleset');\n\n this._refs.reset();\n\n this._ids.reset();\n\n this._definition.rebuild(this);\n\n this._ruleset = false;\n return this;\n }\n\n $_mutateRegister(schema) {\n let {\n family,\n key\n } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n this._refs.register(schema, family);\n\n this._ids.register(schema, key);\n }\n\n $_property(name) {\n return this._definition.properties[name];\n }\n\n $_reach(path) {\n return this._ids.reach(path);\n }\n\n $_replaceRules(name, each) {\n let obj;\n\n for (let i = 0; i < this._rules.length; ++i) {\n const rule = this._rules[i];\n\n if (rule.name !== name) {\n continue;\n }\n\n const override = each(rule);\n\n if (override) {\n override.args = override.options.args;\n obj = obj || this.clone();\n obj._rules[i] = override;\n\n if (obj._singleRules.has(name)) {\n obj._singleRules.set(name, override.options);\n }\n }\n }\n\n if (obj) {\n return obj.$_mutateRebuild();\n }\n\n return this;\n }\n\n $_rootReferences() {\n return this._refs.roots();\n }\n\n $_setFlag(name, value) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(!this._inRuleset(), 'Cannot set flag inside a ruleset');\n\n if (DeepEqual(value, this._flags[name])) {\n return this;\n }\n\n const obj = options.clone !== false ? this.clone() : this;\n\n if (value !== undefined) {\n obj._flags[name] = value;\n } else {\n delete obj._flags[name];\n }\n\n obj._ruleset = false;\n return obj;\n }\n\n $_validate(value, state, prefs) {\n return Validator.validate(value, this, state, prefs);\n } // Internals\n\n\n _assign(target) {\n target.type = this.type;\n target._root = this._root;\n target._ids = this._ids.clone();\n target._preferences = this._preferences;\n target._valids = this._valids && this._valids.clone();\n target._invalids = this._invalids && this._invalids.clone();\n target._rules = this._rules.slice();\n target._singleRules = Clone(this._singleRules, {\n shallow: true\n });\n target._ruleset = this._ruleset;\n target._refs = this._refs.clone();\n target._flags = Clone(this._flags);\n target._cache = null;\n target.$_terms = {};\n\n for (const key in this.$_terms) {\n target.$_terms[key] = this.$_terms[key] ? this.$_terms[key].slice() : null;\n }\n\n target.super = {};\n\n for (const override in this.super) {\n target.super[override] = this._super[override].bind(target);\n }\n\n return target;\n }\n\n _default(flag, value) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Common.assertOptions(options, 'literal');\n Assert(value !== undefined, 'Missing', flag, 'value');\n Assert(typeof value === 'function' || !options.literal, 'Only function value supports literal option');\n\n if (typeof value === 'function' && options.literal) {\n value = {\n [Common.symbols.literal]: true,\n literal: value\n };\n }\n\n const obj = this.$_setFlag(flag, value);\n\n obj._refs.register(value);\n\n return obj;\n }\n\n _inner(type, values) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(!this._inRuleset(), \"Cannot set \".concat(type, \" inside a ruleset\"));\n const obj = this.clone();\n\n if (!obj.$_terms[type] || options.override) {\n obj.$_terms[type] = [];\n }\n\n if (options.single) {\n obj.$_terms[type].push(values);\n } else {\n obj.$_terms[type].push(...values);\n }\n\n obj._ruleset = false;\n return obj;\n }\n\n _inRuleset() {\n return this._ruleset !== null && this._ruleset !== false;\n }\n\n _ruleRemove(name) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!this._singleRules.has(name)) {\n return this;\n }\n\n const obj = options.clone !== false ? this.clone() : this;\n\n obj._singleRules.delete(name);\n\n const filtered = [];\n\n for (let i = 0; i < obj._rules.length; ++i) {\n const test = obj._rules[i];\n\n if (test.name === name && !test.keep) {\n if (obj._inRuleset() && i < obj._ruleset) {\n --obj._ruleset;\n }\n\n continue;\n }\n\n filtered.push(test);\n }\n\n obj._rules = filtered;\n return obj;\n }\n\n};\ninternals.Base.prototype.isImmutable = true; // Prevents Hoek from deep cloning schema objects\n\ninternals.Base.prototype[Common.symbols.any] = {\n version: Common.version,\n compile: Compile.compile,\n root: '_root'\n}; // Aliases\n\ninternals.Base.prototype.disallow = internals.Base.prototype.invalids;\ninternals.Base.prototype.equal = internals.Base.prototype.valid;\ninternals.Base.prototype.exist = internals.Base.prototype.required;\ninternals.Base.prototype.not = internals.Base.prototype.invalid;\ninternals.Base.prototype.options = internals.Base.prototype.prefs;\ninternals.Base.prototype.preferences = internals.Base.prototype.prefs;\nmodule.exports = new internals.Base();" }, { - "id": 32, + "id": 31, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/extend.js", "name": "../lib/extend.js", "index": 26, "index2": 22, - "size": 6758, + "size": 5055, "cacheable": true, "built": true, "optional": false, @@ -7656,7 +7470,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", - "issuerId": 31, + "issuerId": 30, "issuerName": "../lib/base.js", "issuerPath": [ { @@ -7664,8 +7478,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -7673,25 +7487,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/any.js", "name": "../lib/types/any.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 31, + "id": 30, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "name": "../lib/base.js", "profile": { - "factory": 767, - "building": 322, + "factory": 353, + "building": 264, "dependencies": 2 } } ], "profile": { - "factory": 169, - "building": 279, + "factory": 101, + "building": 141, "dependencies": 0 }, "failed": false, @@ -7700,13 +7514,13 @@ "assets": [], "reasons": [ { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./extend", - "loc": "37:13-32" + "loc": "19:15-34" } ], "usedExports": true, @@ -7715,15 +7529,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Messages = require('./messages');\n\nvar internals = {};\n\nexports.type = function (from, options) {\n var base = Object.getPrototypeOf(from);\n var prototype = Clone(base);\n\n var schema = from._assign(Object.create(prototype));\n\n var def = Object.assign({}, options); // Shallow cloned\n\n prototype._definition = def;\n var parent = base._definition || {};\n def.messages = Messages.merge(parent.messages, def.messages);\n def.properties = Object.assign({}, parent.properties, def.properties); // Initialize\n\n schema.type = def.type;\n\n if (def.initialize) {\n def.initialize(schema);\n }\n\n if (!def.args) {\n def.args = parent.args;\n } // Validate\n\n\n def.validate = internals.validate(def.validate, parent.validate); // Coerce\n\n if (def.coerce) {\n if (typeof def.coerce === 'function') {\n def.coerce = {\n method: def.coerce\n };\n }\n\n if (def.coerce.from && !Array.isArray(def.coerce.from)) {\n def.coerce = {\n method: def.coerce.method,\n from: [].concat(def.coerce.from)\n };\n }\n }\n\n def.coerce = internals.coerce(def.coerce, parent.coerce); // Rules\n\n var rules = Object.assign({}, parent.rules);\n\n if (def.rules) {\n var _loop = function _loop(name) {\n var rule = def.rules[name];\n Assert(_typeof(rule) === 'object', 'Invalid rule definition for', def.type, name);\n var method = rule.method;\n\n if (method === undefined) {\n method = function method() {\n return this.$_addRule(name);\n };\n }\n\n if (method) {\n Assert(!prototype[name], 'Rule conflict in', def.type, name);\n prototype[name] = method;\n }\n\n Assert(!rules[name], 'Rule conflict in', def.type, name);\n rules[name] = rule;\n\n if (rule.alias) {\n var aliases = [].concat(rule.alias);\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = aliases[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var alias = _step.value;\n prototype[alias] = rule.method;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n\n if (rule.args) {\n rule.argsByName = new Map();\n rule.args = rule.args.map(function (arg) {\n if (typeof arg === 'string') {\n arg = {\n name: arg\n };\n }\n\n Assert(!rule.argsByName.has(arg.name), 'Duplicated argument name', arg.name);\n rule.argsByName.set(arg.name, arg);\n return arg;\n });\n }\n };\n\n for (var name in def.rules) {\n _loop(name);\n }\n }\n\n def.rules = rules; // Overrides\n\n if (def.overrides) {\n prototype._super = base;\n schema.super = {};\n\n for (var override in def.overrides) {\n Assert(base[override], 'Cannot override missing', override);\n schema.super[override] = base[override].bind(schema);\n }\n\n Object.assign(prototype, def.overrides);\n } // Casts\n\n\n def.cast = Object.assign({}, parent.cast, def.cast); // Manifest\n\n def.build = internals.build(def.build, parent.build); // Modify\n\n def.modify = internals.modify(def.modify, parent.modify);\n def.rebuild = internals.rebuild(def.rebuild, parent.rebuild);\n schema._ids._reachable = !!def.modify;\n return schema;\n}; // Helpers\n\n\ninternals.build = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (obj, desc) {\n return child(parent(obj, desc), desc);\n };\n};\n\ninternals.coerce = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return {\n from: child.from && parent.from ? _toConsumableArray(new Set([].concat(_toConsumableArray(child.from), _toConsumableArray(parent.from)))) : null,\n method: function method(schema, value, helpers) {\n var coerced;\n\n if (!parent.from || parent.from.includes(_typeof(value))) {\n coerced = parent.method(schema, value, helpers);\n\n if (coerced) {\n if (coerced.errors) {\n return coerced;\n }\n\n value = coerced.value;\n }\n }\n\n if (value !== undefined && (!child.from || child.from.includes(_typeof(value)))) {\n var own = child.method(schema, value, helpers);\n\n if (own) {\n if (own.errors) {\n return own;\n }\n\n coerced = own;\n }\n }\n\n return coerced;\n }\n };\n};\n\ninternals.modify = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (obj, id, schema) {\n var found = parent(obj, id, schema);\n\n if (found) {\n return found;\n }\n\n return child(obj, id, schema);\n };\n};\n\ninternals.rebuild = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (schema) {\n parent(schema);\n child(schema);\n };\n};\n\ninternals.validate = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (schema, value, helpers) {\n var result = parent(schema, value, helpers);\n\n if (result) {\n if (result.errors && (!Array.isArray(result.errors) || result.errors.length)) {\n return result;\n }\n\n value = result.value;\n }\n\n return child(schema, value, helpers);\n };\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Messages = require('./messages');\n\nconst internals = {};\n\nexports.type = function (from, options) {\n const base = Object.getPrototypeOf(from);\n const prototype = Clone(base);\n\n const schema = from._assign(Object.create(prototype));\n\n const def = Object.assign({}, options); // Shallow cloned\n\n prototype._definition = def;\n const parent = base._definition || {};\n def.messages = Messages.merge(parent.messages, def.messages);\n def.properties = Object.assign({}, parent.properties, def.properties); // Initialize\n\n schema.type = def.type;\n\n if (def.initialize) {\n def.initialize(schema);\n }\n\n if (!def.args) {\n def.args = parent.args;\n } // Validate\n\n\n def.validate = internals.validate(def.validate, parent.validate); // Coerce\n\n if (def.coerce) {\n if (typeof def.coerce === 'function') {\n def.coerce = {\n method: def.coerce\n };\n }\n\n if (def.coerce.from && !Array.isArray(def.coerce.from)) {\n def.coerce = {\n method: def.coerce.method,\n from: [].concat(def.coerce.from)\n };\n }\n }\n\n def.coerce = internals.coerce(def.coerce, parent.coerce); // Rules\n\n const rules = Object.assign({}, parent.rules);\n\n if (def.rules) {\n for (const name in def.rules) {\n const rule = def.rules[name];\n Assert(typeof rule === 'object', 'Invalid rule definition for', def.type, name);\n let method = rule.method;\n\n if (method === undefined) {\n method = function method() {\n return this.$_addRule(name);\n };\n }\n\n if (method) {\n Assert(!prototype[name], 'Rule conflict in', def.type, name);\n prototype[name] = method;\n }\n\n Assert(!rules[name], 'Rule conflict in', def.type, name);\n rules[name] = rule;\n\n if (rule.alias) {\n const aliases = [].concat(rule.alias);\n\n for (const alias of aliases) {\n prototype[alias] = rule.method;\n }\n }\n\n if (rule.args) {\n rule.argsByName = new Map();\n rule.args = rule.args.map(arg => {\n if (typeof arg === 'string') {\n arg = {\n name: arg\n };\n }\n\n Assert(!rule.argsByName.has(arg.name), 'Duplicated argument name', arg.name);\n rule.argsByName.set(arg.name, arg);\n return arg;\n });\n }\n }\n }\n\n def.rules = rules; // Overrides\n\n if (def.overrides) {\n prototype._super = base;\n schema.super = {};\n\n for (const override in def.overrides) {\n Assert(base[override], 'Cannot override missing', override);\n schema.super[override] = base[override].bind(schema);\n }\n\n Object.assign(prototype, def.overrides);\n } // Casts\n\n\n def.cast = Object.assign({}, parent.cast, def.cast); // Manifest\n\n def.build = internals.build(def.build, parent.build); // Modify\n\n def.modify = internals.modify(def.modify, parent.modify);\n def.rebuild = internals.rebuild(def.rebuild, parent.rebuild);\n schema._ids._reachable = !!def.modify;\n return schema;\n}; // Helpers\n\n\ninternals.build = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (obj, desc) {\n return child(parent(obj, desc), desc);\n };\n};\n\ninternals.coerce = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return {\n from: child.from && parent.from ? [...new Set([...child.from, ...parent.from])] : null,\n method: function method(schema, value, helpers) {\n let coerced;\n\n if (!parent.from || parent.from.includes(typeof value)) {\n coerced = parent.method(schema, value, helpers);\n\n if (coerced) {\n if (coerced.errors) {\n return coerced;\n }\n\n value = coerced.value;\n }\n }\n\n if (value !== undefined && (!child.from || child.from.includes(typeof value))) {\n const own = child.method(schema, value, helpers);\n\n if (own) {\n if (own.errors) {\n return own;\n }\n\n coerced = own;\n }\n }\n\n return coerced;\n }\n };\n};\n\ninternals.modify = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (obj, id, schema) {\n const found = parent(obj, id, schema);\n\n if (found) {\n return found;\n }\n\n return child(obj, id, schema);\n };\n};\n\ninternals.rebuild = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (schema) {\n parent(schema);\n child(schema);\n };\n};\n\ninternals.validate = function (child, parent) {\n if (!child || !parent) {\n return child || parent;\n }\n\n return function (schema, value, helpers) {\n const result = parent(schema, value, helpers);\n\n if (result) {\n if (result.errors && (!Array.isArray(result.errors) || result.errors.length)) {\n return result;\n }\n\n value = result.value;\n }\n\n return child(schema, value, helpers);\n };\n};" }, { - "id": 33, + "id": 32, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/modify.js", "name": "../lib/modify.js", "index": 27, "index2": 23, - "size": 7000, + "size": 3527, "cacheable": true, "built": true, "optional": false, @@ -7732,7 +7546,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", - "issuerId": 31, + "issuerId": 30, "issuerName": "../lib/base.js", "issuerPath": [ { @@ -7740,8 +7554,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -7749,25 +7563,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/any.js", "name": "../lib/types/any.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 31, + "id": 30, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "name": "../lib/base.js", "profile": { - "factory": 767, - "building": 322, + "factory": 353, + "building": 264, "dependencies": 2 } } ], "profile": { - "factory": 169, - "building": 279, + "factory": 101, + "building": 141, "dependencies": 0 }, "failed": false, @@ -7776,13 +7590,13 @@ "assets": [], "reasons": [ { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./modify", - "loc": "43:13-32" + "loc": "25:15-34" } ], "usedExports": true, @@ -7791,15 +7605,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Common = require('./common');\n\nvar internals = {};\n\nexports.Ids = internals.Ids =\n/*#__PURE__*/\nfunction () {\n function _class() {\n _classCallCheck(this, _class);\n\n this._reachable = false;\n this._map = new Map();\n this._schemaChain = false;\n }\n\n _createClass(_class, [{\n key: \"clone\",\n value: function clone() {\n var clone = new internals.Ids();\n clone._map = new Map(this._map);\n clone._schemaChain = this._schemaChain;\n clone._reachable = this._reachable;\n return clone;\n }\n }, {\n key: \"concat\",\n value: function concat(source) {\n this._reachable = source._reachable;\n\n if (source._schemaChain) {\n this._schemaChain = true;\n }\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = source._map.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var key = _step.value;\n\n this._map.set(key, source._map.get(key));\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n }, {\n key: \"fork\",\n value: function fork(path, adjuster, root) {\n var chain = this._collect(path);\n\n chain.push({\n schema: root\n });\n var tail = chain.shift();\n var adjusted = {\n id: tail.id,\n schema: adjuster(tail.schema)\n };\n Assert(Common.isSchema(adjusted.schema), 'adjuster function failed to return a joi schema type');\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = chain[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var node = _step2.value;\n var def = node.schema._definition;\n adjusted = {\n id: node.id,\n schema: def.modify(node.schema, adjusted.id, adjusted.schema)\n };\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return adjusted.schema;\n }\n }, {\n key: \"labels\",\n value: function labels(path) {\n var behind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n Assert(this._reachable, 'Schema type is not reachable');\n var current = path[0];\n\n var node = this._map.get(current);\n\n if (!node) {\n return [].concat(_toConsumableArray(behind), _toConsumableArray(path)).join('.');\n }\n\n var forward = path.slice(1);\n behind = [].concat(_toConsumableArray(behind), [node.schema._flags.label || current]);\n\n if (!forward.length) {\n return behind.join('.');\n }\n\n return node.schema._ids.labels(forward, behind);\n }\n }, {\n key: \"reach\",\n value: function reach(path) {\n var behind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n Assert(this._reachable, 'Schema type is not reachable');\n var current = path[0];\n\n var node = this._map.get(current);\n\n Assert(node, 'Schema does not contain path', [].concat(_toConsumableArray(behind), _toConsumableArray(path)).join('.'));\n var forward = path.slice(1);\n\n if (!forward.length) {\n return node.schema;\n }\n\n return node.schema._ids.reach(forward, [].concat(_toConsumableArray(behind), [current]));\n }\n }, {\n key: \"register\",\n value: function register(schema, key) {\n if (!schema || !Common.isSchema(schema)) {\n return;\n }\n\n if (schema._definition.properties.schemaChain || schema._ids._schemaChain) {\n this._schemaChain = true;\n }\n\n var id = schema._flags.id || key;\n\n if (!id) {\n return;\n }\n\n Assert(!this._map.has(id), 'Schema already contains id', id);\n\n this._map.set(id, {\n schema: schema,\n key: key,\n id: id\n });\n }\n }, {\n key: \"reset\",\n value: function reset() {\n this._map = new Map();\n this._schemaChain = false;\n }\n }, {\n key: \"_collect\",\n value: function _collect(path) {\n var behind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var nodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n Assert(this._reachable, 'Schema type is not reachable');\n var current = path[0];\n\n var node = this._map.get(current);\n\n Assert(node, 'Schema does not contain path', [].concat(_toConsumableArray(behind), _toConsumableArray(path)).join('.'));\n nodes = [node].concat(_toConsumableArray(nodes));\n var forward = path.slice(1);\n\n if (!forward.length) {\n return nodes;\n }\n\n Assert(node.schema._definition.modify, 'Schema node', [].concat(_toConsumableArray(behind), _toConsumableArray(path)).join('.'), 'does not support manipulation');\n return node.schema._ids._collect(forward, [].concat(_toConsumableArray(behind), [current]), nodes);\n }\n }]);\n\n return _class;\n}();" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Common = require('./common');\n\nconst internals = {};\nexports.Ids = internals.Ids = class {\n constructor() {\n this._reachable = false;\n this._map = new Map();\n this._schemaChain = false;\n }\n\n clone() {\n const clone = new internals.Ids();\n clone._map = new Map(this._map);\n clone._schemaChain = this._schemaChain;\n clone._reachable = this._reachable;\n return clone;\n }\n\n concat(source) {\n this._reachable = source._reachable;\n\n if (source._schemaChain) {\n this._schemaChain = true;\n }\n\n for (const key of source._map.keys()) {\n this._map.set(key, source._map.get(key));\n }\n }\n\n fork(path, adjuster, root) {\n const chain = this._collect(path);\n\n chain.push({\n schema: root\n });\n const tail = chain.shift();\n let adjusted = {\n id: tail.id,\n schema: adjuster(tail.schema)\n };\n Assert(Common.isSchema(adjusted.schema), 'adjuster function failed to return a joi schema type');\n\n for (const node of chain) {\n const def = node.schema._definition;\n adjusted = {\n id: node.id,\n schema: def.modify(node.schema, adjusted.id, adjusted.schema)\n };\n }\n\n return adjusted.schema;\n }\n\n labels(path) {\n let behind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n Assert(this._reachable, 'Schema type is not reachable');\n const current = path[0];\n\n const node = this._map.get(current);\n\n if (!node) {\n return [...behind, ...path].join('.');\n }\n\n const forward = path.slice(1);\n behind = [...behind, node.schema._flags.label || current];\n\n if (!forward.length) {\n return behind.join('.');\n }\n\n return node.schema._ids.labels(forward, behind);\n }\n\n reach(path) {\n let behind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n Assert(this._reachable, 'Schema type is not reachable');\n const current = path[0];\n\n const node = this._map.get(current);\n\n Assert(node, 'Schema does not contain path', [...behind, ...path].join('.'));\n const forward = path.slice(1);\n\n if (!forward.length) {\n return node.schema;\n }\n\n return node.schema._ids.reach(forward, [...behind, current]);\n }\n\n register(schema, key) {\n if (!schema || !Common.isSchema(schema)) {\n return;\n }\n\n if (schema._definition.properties.schemaChain || schema._ids._schemaChain) {\n this._schemaChain = true;\n }\n\n const id = schema._flags.id || key;\n\n if (!id) {\n return;\n }\n\n Assert(!this._map.has(id), 'Schema already contains id', id);\n\n this._map.set(id, {\n schema,\n key,\n id\n });\n }\n\n reset() {\n this._map = new Map();\n this._schemaChain = false;\n }\n\n _collect(path) {\n let behind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n let nodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n Assert(this._reachable, 'Schema type is not reachable');\n const current = path[0];\n\n const node = this._map.get(current);\n\n Assert(node, 'Schema does not contain path', [...behind, ...path].join('.'));\n nodes = [node, ...nodes];\n const forward = path.slice(1);\n\n if (!forward.length) {\n return nodes;\n }\n\n Assert(node.schema._definition.modify, 'Schema node', [...behind, ...path].join('.'), 'does not support manipulation');\n return node.schema._ids._collect(forward, [...behind, current], nodes);\n }\n\n};" }, { - "id": 34, + "id": 33, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/validator.js", "name": "../lib/validator.js", "index": 28, "index2": 24, - "size": 20415, + "size": 12648, "cacheable": true, "built": true, "optional": false, @@ -7808,7 +7622,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", - "issuerId": 31, + "issuerId": 30, "issuerName": "../lib/base.js", "issuerPath": [ { @@ -7816,8 +7630,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -7825,25 +7639,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/any.js", "name": "../lib/types/any.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 31, + "id": 30, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "name": "../lib/base.js", "profile": { - "factory": 767, - "building": 322, + "factory": 353, + "building": 264, "dependencies": 2 } } ], "profile": { - "factory": 169, - "building": 279, + "factory": 101, + "building": 141, "dependencies": 0 }, "failed": false, @@ -7852,13 +7666,13 @@ "assets": [], "reasons": [ { - "moduleId": 31, + "moduleId": 30, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/base.js", "module": "../lib/base.js", "moduleName": "../lib/base.js", "type": "cjs require", "userRequest": "./validator", - "loc": "47:16-38" + "loc": "29:18-40" } ], "usedExports": true, @@ -7867,15 +7681,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Clone = require('@hapi/hoek/lib/clone');\n\nvar Reach = require('@hapi/hoek/lib/reach');\n\nvar Common = require('./common');\n\nvar Errors = require('./errors');\n\nvar internals = {\n result: Symbol('result')\n};\n\nexports.entry = function (value, schema, prefs) {\n var settings = Common.defaults;\n\n if (prefs) {\n Assert(prefs.warnings === undefined, 'Cannot override warnings preference in synchronous validation');\n settings = Common.preferences(Common.defaults, prefs);\n }\n\n var result = internals.entry(value, schema, settings);\n Assert(!result.mainstay.externals.length, 'Schema with external rules must use validateAsync()');\n var outcome = {\n value: result.value\n };\n\n if (result.error) {\n outcome.error = result.error;\n }\n\n if (result.mainstay.warnings.length) {\n outcome.warning = Errors.details(result.mainstay.warnings);\n }\n\n return outcome;\n};\n\nexports.entryAsync =\n/*#__PURE__*/\nfunction () {\n var _ref = _asyncToGenerator(\n /*#__PURE__*/\n regeneratorRuntime.mark(function _callee(value, schema, prefs) {\n var settings, result, mainstay, root, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step$value, method, path, label, node, key, parent, output, outcome;\n\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n settings = Common.defaults;\n\n if (prefs) {\n settings = Common.preferences(Common.defaults, prefs);\n }\n\n result = internals.entry(value, schema, settings);\n\n if (!result.error) {\n _context.next = 5;\n break;\n }\n\n throw result.error;\n\n case 5:\n mainstay = result.mainstay;\n\n if (!mainstay.externals.length) {\n _context.next = 50;\n break;\n }\n\n root = result.value;\n _iteratorNormalCompletion = true;\n _didIteratorError = false;\n _iteratorError = undefined;\n _context.prev = 11;\n _iterator = mainstay.externals[Symbol.iterator]();\n\n case 13:\n if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {\n _context.next = 35;\n break;\n }\n\n _step$value = _step.value, method = _step$value.method, path = _step$value.path, label = _step$value.label;\n node = root;\n key = void 0;\n parent = void 0;\n\n if (path.length) {\n key = path[path.length - 1];\n parent = Reach(root, path.slice(0, -1));\n node = parent[key];\n }\n\n _context.prev = 19;\n _context.next = 22;\n return method(node);\n\n case 22:\n output = _context.sent;\n\n if (!(output === undefined || output === node)) {\n _context.next = 25;\n break;\n }\n\n return _context.abrupt(\"continue\", 32);\n\n case 25:\n if (parent) {\n parent[key] = output;\n } else {\n root = output;\n }\n\n _context.next = 32;\n break;\n\n case 28:\n _context.prev = 28;\n _context.t0 = _context[\"catch\"](19);\n _context.t0.message += \" (\".concat(label, \")\"); // Change message to include path\n\n throw _context.t0;\n\n case 32:\n _iteratorNormalCompletion = true;\n _context.next = 13;\n break;\n\n case 35:\n _context.next = 41;\n break;\n\n case 37:\n _context.prev = 37;\n _context.t1 = _context[\"catch\"](11);\n _didIteratorError = true;\n _iteratorError = _context.t1;\n\n case 41:\n _context.prev = 41;\n _context.prev = 42;\n\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n\n case 44:\n _context.prev = 44;\n\n if (!_didIteratorError) {\n _context.next = 47;\n break;\n }\n\n throw _iteratorError;\n\n case 47:\n return _context.finish(44);\n\n case 48:\n return _context.finish(41);\n\n case 49:\n result.value = root;\n\n case 50:\n if (settings.warnings) {\n _context.next = 52;\n break;\n }\n\n return _context.abrupt(\"return\", result.value);\n\n case 52:\n outcome = {\n value: result.value\n };\n\n if (mainstay.warnings.length) {\n outcome.warning = Errors.details(mainstay.warnings);\n }\n\n return _context.abrupt(\"return\", outcome);\n\n case 55:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, null, [[11, 37, 41, 49], [19, 28], [42,, 44, 48]]);\n }));\n\n return function (_x, _x2, _x3) {\n return _ref.apply(this, arguments);\n };\n}();\n\ninternals.entry = function (value, schema, prefs) {\n var mainstay = {\n externals: [],\n warnings: []\n };\n var state = new Common.State([], [], {\n mainstay: mainstay,\n schemas: schema._ids._schemaChain && [schema]\n });\n var result = exports.validate(value, schema, state, prefs);\n var error = Errors.process(result.errors, value, prefs);\n return {\n value: result.value,\n error: error,\n mainstay: mainstay\n };\n};\n\nexports.validate = function (value, schema, state, prefs) {\n // Setup state and settings\n if (schema._preferences) {\n prefs = internals.prefs(schema, prefs);\n }\n\n var original = value; // Cache\n\n if (schema._cache && prefs.cache) {\n var result = schema._cache.get(original);\n\n if (result) {\n return result;\n }\n } // Helpers\n\n\n var helpers = {\n prefs: prefs,\n schema: schema,\n state: state,\n error: function error(code, local, localState) {\n return schema.$_createError(code, value, local, localState || state, prefs);\n }\n }; // Type coercion\n\n var def = schema._definition;\n\n if (def.coerce && value !== undefined && prefs.convert && (!def.coerce.from || def.coerce.from.includes(_typeof(value)))) {\n var coerced = def.coerce.method(schema, value, helpers);\n\n if (coerced) {\n if (coerced.errors) {\n return internals.finalize(coerced.value, original, [].concat(coerced.errors), helpers); // Coerced error always aborts early\n }\n\n value = coerced.value;\n }\n } // Empty value\n\n\n if (schema._flags.empty && schema._flags.empty.$_match(internals.trim(value, schema), state.entry(schema._flags.empty), Common.defaults)) {\n value = undefined;\n } // Presence requirements (required, optional, forbidden)\n\n\n var presence = schema._flags.presence || (schema._flags._endedSwitch ? 'ignore' : prefs.presence);\n\n if (value === undefined) {\n if (presence === 'forbidden') {\n return internals.finalize(value, original, null, helpers);\n }\n\n if (presence === 'required') {\n return internals.finalize(value, original, [schema.$_createError('any.required', value, null, state, prefs)], helpers);\n }\n\n if (presence === 'optional') {\n if (schema._flags.default !== Common.symbols.deepDefault) {\n return internals.finalize(value, original, null, helpers);\n }\n\n value = {};\n }\n } else if (presence === 'forbidden') {\n return internals.finalize(value, original, [schema.$_createError('any.unknown', value, null, state, prefs)], helpers);\n } // Allowed values\n\n\n var errors = [];\n\n if (schema._valids) {\n var match = schema._valids.get(value, state, prefs, schema._flags.insensitive);\n\n if (match) {\n if (prefs.convert) {\n value = match.value;\n }\n\n return internals.finalize(value, original, null, helpers);\n }\n\n if (schema._flags.only) {\n var report = schema.$_createError('any.only', value, {\n valids: schema._valids.values({\n stripUndefined: true\n })\n }, state, prefs);\n\n if (prefs.abortEarly) {\n return internals.finalize(value, original, [report], helpers);\n }\n\n errors.push(report);\n }\n } // Denied values\n\n\n if (schema._invalids) {\n if (schema._invalids.has(value, state, prefs, schema._flags.insensitive)) {\n var _report = schema.$_createError('any.invalid', value, {\n invalids: schema._invalids.values({\n stripUndefined: true\n })\n }, state, prefs);\n\n if (prefs.abortEarly) {\n return internals.finalize(value, original, [_report], helpers);\n }\n\n errors.push(_report);\n }\n } // Base type\n\n\n if (def.validate) {\n var base = def.validate(schema, value, helpers);\n\n if (base) {\n value = base.value;\n\n if (base.errors) {\n if (!Array.isArray(base.errors)) {\n errors.push(base.errors);\n return internals.finalize(value, original, errors, helpers); // Base error always aborts early\n }\n\n if (base.errors.length) {\n errors.push.apply(errors, _toConsumableArray(base.errors));\n return internals.finalize(value, original, errors, helpers); // Base error always aborts early\n }\n }\n }\n } // Validate tests\n\n\n if (!schema._rules.length) {\n return internals.finalize(value, original, errors, helpers);\n }\n\n return internals.rules(value, errors, original, helpers);\n};\n\ninternals.rules = function (value, errors, original, helpers) {\n var schema = helpers.schema,\n state = helpers.state,\n prefs = helpers.prefs;\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = schema._rules[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var rule = _step2.value;\n var definition = schema._definition.rules[rule.method]; // Skip rules that are also applied in coerce step\n\n if (definition.convert && prefs.convert) {\n continue;\n } // Resolve references\n\n\n var ret = void 0;\n var args = rule.args;\n\n if (rule.resolve.length) {\n args = Object.assign({}, args); // Shallow copy\n\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = rule.resolve[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var key = _step3.value;\n var resolver = definition.argsByName.get(key);\n var resolved = args[key].resolve(value, state, prefs);\n var normalized = resolver.normalize ? resolver.normalize(resolved) : resolved;\n var invalid = Common.validateArg(normalized, resolver);\n\n if (invalid) {\n ret = schema.$_createError('any.ref', resolved, {\n arg: key,\n ref: args[key],\n reason: invalid\n }, state, prefs);\n break;\n }\n\n args[key] = normalized;\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n } // Test rule\n\n\n ret = ret || definition.validate(value, helpers, args, rule.options); // Use ret if already set to reference error\n\n var result = internals.rule(ret, rule);\n\n if (result.errors) {\n if (rule.warn) {\n var _state$mainstay$warni;\n\n (_state$mainstay$warni = state.mainstay.warnings).push.apply(_state$mainstay$warni, _toConsumableArray(result.errors));\n\n continue;\n }\n\n if (prefs.abortEarly) {\n return internals.finalize(value, original, result.errors, helpers);\n }\n\n errors.push.apply(errors, _toConsumableArray(result.errors));\n } else {\n value = result.value;\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n return internals.finalize(value, original, errors, helpers);\n};\n\ninternals.rule = function (ret, rule) {\n if (ret instanceof Errors.Report) {\n internals.error(ret, rule);\n return {\n errors: [ret]\n };\n }\n\n if (Array.isArray(ret) && ret[0] instanceof Errors.Report) {\n ret.forEach(function (report) {\n return internals.error(report, rule);\n });\n return {\n errors: ret\n };\n }\n\n return {\n value: ret\n };\n};\n\ninternals.error = function (report, _ref2) {\n var message = _ref2.message;\n\n if (message) {\n report._setTemplate(message);\n }\n\n return report;\n};\n\ninternals.finalize = function (value, original, errors, helpers) {\n errors = errors || [];\n var schema = helpers.schema,\n state = helpers.state,\n prefs = helpers.prefs; // Failover value\n\n if (errors.length) {\n var failover = internals.default('failover', undefined, errors, helpers);\n\n if (failover !== undefined) {\n value = failover;\n errors = [];\n }\n } // Error override\n\n\n if (errors.length && schema._flags.error) {\n if (typeof schema._flags.error === 'function') {\n errors = schema._flags.error(errors);\n\n if (!Array.isArray(errors)) {\n errors = [errors];\n }\n } else {\n errors = [schema._flags.error];\n }\n } // Default\n\n\n if (value === undefined) {\n value = internals.default('default', value, errors, helpers);\n } // Cast\n\n\n if (schema._flags.cast && value !== undefined) {\n var caster = schema._definition.cast[schema._flags.cast];\n\n if (caster.from(value)) {\n value = caster.to(value, helpers);\n }\n } // Externals\n\n\n if (schema.$_terms.externals && prefs.externals && prefs._externals !== false) {\n // Disabled for matching\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = schema.$_terms.externals[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var method = _step4.value;\n state.mainstay.externals.push({\n method: method,\n path: state.path,\n label: Errors.label(schema._flags, state, prefs)\n });\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n } // Result\n\n\n var result = {\n value: value,\n errors: errors.length ? errors : null\n };\n\n if (schema._flags.result) {\n result.value = schema._flags.result === 'strip' ? undefined :\n /* raw */\n original;\n state.mainstay.shadow = state.mainstay.shadow || new internals.Shadow();\n state.mainstay.shadow.set(state.path, value);\n } // Cache\n\n\n if (schema._cache && prefs.cache !== false && !schema._refs.length) {\n schema._cache.set(original, result);\n }\n\n return result;\n};\n\ninternals.prefs = function (schema, prefs) {\n var isDefaultOptions = prefs === Common.defaults;\n\n if (isDefaultOptions && schema._preferences[Common.symbols.prefs]) {\n return schema._preferences[Common.symbols.prefs];\n }\n\n prefs = Common.preferences(prefs, schema._preferences);\n\n if (isDefaultOptions) {\n schema._preferences[Common.symbols.prefs] = prefs;\n }\n\n return prefs;\n};\n\ninternals.default = function (flag, value, errors, _ref3) {\n var schema = _ref3.schema,\n state = _ref3.state,\n prefs = _ref3.prefs;\n var source = schema._flags[flag];\n\n if (prefs.noDefaults || source === undefined) {\n return value;\n }\n\n if (!source) {\n return source;\n }\n\n if (typeof source === 'function') {\n var args = source.length > 0 ? [Clone(state.ancestors[0]), prefs] : [];\n\n try {\n return source.apply(void 0, args);\n } catch (err) {\n errors.push(schema.$_createError(\"any.\".concat(flag), null, {\n error: err\n }, state, prefs));\n return;\n }\n }\n\n if (_typeof(source) !== 'object') {\n return source;\n }\n\n if (source[Common.symbols.literal]) {\n return source.literal;\n }\n\n if (Common.isResolvable(source)) {\n return source.resolve(value, state, prefs);\n }\n\n return Clone(source);\n};\n\ninternals.trim = function (value, schema) {\n if (typeof value !== 'string') {\n return value;\n }\n\n var trim = schema.$_getRule('trim');\n\n if (!trim || !trim.args.enabled) {\n return value;\n }\n\n return value.trim();\n};\n\ninternals.Shadow =\n/*#__PURE__*/\nfunction () {\n function _class() {\n _classCallCheck(this, _class);\n\n this._value = null;\n }\n\n _createClass(_class, [{\n key: \"set\",\n value: function set(path, value) {\n if (!path.length) {\n // No need to store root value\n return;\n }\n\n this._value = this._value || new Map();\n var node = this._value;\n\n for (var i = 0; i < path.length - 1; ++i) {\n var segment = path[i];\n var next = node.get(segment);\n\n if (!next) {\n next = new Map();\n node.set(segment, next);\n }\n\n node = next;\n }\n\n node.set(path[path.length - 1], value);\n }\n }, {\n key: \"get\",\n value: function get(path) {\n return Reach(this._value, path, {\n iterables: true\n });\n }\n }]);\n\n return _class;\n}();" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Clone = require('@hapi/hoek/lib/clone');\n\nconst Reach = require('@hapi/hoek/lib/reach');\n\nconst Common = require('./common');\n\nconst Errors = require('./errors');\n\nconst internals = {\n result: Symbol('result')\n};\n\nexports.entry = function (value, schema, prefs) {\n let settings = Common.defaults;\n\n if (prefs) {\n Assert(prefs.warnings === undefined, 'Cannot override warnings preference in synchronous validation');\n settings = Common.preferences(Common.defaults, prefs);\n }\n\n const result = internals.entry(value, schema, settings);\n Assert(!result.mainstay.externals.length, 'Schema with external rules must use validateAsync()');\n const outcome = {\n value: result.value\n };\n\n if (result.error) {\n outcome.error = result.error;\n }\n\n if (result.mainstay.warnings.length) {\n outcome.warning = Errors.details(result.mainstay.warnings);\n }\n\n return outcome;\n};\n\nexports.entryAsync = async function (value, schema, prefs) {\n let settings = Common.defaults;\n\n if (prefs) {\n settings = Common.preferences(Common.defaults, prefs);\n }\n\n const result = internals.entry(value, schema, settings);\n\n if (result.error) {\n throw result.error;\n }\n\n const mainstay = result.mainstay;\n\n if (mainstay.externals.length) {\n let root = result.value;\n\n for (const _ref of mainstay.externals) {\n const {\n method,\n path,\n label\n } = _ref;\n let node = root;\n let key;\n let parent;\n\n if (path.length) {\n key = path[path.length - 1];\n parent = Reach(root, path.slice(0, -1));\n node = parent[key];\n }\n\n try {\n const output = await method(node);\n\n if (output === undefined || output === node) {\n continue;\n }\n\n if (parent) {\n parent[key] = output;\n } else {\n root = output;\n }\n } catch (err) {\n err.message += \" (\".concat(label, \")\"); // Change message to include path\n\n throw err;\n }\n }\n\n result.value = root;\n }\n\n if (!settings.warnings) {\n return result.value;\n }\n\n const outcome = {\n value: result.value\n };\n\n if (mainstay.warnings.length) {\n outcome.warning = Errors.details(mainstay.warnings);\n }\n\n return outcome;\n};\n\ninternals.entry = function (value, schema, prefs) {\n const mainstay = {\n externals: [],\n warnings: []\n };\n const state = new Common.State([], [], {\n mainstay,\n schemas: schema._ids._schemaChain && [schema]\n });\n const result = exports.validate(value, schema, state, prefs);\n const error = Errors.process(result.errors, value, prefs);\n return {\n value: result.value,\n error,\n mainstay\n };\n};\n\nexports.validate = function (value, schema, state, prefs) {\n // Setup state and settings\n if (schema._preferences) {\n prefs = internals.prefs(schema, prefs);\n }\n\n const original = value; // Cache\n\n if (schema._cache && prefs.cache) {\n const result = schema._cache.get(original);\n\n if (result) {\n return result;\n }\n } // Helpers\n\n\n const helpers = {\n prefs,\n schema,\n state,\n error: (code, local, localState) => schema.$_createError(code, value, local, localState || state, prefs)\n }; // Type coercion\n\n const def = schema._definition;\n\n if (def.coerce && value !== undefined && prefs.convert && (!def.coerce.from || def.coerce.from.includes(typeof value))) {\n const coerced = def.coerce.method(schema, value, helpers);\n\n if (coerced) {\n if (coerced.errors) {\n return internals.finalize(coerced.value, original, [].concat(coerced.errors), helpers); // Coerced error always aborts early\n }\n\n value = coerced.value;\n }\n } // Empty value\n\n\n if (schema._flags.empty && schema._flags.empty.$_match(internals.trim(value, schema), state.entry(schema._flags.empty), Common.defaults)) {\n value = undefined;\n } // Presence requirements (required, optional, forbidden)\n\n\n const presence = schema._flags.presence || (schema._flags._endedSwitch ? 'ignore' : prefs.presence);\n\n if (value === undefined) {\n if (presence === 'forbidden') {\n return internals.finalize(value, original, null, helpers);\n }\n\n if (presence === 'required') {\n return internals.finalize(value, original, [schema.$_createError('any.required', value, null, state, prefs)], helpers);\n }\n\n if (presence === 'optional') {\n if (schema._flags.default !== Common.symbols.deepDefault) {\n return internals.finalize(value, original, null, helpers);\n }\n\n value = {};\n }\n } else if (presence === 'forbidden') {\n return internals.finalize(value, original, [schema.$_createError('any.unknown', value, null, state, prefs)], helpers);\n } // Allowed values\n\n\n const errors = [];\n\n if (schema._valids) {\n const match = schema._valids.get(value, state, prefs, schema._flags.insensitive);\n\n if (match) {\n if (prefs.convert) {\n value = match.value;\n }\n\n return internals.finalize(value, original, null, helpers);\n }\n\n if (schema._flags.only) {\n const report = schema.$_createError('any.only', value, {\n valids: schema._valids.values({\n stripUndefined: true\n })\n }, state, prefs);\n\n if (prefs.abortEarly) {\n return internals.finalize(value, original, [report], helpers);\n }\n\n errors.push(report);\n }\n } // Denied values\n\n\n if (schema._invalids) {\n if (schema._invalids.has(value, state, prefs, schema._flags.insensitive)) {\n const report = schema.$_createError('any.invalid', value, {\n invalids: schema._invalids.values({\n stripUndefined: true\n })\n }, state, prefs);\n\n if (prefs.abortEarly) {\n return internals.finalize(value, original, [report], helpers);\n }\n\n errors.push(report);\n }\n } // Base type\n\n\n if (def.validate) {\n const base = def.validate(schema, value, helpers);\n\n if (base) {\n value = base.value;\n\n if (base.errors) {\n if (!Array.isArray(base.errors)) {\n errors.push(base.errors);\n return internals.finalize(value, original, errors, helpers); // Base error always aborts early\n }\n\n if (base.errors.length) {\n errors.push(...base.errors);\n return internals.finalize(value, original, errors, helpers); // Base error always aborts early\n }\n }\n }\n } // Validate tests\n\n\n if (!schema._rules.length) {\n return internals.finalize(value, original, errors, helpers);\n }\n\n return internals.rules(value, errors, original, helpers);\n};\n\ninternals.rules = function (value, errors, original, helpers) {\n const {\n schema,\n state,\n prefs\n } = helpers;\n\n for (const rule of schema._rules) {\n const definition = schema._definition.rules[rule.method]; // Skip rules that are also applied in coerce step\n\n if (definition.convert && prefs.convert) {\n continue;\n } // Resolve references\n\n\n let ret;\n let args = rule.args;\n\n if (rule.resolve.length) {\n args = Object.assign({}, args); // Shallow copy\n\n for (const key of rule.resolve) {\n const resolver = definition.argsByName.get(key);\n const resolved = args[key].resolve(value, state, prefs);\n const normalized = resolver.normalize ? resolver.normalize(resolved) : resolved;\n const invalid = Common.validateArg(normalized, resolver);\n\n if (invalid) {\n ret = schema.$_createError('any.ref', resolved, {\n arg: key,\n ref: args[key],\n reason: invalid\n }, state, prefs);\n break;\n }\n\n args[key] = normalized;\n }\n } // Test rule\n\n\n ret = ret || definition.validate(value, helpers, args, rule.options); // Use ret if already set to reference error\n\n const result = internals.rule(ret, rule);\n\n if (result.errors) {\n if (rule.warn) {\n state.mainstay.warnings.push(...result.errors);\n continue;\n }\n\n if (prefs.abortEarly) {\n return internals.finalize(value, original, result.errors, helpers);\n }\n\n errors.push(...result.errors);\n } else {\n value = result.value;\n }\n }\n\n return internals.finalize(value, original, errors, helpers);\n};\n\ninternals.rule = function (ret, rule) {\n if (ret instanceof Errors.Report) {\n internals.error(ret, rule);\n return {\n errors: [ret]\n };\n }\n\n if (Array.isArray(ret) && ret[0] instanceof Errors.Report) {\n ret.forEach(report => internals.error(report, rule));\n return {\n errors: ret\n };\n }\n\n return {\n value: ret\n };\n};\n\ninternals.error = function (report, _ref2) {\n let {\n message\n } = _ref2;\n\n if (message) {\n report._setTemplate(message);\n }\n\n return report;\n};\n\ninternals.finalize = function (value, original, errors, helpers) {\n errors = errors || [];\n const {\n schema,\n state,\n prefs\n } = helpers; // Failover value\n\n if (errors.length) {\n const failover = internals.default('failover', undefined, errors, helpers);\n\n if (failover !== undefined) {\n value = failover;\n errors = [];\n }\n } // Error override\n\n\n if (errors.length && schema._flags.error) {\n if (typeof schema._flags.error === 'function') {\n errors = schema._flags.error(errors);\n\n if (!Array.isArray(errors)) {\n errors = [errors];\n }\n } else {\n errors = [schema._flags.error];\n }\n } // Default\n\n\n if (value === undefined) {\n value = internals.default('default', value, errors, helpers);\n } // Cast\n\n\n if (schema._flags.cast && value !== undefined) {\n const caster = schema._definition.cast[schema._flags.cast];\n\n if (caster.from(value)) {\n value = caster.to(value, helpers);\n }\n } // Externals\n\n\n if (schema.$_terms.externals && prefs.externals && prefs._externals !== false) {\n // Disabled for matching\n for (const method of schema.$_terms.externals) {\n state.mainstay.externals.push({\n method,\n path: state.path,\n label: Errors.label(schema._flags, state, prefs)\n });\n }\n } // Result\n\n\n const result = {\n value,\n errors: errors.length ? errors : null\n };\n\n if (schema._flags.result) {\n result.value = schema._flags.result === 'strip' ? undefined :\n /* raw */\n original;\n state.mainstay.shadow = state.mainstay.shadow || new internals.Shadow();\n state.mainstay.shadow.set(state.path, value);\n } // Cache\n\n\n if (schema._cache && prefs.cache !== false && !schema._refs.length) {\n schema._cache.set(original, result);\n }\n\n return result;\n};\n\ninternals.prefs = function (schema, prefs) {\n const isDefaultOptions = prefs === Common.defaults;\n\n if (isDefaultOptions && schema._preferences[Common.symbols.prefs]) {\n return schema._preferences[Common.symbols.prefs];\n }\n\n prefs = Common.preferences(prefs, schema._preferences);\n\n if (isDefaultOptions) {\n schema._preferences[Common.symbols.prefs] = prefs;\n }\n\n return prefs;\n};\n\ninternals.default = function (flag, value, errors, _ref3) {\n let {\n schema,\n state,\n prefs\n } = _ref3;\n const source = schema._flags[flag];\n\n if (prefs.noDefaults || source === undefined) {\n return value;\n }\n\n if (!source) {\n return source;\n }\n\n if (typeof source === 'function') {\n const args = source.length > 0 ? [Clone(state.ancestors[0]), prefs] : [];\n\n try {\n return source(...args);\n } catch (err) {\n errors.push(schema.$_createError(\"any.\".concat(flag), null, {\n error: err\n }, state, prefs));\n return;\n }\n }\n\n if (typeof source !== 'object') {\n return source;\n }\n\n if (source[Common.symbols.literal]) {\n return source.literal;\n }\n\n if (Common.isResolvable(source)) {\n return source.resolve(value, state, prefs);\n }\n\n return Clone(source);\n};\n\ninternals.trim = function (value, schema) {\n if (typeof value !== 'string') {\n return value;\n }\n\n const trim = schema.$_getRule('trim');\n\n if (!trim || !trim.args.enabled) {\n return value;\n }\n\n return value.trim();\n};\n\ninternals.Shadow = class {\n constructor() {\n this._value = null;\n }\n\n set(path, value) {\n if (!path.length) {\n // No need to store root value\n return;\n }\n\n this._value = this._value || new Map();\n let node = this._value;\n\n for (let i = 0; i < path.length - 1; ++i) {\n const segment = path[i];\n let next = node.get(segment);\n\n if (!next) {\n next = new Map();\n node.set(segment, next);\n }\n\n node = next;\n }\n\n node.set(path[path.length - 1], value);\n }\n\n get(path) {\n return Reach(this._value, path, {\n iterables: true\n });\n }\n\n};" }, { - "id": 35, + "id": 34, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/array.js", "name": "../lib/types/array.js", "index": 30, "index2": 30, - "size": 31315, + "size": 24061, "cacheable": true, "built": true, "optional": false, @@ -7892,15 +7706,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -7914,7 +7728,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/array", - "loc": "40:11-35" + "loc": "26:11-35" } ], "usedExports": true, @@ -7923,15 +7737,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Bourne = require('@hapi/bourne');\n\nvar DeepEqual = require('@hapi/hoek/lib/deepEqual');\n\nvar Reach = require('@hapi/hoek/lib/reach');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar Compile = require('../compile');\n\nvar internals = {};\nmodule.exports = Any.extend({\n type: 'array',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.items = [];\n schema.$_terms.ordered = [];\n schema.$_terms._inclusions = [];\n schema.$_terms._exclusions = [];\n schema.$_terms._requireds = [];\n },\n // Coerce\n coerce: {\n method: function method(schema, value, _ref) {\n var state = _ref.state,\n prefs = _ref.prefs;\n var result = {\n value: value\n };\n\n if (typeof value === 'string') {\n if (value[0] !== '[' && !/^\\s*\\[/.test(value)) {\n return;\n }\n\n try {\n result.value = Bourne.parse(value);\n } catch (ignoreErr) {\n return;\n }\n }\n\n if (!Array.isArray(result.value)) {\n return;\n }\n\n var sort = schema.$_getRule('sort');\n\n if (sort) {\n return internals.sort(schema, result.value, sort.args.options, state, prefs);\n }\n\n return result;\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n var error = _ref2.error;\n\n if (!Array.isArray(value)) {\n if (schema._flags.single) {\n var single = [value];\n single[Common.symbols.arraySingle] = true;\n return {\n value: single\n };\n }\n\n return {\n errors: error('array.base')\n };\n }\n\n if (!schema.$_getRule('items') && !schema.$_terms.externals) {\n return;\n }\n\n return {\n value: value.slice()\n }; // Clone the array so that we don't modify the original\n },\n // Rules\n rules: {\n has: {\n method: function method(schema) {\n schema = this.$_compile(schema, {\n appendPath: true\n });\n var obj = this.$_addRule({\n name: 'has',\n args: {\n schema: schema\n }\n });\n obj.$_mutateRegister(schema);\n return obj;\n },\n validate: function validate(value, _ref3, _ref4) {\n var state = _ref3.state,\n prefs = _ref3.prefs,\n error = _ref3.error,\n schema = _ref3.schema;\n var has = _ref4.schema;\n var ancestors = [value].concat(_toConsumableArray(state.ancestors));\n\n for (var i = 0; i < value.length; ++i) {\n var localState = state.localize([].concat(_toConsumableArray(state.path), [i]), ancestors, has);\n\n if (has.$_match(value[i], localState, prefs)) {\n return value;\n }\n }\n\n var patternLabel = has._flags.label;\n\n if (patternLabel) {\n return error('array.hasKnown', {\n patternLabel: patternLabel\n });\n }\n\n return error('array.hasUnknown', null);\n },\n multi: true\n },\n items: {\n method: function method() {\n var _this = this;\n\n for (var _len = arguments.length, schemas = new Array(_len), _key = 0; _key < _len; _key++) {\n schemas[_key] = arguments[_key];\n }\n\n Common.verifyFlat(schemas, 'items');\n var obj = this.$_addRule('items');\n\n var _loop = function _loop(i) {\n var type = Common.tryWithPath(function () {\n return _this.$_compile(schemas[i]);\n }, i, {\n append: true\n });\n obj.$_terms.items.push(type);\n };\n\n for (var i = 0; i < schemas.length; ++i) {\n _loop(i);\n }\n\n return obj.$_mutateRebuild();\n },\n validate: function validate(value, _ref5) {\n var schema = _ref5.schema,\n error = _ref5.error,\n state = _ref5.state,\n prefs = _ref5.prefs;\n\n var requireds = schema.$_terms._requireds.slice();\n\n var ordereds = schema.$_terms.ordered.slice();\n var inclusions = [].concat(_toConsumableArray(schema.$_terms._inclusions), _toConsumableArray(requireds));\n var wasArray = !value[Common.symbols.arraySingle];\n var errors = [];\n var il = value.length;\n\n for (var i = 0; i < il; ++i) {\n var item = value[i];\n var errored = false;\n var isValid = false;\n var key = wasArray ? i : new Number(i); // eslint-disable-line no-new-wrappers\n\n var path = [].concat(_toConsumableArray(state.path), [key]); // Sparse\n\n if (!schema._flags.sparse && item === undefined) {\n errors.push(error('array.sparse', {\n key: key,\n path: path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n ordereds.shift();\n continue;\n } // Exclusions\n\n\n var ancestors = [value].concat(_toConsumableArray(state.ancestors));\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = schema.$_terms._exclusions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var exclusion = _step.value;\n\n if (!exclusion.$_match(item, state.localize(path, ancestors, exclusion), prefs)) {\n continue;\n }\n\n errors.push(error('array.excludes', {\n pos: i,\n value: item\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n errored = true;\n ordereds.shift();\n break;\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n if (errored) {\n continue;\n } // Ordered\n\n\n if (schema.$_terms.ordered.length) {\n if (ordereds.length) {\n var ordered = ordereds.shift();\n var res = ordered.$_validate(item, state.localize(path, ancestors, ordered), prefs);\n\n if (!res.errors) {\n if (ordered._flags.result === 'strip') {\n internals.fastSplice(value, i);\n --i;\n --il;\n } else if (!schema._flags.sparse && res.value === undefined) {\n errors.push(error('array.sparse', {\n key: key,\n path: path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n continue;\n } else {\n value[i] = res.value;\n }\n } else {\n errors.push.apply(errors, _toConsumableArray(res.errors));\n\n if (prefs.abortEarly) {\n return errors;\n }\n }\n\n continue;\n } else if (!schema.$_terms.items.length) {\n errors.push(error('array.orderedLength', {\n pos: i,\n limit: schema.$_terms.ordered.length\n }));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n break; // No reason to continue since there are no other rules to validate other than array.orderedLength\n }\n } // Requireds\n\n\n var requiredChecks = [];\n var jl = requireds.length;\n\n for (var j = 0; j < jl; ++j) {\n var _res = requireds[j].$_validate(item, state.localize(path, ancestors, requireds[j]), prefs);\n\n requiredChecks[j] = _res;\n\n if (!_res.errors) {\n value[i] = _res.value;\n isValid = true;\n internals.fastSplice(requireds, j);\n --j;\n --jl;\n\n if (!schema._flags.sparse && _res.value === undefined) {\n errors.push(error('array.sparse', {\n key: key,\n path: path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n }\n\n break;\n }\n }\n\n if (isValid) {\n continue;\n } // Inclusions\n\n\n var stripUnknown = prefs.stripUnknown && !!prefs.stripUnknown.arrays || false;\n jl = inclusions.length;\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = inclusions[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var inclusion = _step2.value;\n\n // Avoid re-running requireds that already didn't match in the previous loop\n var _res2 = void 0;\n\n var previousCheck = requireds.indexOf(inclusion);\n\n if (previousCheck !== -1) {\n _res2 = requiredChecks[previousCheck];\n } else {\n _res2 = inclusion.$_validate(item, state.localize(path, ancestors, inclusion), prefs);\n\n if (!_res2.errors) {\n if (inclusion._flags.result === 'strip') {\n internals.fastSplice(value, i);\n --i;\n --il;\n } else if (!schema._flags.sparse && _res2.value === undefined) {\n errors.push(error('array.sparse', {\n key: key,\n path: path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n errored = true;\n } else {\n value[i] = _res2.value;\n }\n\n isValid = true;\n break;\n }\n } // Return the actual error if only one inclusion defined\n\n\n if (jl === 1) {\n if (stripUnknown) {\n internals.fastSplice(value, i);\n --i;\n --il;\n isValid = true;\n break;\n }\n\n errors.push.apply(errors, _toConsumableArray(_res2.errors));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n errored = true;\n break;\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (errored) {\n continue;\n }\n\n if (schema.$_terms._inclusions.length && !isValid) {\n if (stripUnknown) {\n internals.fastSplice(value, i);\n --i;\n --il;\n continue;\n }\n\n errors.push(error('array.includes', {\n pos: i,\n value: item\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n }\n }\n\n if (requireds.length) {\n internals.fillMissedErrors(schema, errors, requireds, value, state, prefs);\n }\n\n if (ordereds.length) {\n internals.fillOrderedErrors(schema, errors, ordereds, value, state, prefs);\n }\n\n return errors.length ? errors : value;\n },\n priority: true\n },\n length: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'length',\n args: {\n limit: limit\n },\n operator: '='\n });\n },\n validate: function validate(value, helpers, _ref6, _ref7) {\n var limit = _ref6.limit;\n var name = _ref7.name,\n operator = _ref7.operator,\n args = _ref7.args;\n\n if (Common.compare(value.length, limit, operator)) {\n return value;\n }\n\n return helpers.error('array.' + name, {\n limit: args.limit,\n value: value\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.limit,\n message: 'must be a positive integer'\n }]\n },\n max: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'max',\n method: 'length',\n args: {\n limit: limit\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'min',\n method: 'length',\n args: {\n limit: limit\n },\n operator: '>='\n });\n }\n },\n ordered: {\n method: function method() {\n var _this2 = this;\n\n for (var _len2 = arguments.length, schemas = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n schemas[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(schemas, 'ordered');\n var obj = this.$_addRule('items');\n\n var _loop2 = function _loop2(i) {\n var type = Common.tryWithPath(function () {\n return _this2.$_compile(schemas[i]);\n }, i, {\n append: true\n });\n internals.validateSingle(type, obj);\n obj.$_mutateRegister(type);\n obj.$_terms.ordered.push(type);\n };\n\n for (var i = 0; i < schemas.length; ++i) {\n _loop2(i);\n }\n\n return obj.$_mutateRebuild();\n }\n },\n single: {\n method: function method(enabled) {\n var value = enabled === undefined ? true : !!enabled;\n Assert(!value || !this._flags._arrayItems, 'Cannot specify single rule when array has array items');\n return this.$_setFlag('single', value);\n }\n },\n sort: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['by', 'order']);\n var settings = {\n order: options.order || 'ascending'\n };\n\n if (options.by) {\n settings.by = Compile.ref(options.by, {\n ancestor: 0\n });\n Assert(!settings.by.ancestor, 'Cannot sort by ancestor');\n }\n\n return this.$_addRule({\n name: 'sort',\n args: {\n options: settings\n }\n });\n },\n validate: function validate(value, _ref8, _ref9) {\n var error = _ref8.error,\n state = _ref8.state,\n prefs = _ref8.prefs,\n schema = _ref8.schema;\n var options = _ref9.options;\n\n var _internals$sort = internals.sort(schema, value, options, state, prefs),\n sorted = _internals$sort.value,\n errors = _internals$sort.errors;\n\n if (errors) {\n return errors;\n }\n\n for (var i = 0; i < value.length; ++i) {\n if (value[i] !== sorted[i]) {\n return error('array.sort', {\n order: options.order,\n by: options.by ? options.by.key : 'value'\n });\n }\n }\n\n return value;\n },\n convert: true\n },\n sparse: {\n method: function method(enabled) {\n var value = enabled === undefined ? true : !!enabled;\n\n if (this._flags.sparse === value) {\n return this;\n }\n\n var obj = value ? this.clone() : this.$_addRule('items');\n return obj.$_setFlag('sparse', value, {\n clone: false\n });\n }\n },\n unique: {\n method: function method(comparator) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(!comparator || typeof comparator === 'function' || typeof comparator === 'string', 'comparator must be a function or a string');\n Common.assertOptions(options, ['ignoreUndefined', 'separator']);\n var rule = {\n name: 'unique',\n args: {\n options: options,\n comparator: comparator\n }\n };\n\n if (comparator) {\n if (typeof comparator === 'string') {\n var separator = Common.default(options.separator, '.');\n rule.path = separator ? comparator.split(separator) : [comparator];\n } else {\n rule.comparator = comparator;\n }\n }\n\n return this.$_addRule(rule);\n },\n validate: function validate(value, _ref10, _ref11, _ref12) {\n var state = _ref10.state,\n error = _ref10.error,\n schema = _ref10.schema;\n var raw = _ref11.comparator,\n options = _ref11.options;\n var comparator = _ref12.comparator,\n path = _ref12.path;\n var found = {\n string: Object.create(null),\n number: Object.create(null),\n undefined: Object.create(null),\n boolean: Object.create(null),\n object: new Map(),\n function: new Map(),\n custom: new Map()\n };\n var compare = comparator || DeepEqual;\n var ignoreUndefined = options.ignoreUndefined;\n\n for (var i = 0; i < value.length; ++i) {\n var item = path ? Reach(value[i], path) : value[i];\n var records = comparator ? found.custom : found[_typeof(item)];\n Assert(records, 'Failed to find unique map container for type', _typeof(item));\n\n if (records instanceof Map) {\n var entries = records.entries();\n var current = void 0;\n\n while (!(current = entries.next()).done) {\n if (compare(current.value[0], item)) {\n var localState = state.localize([].concat(_toConsumableArray(state.path), [i]), [value].concat(_toConsumableArray(state.ancestors)));\n var context = {\n pos: i,\n value: value[i],\n dupePos: current.value[1],\n dupeValue: value[current.value[1]]\n };\n\n if (path) {\n context.path = raw;\n }\n\n return error('array.unique', context, localState);\n }\n }\n\n records.set(item, i);\n } else {\n if ((!ignoreUndefined || item !== undefined) && records[item] !== undefined) {\n var _context = {\n pos: i,\n value: value[i],\n dupePos: records[item],\n dupeValue: value[records[item]]\n };\n\n if (path) {\n _context.path = raw;\n }\n\n var _localState = state.localize([].concat(_toConsumableArray(state.path), [i]), [value].concat(_toConsumableArray(state.ancestors)));\n\n return error('array.unique', _context, _localState);\n }\n\n records[item] = i;\n }\n }\n\n return value;\n },\n args: ['comparator', 'options'],\n multi: true\n }\n },\n // Cast\n cast: {\n set: {\n from: Array.isArray,\n to: function to(value, helpers) {\n return new Set(value);\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n if (desc.items) {\n var _obj;\n\n obj = (_obj = obj).items.apply(_obj, _toConsumableArray(desc.items));\n }\n\n if (desc.ordered) {\n var _obj2;\n\n obj = (_obj2 = obj).ordered.apply(_obj2, _toConsumableArray(desc.ordered));\n }\n\n return obj;\n },\n // Modify\n modify: function modify(schema, id, replacement) {\n for (var _i = 0, _arr = ['items', 'ordered']; _i < _arr.length; _i++) {\n var set = _arr[_i];\n\n for (var i = 0; i < schema.$_terms[set].length; ++i) {\n var existing = schema.$_terms[set][i];\n\n if (id === existing._flags.id) {\n var obj = schema.clone();\n obj.$_terms[set][i] = replacement;\n return obj.$_mutateRebuild();\n }\n }\n }\n\n var hases = schema.$_getRules('has');\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = hases[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var has = _step3.value;\n\n if (id === has.args.schema._flags.id) {\n var _obj3 = schema.clone();\n\n has.args.schema = replacement;\n return _obj3.$_mutateRebuild();\n }\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n },\n rebuild: function rebuild(schema) {\n schema.$_terms._inclusions = [];\n schema.$_terms._exclusions = [];\n schema.$_terms._requireds = [];\n var _iteratorNormalCompletion4 = true;\n var _didIteratorError4 = false;\n var _iteratorError4 = undefined;\n\n try {\n for (var _iterator4 = schema.$_terms.items[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var type = _step4.value;\n internals.validateSingle(type, schema);\n schema.$_mutateRegister(type);\n\n if (type._flags.presence === 'required') {\n schema.$_terms._requireds.push(type);\n } else if (type._flags.presence === 'forbidden') {\n schema.$_terms._exclusions.push(type.optional());\n } else {\n schema.$_terms._inclusions.push(type);\n }\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n\n var _iteratorNormalCompletion5 = true;\n var _didIteratorError5 = false;\n var _iteratorError5 = undefined;\n\n try {\n for (var _iterator5 = schema.$_terms.ordered[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {\n var _type = _step5.value;\n internals.validateSingle(_type, schema);\n schema.$_mutateRegister(_type);\n }\n } catch (err) {\n _didIteratorError5 = true;\n _iteratorError5 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion5 && _iterator5.return != null) {\n _iterator5.return();\n }\n } finally {\n if (_didIteratorError5) {\n throw _iteratorError5;\n }\n }\n }\n\n var hases = schema.$_getRules('has');\n var _iteratorNormalCompletion6 = true;\n var _didIteratorError6 = false;\n var _iteratorError6 = undefined;\n\n try {\n for (var _iterator6 = hases[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {\n var has = _step6.value;\n schema.$_mutateRegister(has.args.schema);\n }\n } catch (err) {\n _didIteratorError6 = true;\n _iteratorError6 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion6 && _iterator6.return != null) {\n _iterator6.return();\n }\n } finally {\n if (_didIteratorError6) {\n throw _iteratorError6;\n }\n }\n }\n\n return schema;\n },\n // Errors\n messages: {\n 'array.base': '\"{{#label}}\" must be an array',\n 'array.excludes': '\"{{#label}}\" contains an excluded value',\n 'array.hasKnown': '\"{{#label}}\" does not contain at least one required match for type \"{#patternLabel}\"',\n 'array.hasUnknown': '\"{{#label}}\" does not contain at least one required match',\n 'array.includes': '\"{{#label}}\" does not match any of the allowed types',\n 'array.includesRequiredBoth': '\"{{#label}}\" does not contain {{#knownMisses}} and {{#unknownMisses}} other required value(s)',\n 'array.includesRequiredKnowns': '\"{{#label}}\" does not contain {{#knownMisses}}',\n 'array.includesRequiredUnknowns': '\"{{#label}}\" does not contain {{#unknownMisses}} required value(s)',\n 'array.length': '\"{{#label}}\" must contain {{#limit}} items',\n 'array.max': '\"{{#label}}\" must contain less than or equal to {{#limit}} items',\n 'array.min': '\"{{#label}}\" must contain at least {{#limit}} items',\n 'array.orderedLength': '\"{{#label}}\" must contain at most {{#limit}} items',\n 'array.sort': '\"{{#label}}\" must be sorted in {#order} order by {{#by}}',\n 'array.sort.mismatching': '\"{{#label}}\" cannot be sorted due to mismatching types',\n 'array.sort.unsupported': '\"{{#label}}\" cannot be sorted due to unsupported type {#type}',\n 'array.sparse': '\"{{#label}}\" must not be a sparse array item',\n 'array.unique': '\"{{#label}}\" contains a duplicate value'\n }\n}); // Helpers\n\ninternals.fillMissedErrors = function (schema, errors, requireds, value, state, prefs) {\n var knownMisses = [];\n var unknownMisses = 0;\n var _iteratorNormalCompletion7 = true;\n var _didIteratorError7 = false;\n var _iteratorError7 = undefined;\n\n try {\n for (var _iterator7 = requireds[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {\n var required = _step7.value;\n var label = required._flags.label;\n\n if (label) {\n knownMisses.push(label);\n } else {\n ++unknownMisses;\n }\n }\n } catch (err) {\n _didIteratorError7 = true;\n _iteratorError7 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion7 && _iterator7.return != null) {\n _iterator7.return();\n }\n } finally {\n if (_didIteratorError7) {\n throw _iteratorError7;\n }\n }\n }\n\n if (knownMisses.length) {\n if (unknownMisses) {\n errors.push(schema.$_createError('array.includesRequiredBoth', value, {\n knownMisses: knownMisses,\n unknownMisses: unknownMisses\n }, state, prefs));\n } else {\n errors.push(schema.$_createError('array.includesRequiredKnowns', value, {\n knownMisses: knownMisses\n }, state, prefs));\n }\n } else {\n errors.push(schema.$_createError('array.includesRequiredUnknowns', value, {\n unknownMisses: unknownMisses\n }, state, prefs));\n }\n};\n\ninternals.fillOrderedErrors = function (schema, errors, ordereds, value, state, prefs) {\n var requiredOrdereds = [];\n var _iteratorNormalCompletion8 = true;\n var _didIteratorError8 = false;\n var _iteratorError8 = undefined;\n\n try {\n for (var _iterator8 = ordereds[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {\n var ordered = _step8.value;\n\n if (ordered._flags.presence === 'required') {\n requiredOrdereds.push(ordered);\n }\n }\n } catch (err) {\n _didIteratorError8 = true;\n _iteratorError8 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion8 && _iterator8.return != null) {\n _iterator8.return();\n }\n } finally {\n if (_didIteratorError8) {\n throw _iteratorError8;\n }\n }\n }\n\n if (requiredOrdereds.length) {\n internals.fillMissedErrors(schema, errors, requiredOrdereds, value, state, prefs);\n }\n};\n\ninternals.fastSplice = function (arr, i) {\n var pos = i;\n\n while (pos < arr.length) {\n arr[pos++] = arr[pos];\n }\n\n --arr.length;\n};\n\ninternals.validateSingle = function (type, obj) {\n if (type.type === 'array' || type._flags._arrayItems) {\n Assert(!obj._flags.single, 'Cannot specify array item with single rule enabled');\n obj.$_setFlag('_arrayItems', true, {\n clone: false\n });\n }\n};\n\ninternals.sort = function (schema, value, settings, state, prefs) {\n var order = settings.order === 'ascending' ? 1 : -1;\n var aFirst = -1 * order;\n var bFirst = order;\n\n var sort = function sort(a, b) {\n var compare = internals.compare(a, b, aFirst, bFirst);\n\n if (compare !== null) {\n return compare;\n }\n\n if (settings.by) {\n a = settings.by.resolve(a, state, prefs);\n b = settings.by.resolve(b, state, prefs);\n }\n\n compare = internals.compare(a, b, aFirst, bFirst);\n\n if (compare !== null) {\n return compare;\n }\n\n var type = _typeof(a);\n\n if (type !== _typeof(b)) {\n throw schema.$_createError('array.sort.mismatching', value, null, state, prefs);\n }\n\n if (type !== 'number' && type !== 'string') {\n throw schema.$_createError('array.sort.unsupported', value, {\n type: type\n }, state, prefs);\n }\n\n if (type === 'number') {\n return (a - b) * order;\n }\n\n return a < b ? aFirst : bFirst;\n };\n\n try {\n return {\n value: value.slice().sort(sort)\n };\n } catch (err) {\n return {\n errors: err\n };\n }\n};\n\ninternals.compare = function (a, b, aFirst, bFirst) {\n if (a === b) {\n return 0;\n }\n\n if (a === undefined) {\n return 1; // Always last regardless of sort order\n }\n\n if (b === undefined) {\n return -1; // Always last regardless of sort order\n }\n\n if (a === null) {\n return bFirst;\n }\n\n if (b === null) {\n return aFirst;\n }\n\n return null;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Bourne = require('@hapi/bourne');\n\nconst DeepEqual = require('@hapi/hoek/lib/deepEqual');\n\nconst Reach = require('@hapi/hoek/lib/reach');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst Compile = require('../compile');\n\nconst internals = {};\nmodule.exports = Any.extend({\n type: 'array',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.items = [];\n schema.$_terms.ordered = [];\n schema.$_terms._inclusions = [];\n schema.$_terms._exclusions = [];\n schema.$_terms._requireds = [];\n },\n // Coerce\n coerce: {\n method: function method(schema, value, _ref) {\n let {\n state,\n prefs\n } = _ref;\n const result = {\n value\n };\n\n if (typeof value === 'string') {\n if (value[0] !== '[' && !/^\\s*\\[/.test(value)) {\n return;\n }\n\n try {\n result.value = Bourne.parse(value);\n } catch (ignoreErr) {\n return;\n }\n }\n\n if (!Array.isArray(result.value)) {\n return;\n }\n\n const sort = schema.$_getRule('sort');\n\n if (sort) {\n return internals.sort(schema, result.value, sort.args.options, state, prefs);\n }\n\n return result;\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n let {\n error\n } = _ref2;\n\n if (!Array.isArray(value)) {\n if (schema._flags.single) {\n const single = [value];\n single[Common.symbols.arraySingle] = true;\n return {\n value: single\n };\n }\n\n return {\n errors: error('array.base')\n };\n }\n\n if (!schema.$_getRule('items') && !schema.$_terms.externals) {\n return;\n }\n\n return {\n value: value.slice()\n }; // Clone the array so that we don't modify the original\n },\n // Rules\n rules: {\n has: {\n method: function method(schema) {\n schema = this.$_compile(schema, {\n appendPath: true\n });\n const obj = this.$_addRule({\n name: 'has',\n args: {\n schema\n }\n });\n obj.$_mutateRegister(schema);\n return obj;\n },\n validate: function validate(value, _ref3, _ref4) {\n let {\n state,\n prefs,\n error,\n schema\n } = _ref3;\n let {\n schema: has\n } = _ref4;\n const ancestors = [value, ...state.ancestors];\n\n for (let i = 0; i < value.length; ++i) {\n const localState = state.localize([...state.path, i], ancestors, has);\n\n if (has.$_match(value[i], localState, prefs)) {\n return value;\n }\n }\n\n const patternLabel = has._flags.label;\n\n if (patternLabel) {\n return error('array.hasKnown', {\n patternLabel\n });\n }\n\n return error('array.hasUnknown', null);\n },\n multi: true\n },\n items: {\n method: function method() {\n for (var _len = arguments.length, schemas = new Array(_len), _key = 0; _key < _len; _key++) {\n schemas[_key] = arguments[_key];\n }\n\n Common.verifyFlat(schemas, 'items');\n const obj = this.$_addRule('items');\n\n for (let i = 0; i < schemas.length; ++i) {\n const type = Common.tryWithPath(() => this.$_compile(schemas[i]), i, {\n append: true\n });\n obj.$_terms.items.push(type);\n }\n\n return obj.$_mutateRebuild();\n },\n validate: function validate(value, _ref5) {\n let {\n schema,\n error,\n state,\n prefs\n } = _ref5;\n\n const requireds = schema.$_terms._requireds.slice();\n\n const ordereds = schema.$_terms.ordered.slice();\n const inclusions = [...schema.$_terms._inclusions, ...requireds];\n const wasArray = !value[Common.symbols.arraySingle];\n const errors = [];\n let il = value.length;\n\n for (let i = 0; i < il; ++i) {\n const item = value[i];\n let errored = false;\n let isValid = false;\n const key = wasArray ? i : new Number(i); // eslint-disable-line no-new-wrappers\n\n const path = [...state.path, key]; // Sparse\n\n if (!schema._flags.sparse && item === undefined) {\n errors.push(error('array.sparse', {\n key,\n path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n ordereds.shift();\n continue;\n } // Exclusions\n\n\n const ancestors = [value, ...state.ancestors];\n\n for (const exclusion of schema.$_terms._exclusions) {\n if (!exclusion.$_match(item, state.localize(path, ancestors, exclusion), prefs)) {\n continue;\n }\n\n errors.push(error('array.excludes', {\n pos: i,\n value: item\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n errored = true;\n ordereds.shift();\n break;\n }\n\n if (errored) {\n continue;\n } // Ordered\n\n\n if (schema.$_terms.ordered.length) {\n if (ordereds.length) {\n const ordered = ordereds.shift();\n const res = ordered.$_validate(item, state.localize(path, ancestors, ordered), prefs);\n\n if (!res.errors) {\n if (ordered._flags.result === 'strip') {\n internals.fastSplice(value, i);\n --i;\n --il;\n } else if (!schema._flags.sparse && res.value === undefined) {\n errors.push(error('array.sparse', {\n key,\n path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n continue;\n } else {\n value[i] = res.value;\n }\n } else {\n errors.push(...res.errors);\n\n if (prefs.abortEarly) {\n return errors;\n }\n }\n\n continue;\n } else if (!schema.$_terms.items.length) {\n errors.push(error('array.orderedLength', {\n pos: i,\n limit: schema.$_terms.ordered.length\n }));\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n break; // No reason to continue since there are no other rules to validate other than array.orderedLength\n }\n } // Requireds\n\n\n const requiredChecks = [];\n let jl = requireds.length;\n\n for (let j = 0; j < jl; ++j) {\n const res = requireds[j].$_validate(item, state.localize(path, ancestors, requireds[j]), prefs);\n requiredChecks[j] = res;\n\n if (!res.errors) {\n value[i] = res.value;\n isValid = true;\n internals.fastSplice(requireds, j);\n --j;\n --jl;\n\n if (!schema._flags.sparse && res.value === undefined) {\n errors.push(error('array.sparse', {\n key,\n path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n }\n\n break;\n }\n }\n\n if (isValid) {\n continue;\n } // Inclusions\n\n\n const stripUnknown = prefs.stripUnknown && !!prefs.stripUnknown.arrays || false;\n jl = inclusions.length;\n\n for (const inclusion of inclusions) {\n // Avoid re-running requireds that already didn't match in the previous loop\n let res;\n const previousCheck = requireds.indexOf(inclusion);\n\n if (previousCheck !== -1) {\n res = requiredChecks[previousCheck];\n } else {\n res = inclusion.$_validate(item, state.localize(path, ancestors, inclusion), prefs);\n\n if (!res.errors) {\n if (inclusion._flags.result === 'strip') {\n internals.fastSplice(value, i);\n --i;\n --il;\n } else if (!schema._flags.sparse && res.value === undefined) {\n errors.push(error('array.sparse', {\n key,\n path,\n pos: i,\n value: undefined\n }, state.localize(path)));\n errored = true;\n } else {\n value[i] = res.value;\n }\n\n isValid = true;\n break;\n }\n } // Return the actual error if only one inclusion defined\n\n\n if (jl === 1) {\n if (stripUnknown) {\n internals.fastSplice(value, i);\n --i;\n --il;\n isValid = true;\n break;\n }\n\n errors.push(...res.errors);\n\n if (prefs.abortEarly) {\n return errors;\n }\n\n errored = true;\n break;\n }\n }\n\n if (errored) {\n continue;\n }\n\n if (schema.$_terms._inclusions.length && !isValid) {\n if (stripUnknown) {\n internals.fastSplice(value, i);\n --i;\n --il;\n continue;\n }\n\n errors.push(error('array.includes', {\n pos: i,\n value: item\n }, state.localize(path)));\n\n if (prefs.abortEarly) {\n return errors;\n }\n }\n }\n\n if (requireds.length) {\n internals.fillMissedErrors(schema, errors, requireds, value, state, prefs);\n }\n\n if (ordereds.length) {\n internals.fillOrderedErrors(schema, errors, ordereds, value, state, prefs);\n }\n\n return errors.length ? errors : value;\n },\n priority: true\n },\n length: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'length',\n args: {\n limit\n },\n operator: '='\n });\n },\n validate: function validate(value, helpers, _ref6, _ref7) {\n let {\n limit\n } = _ref6;\n let {\n name,\n operator,\n args\n } = _ref7;\n\n if (Common.compare(value.length, limit, operator)) {\n return value;\n }\n\n return helpers.error('array.' + name, {\n limit: args.limit,\n value\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.limit,\n message: 'must be a positive integer'\n }]\n },\n max: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'max',\n method: 'length',\n args: {\n limit\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'min',\n method: 'length',\n args: {\n limit\n },\n operator: '>='\n });\n }\n },\n ordered: {\n method: function method() {\n for (var _len2 = arguments.length, schemas = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n schemas[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(schemas, 'ordered');\n const obj = this.$_addRule('items');\n\n for (let i = 0; i < schemas.length; ++i) {\n const type = Common.tryWithPath(() => this.$_compile(schemas[i]), i, {\n append: true\n });\n internals.validateSingle(type, obj);\n obj.$_mutateRegister(type);\n obj.$_terms.ordered.push(type);\n }\n\n return obj.$_mutateRebuild();\n }\n },\n single: {\n method: function method(enabled) {\n const value = enabled === undefined ? true : !!enabled;\n Assert(!value || !this._flags._arrayItems, 'Cannot specify single rule when array has array items');\n return this.$_setFlag('single', value);\n }\n },\n sort: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['by', 'order']);\n const settings = {\n order: options.order || 'ascending'\n };\n\n if (options.by) {\n settings.by = Compile.ref(options.by, {\n ancestor: 0\n });\n Assert(!settings.by.ancestor, 'Cannot sort by ancestor');\n }\n\n return this.$_addRule({\n name: 'sort',\n args: {\n options: settings\n }\n });\n },\n validate: function validate(value, _ref8, _ref9) {\n let {\n error,\n state,\n prefs,\n schema\n } = _ref8;\n let {\n options\n } = _ref9;\n const {\n value: sorted,\n errors\n } = internals.sort(schema, value, options, state, prefs);\n\n if (errors) {\n return errors;\n }\n\n for (let i = 0; i < value.length; ++i) {\n if (value[i] !== sorted[i]) {\n return error('array.sort', {\n order: options.order,\n by: options.by ? options.by.key : 'value'\n });\n }\n }\n\n return value;\n },\n convert: true\n },\n sparse: {\n method: function method(enabled) {\n const value = enabled === undefined ? true : !!enabled;\n\n if (this._flags.sparse === value) {\n return this;\n }\n\n const obj = value ? this.clone() : this.$_addRule('items');\n return obj.$_setFlag('sparse', value, {\n clone: false\n });\n }\n },\n unique: {\n method: function method(comparator) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(!comparator || typeof comparator === 'function' || typeof comparator === 'string', 'comparator must be a function or a string');\n Common.assertOptions(options, ['ignoreUndefined', 'separator']);\n const rule = {\n name: 'unique',\n args: {\n options,\n comparator\n }\n };\n\n if (comparator) {\n if (typeof comparator === 'string') {\n const separator = Common.default(options.separator, '.');\n rule.path = separator ? comparator.split(separator) : [comparator];\n } else {\n rule.comparator = comparator;\n }\n }\n\n return this.$_addRule(rule);\n },\n validate: function validate(value, _ref10, _ref11, _ref12) {\n let {\n state,\n error,\n schema\n } = _ref10;\n let {\n comparator: raw,\n options\n } = _ref11;\n let {\n comparator,\n path\n } = _ref12;\n const found = {\n string: Object.create(null),\n number: Object.create(null),\n undefined: Object.create(null),\n boolean: Object.create(null),\n object: new Map(),\n function: new Map(),\n custom: new Map()\n };\n const compare = comparator || DeepEqual;\n const ignoreUndefined = options.ignoreUndefined;\n\n for (let i = 0; i < value.length; ++i) {\n const item = path ? Reach(value[i], path) : value[i];\n const records = comparator ? found.custom : found[typeof item];\n Assert(records, 'Failed to find unique map container for type', typeof item);\n\n if (records instanceof Map) {\n const entries = records.entries();\n let current;\n\n while (!(current = entries.next()).done) {\n if (compare(current.value[0], item)) {\n const localState = state.localize([...state.path, i], [value, ...state.ancestors]);\n const context = {\n pos: i,\n value: value[i],\n dupePos: current.value[1],\n dupeValue: value[current.value[1]]\n };\n\n if (path) {\n context.path = raw;\n }\n\n return error('array.unique', context, localState);\n }\n }\n\n records.set(item, i);\n } else {\n if ((!ignoreUndefined || item !== undefined) && records[item] !== undefined) {\n const context = {\n pos: i,\n value: value[i],\n dupePos: records[item],\n dupeValue: value[records[item]]\n };\n\n if (path) {\n context.path = raw;\n }\n\n const localState = state.localize([...state.path, i], [value, ...state.ancestors]);\n return error('array.unique', context, localState);\n }\n\n records[item] = i;\n }\n }\n\n return value;\n },\n args: ['comparator', 'options'],\n multi: true\n }\n },\n // Cast\n cast: {\n set: {\n from: Array.isArray,\n to: function to(value, helpers) {\n return new Set(value);\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n if (desc.items) {\n obj = obj.items(...desc.items);\n }\n\n if (desc.ordered) {\n obj = obj.ordered(...desc.ordered);\n }\n\n return obj;\n },\n // Modify\n modify: function modify(schema, id, replacement) {\n for (const set of ['items', 'ordered']) {\n for (let i = 0; i < schema.$_terms[set].length; ++i) {\n const existing = schema.$_terms[set][i];\n\n if (id === existing._flags.id) {\n const obj = schema.clone();\n obj.$_terms[set][i] = replacement;\n return obj.$_mutateRebuild();\n }\n }\n }\n\n const hases = schema.$_getRules('has');\n\n for (const has of hases) {\n if (id === has.args.schema._flags.id) {\n const obj = schema.clone();\n has.args.schema = replacement;\n return obj.$_mutateRebuild();\n }\n }\n },\n rebuild: function rebuild(schema) {\n schema.$_terms._inclusions = [];\n schema.$_terms._exclusions = [];\n schema.$_terms._requireds = [];\n\n for (const type of schema.$_terms.items) {\n internals.validateSingle(type, schema);\n schema.$_mutateRegister(type);\n\n if (type._flags.presence === 'required') {\n schema.$_terms._requireds.push(type);\n } else if (type._flags.presence === 'forbidden') {\n schema.$_terms._exclusions.push(type.optional());\n } else {\n schema.$_terms._inclusions.push(type);\n }\n }\n\n for (const type of schema.$_terms.ordered) {\n internals.validateSingle(type, schema);\n schema.$_mutateRegister(type);\n }\n\n const hases = schema.$_getRules('has');\n\n for (const has of hases) {\n schema.$_mutateRegister(has.args.schema);\n }\n\n return schema;\n },\n // Errors\n messages: {\n 'array.base': '\"{{#label}}\" must be an array',\n 'array.excludes': '\"{{#label}}\" contains an excluded value',\n 'array.hasKnown': '\"{{#label}}\" does not contain at least one required match for type \"{#patternLabel}\"',\n 'array.hasUnknown': '\"{{#label}}\" does not contain at least one required match',\n 'array.includes': '\"{{#label}}\" does not match any of the allowed types',\n 'array.includesRequiredBoth': '\"{{#label}}\" does not contain {{#knownMisses}} and {{#unknownMisses}} other required value(s)',\n 'array.includesRequiredKnowns': '\"{{#label}}\" does not contain {{#knownMisses}}',\n 'array.includesRequiredUnknowns': '\"{{#label}}\" does not contain {{#unknownMisses}} required value(s)',\n 'array.length': '\"{{#label}}\" must contain {{#limit}} items',\n 'array.max': '\"{{#label}}\" must contain less than or equal to {{#limit}} items',\n 'array.min': '\"{{#label}}\" must contain at least {{#limit}} items',\n 'array.orderedLength': '\"{{#label}}\" must contain at most {{#limit}} items',\n 'array.sort': '\"{{#label}}\" must be sorted in {#order} order by {{#by}}',\n 'array.sort.mismatching': '\"{{#label}}\" cannot be sorted due to mismatching types',\n 'array.sort.unsupported': '\"{{#label}}\" cannot be sorted due to unsupported type {#type}',\n 'array.sparse': '\"{{#label}}\" must not be a sparse array item',\n 'array.unique': '\"{{#label}}\" contains a duplicate value'\n }\n}); // Helpers\n\ninternals.fillMissedErrors = function (schema, errors, requireds, value, state, prefs) {\n const knownMisses = [];\n let unknownMisses = 0;\n\n for (const required of requireds) {\n const label = required._flags.label;\n\n if (label) {\n knownMisses.push(label);\n } else {\n ++unknownMisses;\n }\n }\n\n if (knownMisses.length) {\n if (unknownMisses) {\n errors.push(schema.$_createError('array.includesRequiredBoth', value, {\n knownMisses,\n unknownMisses\n }, state, prefs));\n } else {\n errors.push(schema.$_createError('array.includesRequiredKnowns', value, {\n knownMisses\n }, state, prefs));\n }\n } else {\n errors.push(schema.$_createError('array.includesRequiredUnknowns', value, {\n unknownMisses\n }, state, prefs));\n }\n};\n\ninternals.fillOrderedErrors = function (schema, errors, ordereds, value, state, prefs) {\n const requiredOrdereds = [];\n\n for (const ordered of ordereds) {\n if (ordered._flags.presence === 'required') {\n requiredOrdereds.push(ordered);\n }\n }\n\n if (requiredOrdereds.length) {\n internals.fillMissedErrors(schema, errors, requiredOrdereds, value, state, prefs);\n }\n};\n\ninternals.fastSplice = function (arr, i) {\n let pos = i;\n\n while (pos < arr.length) {\n arr[pos++] = arr[pos];\n }\n\n --arr.length;\n};\n\ninternals.validateSingle = function (type, obj) {\n if (type.type === 'array' || type._flags._arrayItems) {\n Assert(!obj._flags.single, 'Cannot specify array item with single rule enabled');\n obj.$_setFlag('_arrayItems', true, {\n clone: false\n });\n }\n};\n\ninternals.sort = function (schema, value, settings, state, prefs) {\n const order = settings.order === 'ascending' ? 1 : -1;\n const aFirst = -1 * order;\n const bFirst = order;\n\n const sort = (a, b) => {\n let compare = internals.compare(a, b, aFirst, bFirst);\n\n if (compare !== null) {\n return compare;\n }\n\n if (settings.by) {\n a = settings.by.resolve(a, state, prefs);\n b = settings.by.resolve(b, state, prefs);\n }\n\n compare = internals.compare(a, b, aFirst, bFirst);\n\n if (compare !== null) {\n return compare;\n }\n\n const type = typeof a;\n\n if (type !== typeof b) {\n throw schema.$_createError('array.sort.mismatching', value, null, state, prefs);\n }\n\n if (type !== 'number' && type !== 'string') {\n throw schema.$_createError('array.sort.unsupported', value, {\n type\n }, state, prefs);\n }\n\n if (type === 'number') {\n return (a - b) * order;\n }\n\n return a < b ? aFirst : bFirst;\n };\n\n try {\n return {\n value: value.slice().sort(sort)\n };\n } catch (err) {\n return {\n errors: err\n };\n }\n};\n\ninternals.compare = function (a, b, aFirst, bFirst) {\n if (a === b) {\n return 0;\n }\n\n if (a === undefined) {\n return 1; // Always last regardless of sort order\n }\n\n if (b === undefined) {\n return -1; // Always last regardless of sort order\n }\n\n if (a === null) {\n return bFirst;\n }\n\n if (b === null) {\n return aFirst;\n }\n\n return null;\n};" }, { - "id": 36, + "id": 35, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/boolean.js", "name": "../lib/types/boolean.js", "index": 32, "index2": 31, - "size": 3813, + "size": 3156, "cacheable": true, "built": true, "optional": false, @@ -7948,15 +7762,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -7970,7 +7784,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/boolean", - "loc": "41:13-39" + "loc": "27:13-39" } ], "usedExports": true, @@ -7979,15 +7793,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar Values = require('../values');\n\nvar internals = {};\n\ninternals.isBool = function (value) {\n return typeof value === 'boolean';\n};\n\nmodule.exports = Any.extend({\n type: 'boolean',\n // Initialize\n initialize: function initialize(schema) {\n schema._flags.insensitive = true;\n schema.$_terms.truthy = new Values();\n schema.$_terms.falsy = new Values();\n },\n // Coerce\n coerce: function coerce(schema, value, helpers) {\n if (typeof value === 'boolean') {\n return;\n }\n\n if (typeof value === 'string') {\n var normalized = schema._flags.insensitive ? value.toLowerCase() : value;\n value = normalized === 'true' ? true : normalized === 'false' ? false : value;\n }\n\n if (typeof value !== 'boolean') {\n value = schema.$_terms.truthy.has(value, null, null, schema._flags.insensitive) || (schema.$_terms.falsy.has(value, null, null, schema._flags.insensitive) ? false : value);\n }\n\n return {\n value: value\n };\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n var error = _ref.error;\n\n if (typeof value !== 'boolean') {\n return {\n value: value,\n errors: error('boolean.base')\n };\n }\n },\n // Rules\n rules: {\n truthy: {\n method: function method() {\n for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {\n values[_key] = arguments[_key];\n }\n\n Common.verifyFlat(values, 'truthy');\n var obj = this.clone();\n\n for (var i = 0; i < values.length; ++i) {\n var value = values[i];\n Assert(value !== undefined, 'Cannot call truthy with undefined');\n obj.$_terms.truthy.add(value);\n }\n\n return obj;\n }\n },\n falsy: {\n method: function method() {\n for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n values[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(values, 'falsy');\n var obj = this.clone();\n\n for (var i = 0; i < values.length; ++i) {\n var value = values[i];\n Assert(value !== undefined, 'Cannot call falsy with undefined');\n obj.$_terms.falsy.add(value);\n }\n\n return obj;\n }\n },\n insensitive: {\n method: function method(enabled) {\n return this.$_setFlag('insensitive', enabled !== false);\n }\n }\n },\n // Cast\n cast: {\n number: {\n from: internals.isBool,\n to: function to(value, helpers) {\n return value ? 1 : 0;\n }\n },\n string: {\n from: internals.isBool,\n to: function to(value, helpers) {\n return value ? 'true' : 'false';\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n if (desc.truthy) {\n var _obj;\n\n obj = (_obj = obj).truthy.apply(_obj, _toConsumableArray(desc.truthy));\n }\n\n if (desc.falsy) {\n var _obj2;\n\n obj = (_obj2 = obj).falsy.apply(_obj2, _toConsumableArray(desc.falsy));\n }\n\n return obj;\n },\n // Errors\n messages: {\n 'boolean.base': '\"{{#label}}\" must be a boolean'\n }\n});" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst Values = require('../values');\n\nconst internals = {};\n\ninternals.isBool = function (value) {\n return typeof value === 'boolean';\n};\n\nmodule.exports = Any.extend({\n type: 'boolean',\n // Initialize\n initialize: function initialize(schema) {\n schema._flags.insensitive = true;\n schema.$_terms.truthy = new Values();\n schema.$_terms.falsy = new Values();\n },\n // Coerce\n coerce: function coerce(schema, value, helpers) {\n if (typeof value === 'boolean') {\n return;\n }\n\n if (typeof value === 'string') {\n const normalized = schema._flags.insensitive ? value.toLowerCase() : value;\n value = normalized === 'true' ? true : normalized === 'false' ? false : value;\n }\n\n if (typeof value !== 'boolean') {\n value = schema.$_terms.truthy.has(value, null, null, schema._flags.insensitive) || (schema.$_terms.falsy.has(value, null, null, schema._flags.insensitive) ? false : value);\n }\n\n return {\n value\n };\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n let {\n error\n } = _ref;\n\n if (typeof value !== 'boolean') {\n return {\n value,\n errors: error('boolean.base')\n };\n }\n },\n // Rules\n rules: {\n truthy: {\n method: function method() {\n for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {\n values[_key] = arguments[_key];\n }\n\n Common.verifyFlat(values, 'truthy');\n const obj = this.clone();\n\n for (let i = 0; i < values.length; ++i) {\n const value = values[i];\n Assert(value !== undefined, 'Cannot call truthy with undefined');\n obj.$_terms.truthy.add(value);\n }\n\n return obj;\n }\n },\n falsy: {\n method: function method() {\n for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n values[_key2] = arguments[_key2];\n }\n\n Common.verifyFlat(values, 'falsy');\n const obj = this.clone();\n\n for (let i = 0; i < values.length; ++i) {\n const value = values[i];\n Assert(value !== undefined, 'Cannot call falsy with undefined');\n obj.$_terms.falsy.add(value);\n }\n\n return obj;\n }\n },\n insensitive: {\n method: function method(enabled) {\n return this.$_setFlag('insensitive', enabled !== false);\n }\n }\n },\n // Cast\n cast: {\n number: {\n from: internals.isBool,\n to: function to(value, helpers) {\n return value ? 1 : 0;\n }\n },\n string: {\n from: internals.isBool,\n to: function to(value, helpers) {\n return value ? 'true' : 'false';\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n if (desc.truthy) {\n obj = obj.truthy(...desc.truthy);\n }\n\n if (desc.falsy) {\n obj = obj.falsy(...desc.falsy);\n }\n\n return obj;\n },\n // Errors\n messages: {\n 'boolean.base': '\"{{#label}}\" must be a boolean'\n }\n});" }, { - "id": 37, + "id": 36, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/date.js", "name": "../lib/types/date.js", "index": 33, "index2": 32, - "size": 5384, + "size": 5305, "cacheable": true, "built": true, "optional": false, @@ -8004,15 +7818,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -8026,7 +7840,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/date", - "loc": "42:10-33" + "loc": "28:10-33" } ], "usedExports": true, @@ -8035,15 +7849,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar Template = require('../template');\n\nvar internals = {};\n\ninternals.isDate = function (value) {\n return value instanceof Date;\n};\n\nmodule.exports = Any.extend({\n type: 'date',\n // Coerce\n coerce: {\n from: ['number', 'string'],\n method: function method(schema, value, helpers) {\n return {\n value: internals.parse(value, schema._flags.format) || value\n };\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n var error = _ref.error,\n prefs = _ref.prefs;\n\n if (value instanceof Date && !isNaN(value.getTime())) {\n return;\n }\n\n if (!prefs.convert) {\n return {\n value: value,\n errors: error('date.strict')\n };\n }\n\n var format = schema._flags.format;\n var code = !format ? 'date.base' : format === 'iso' ? 'date.isoDate' : \"date.timestamp.\".concat(format);\n return {\n value: value,\n errors: error(code)\n };\n },\n // Rules\n rules: {\n compare: {\n method: false,\n validate: function validate(value, helpers, _ref2, _ref3) {\n var date = _ref2.date;\n var name = _ref3.name,\n operator = _ref3.operator,\n args = _ref3.args;\n var to = date === 'now' ? Date.now() : date.getTime();\n\n if (Common.compare(value.getTime(), to, operator)) {\n return value;\n }\n\n return helpers.error('date.' + name, {\n limit: args.date,\n value: value\n });\n },\n args: [{\n name: 'date',\n ref: true,\n normalize: function normalize(date) {\n return date === 'now' ? date : internals.parse(date);\n },\n assert: function assert(date) {\n return date !== null;\n },\n message: 'must have a valid date format'\n }]\n },\n format: {\n method: function method(format) {\n Assert(['iso', 'javascript', 'unix'].includes(format), 'Unknown date format', format);\n return this.$_setFlag('format', format);\n }\n },\n greater: {\n method: function method(date) {\n return this.$_addRule({\n name: 'greater',\n method: 'compare',\n args: {\n date: date\n },\n operator: '>'\n });\n }\n },\n iso: {\n method: function method() {\n return this.format('iso');\n }\n },\n less: {\n method: function method(date) {\n return this.$_addRule({\n name: 'less',\n method: 'compare',\n args: {\n date: date\n },\n operator: '<'\n });\n }\n },\n max: {\n method: function method(date) {\n return this.$_addRule({\n name: 'max',\n method: 'compare',\n args: {\n date: date\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(date) {\n return this.$_addRule({\n name: 'min',\n method: 'compare',\n args: {\n date: date\n },\n operator: '>='\n });\n }\n },\n timestamp: {\n method: function method() {\n var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'javascript';\n Assert(['javascript', 'unix'].includes(type), '\"type\" must be one of \"javascript, unix\"');\n return this.format(type);\n }\n }\n },\n // Cast\n cast: {\n number: {\n from: internals.isDate,\n to: function to(value, helpers) {\n return value.getTime();\n }\n },\n string: {\n from: internals.isDate,\n to: function to(value, _ref4) {\n var prefs = _ref4.prefs;\n return Template.date(value, prefs);\n }\n }\n },\n // Errors\n messages: {\n 'date.base': '\"{{#label}}\" must be a number of milliseconds or valid date string',\n 'date.greater': '\"{{#label}}\" must be greater than \"{{#limit}}\"',\n 'date.isoDate': '\"{{#label}}\" must be a valid ISO 8601 date',\n 'date.less': '\"{{#label}}\" must be less than \"{{#limit}}\"',\n 'date.max': '\"{{#label}}\" must be less than or equal to \"{{#limit}}\"',\n 'date.min': '\"{{#label}}\" must be larger than or equal to \"{{#limit}}\"',\n 'date.strict': '\"{{#label}}\" must be a valid date',\n 'date.timestamp.javascript': '\"{{#label}}\" must be a valid timestamp or number of milliseconds',\n 'date.timestamp.unix': '\"{{#label}}\" must be a valid timestamp or number of seconds'\n }\n}); // Helpers\n\ninternals.parse = function (value, format) {\n if (value instanceof Date) {\n return value;\n }\n\n if (typeof value !== 'string' && (isNaN(value) || !isFinite(value))) {\n return null;\n } // ISO\n\n\n if (format === 'iso') {\n if (!Common.isIsoDate(value)) {\n return null;\n }\n\n return internals.date(value.toString());\n } // Normalize number string\n\n\n if (typeof value === 'string' && /^[+-]?\\d+(\\.\\d+)?$/.test(value)) {\n value = parseFloat(value);\n } // Timestamp\n\n\n if (format) {\n if (/^\\s*$/.test(value)) {\n return null;\n }\n\n return internals.date(value * (format === 'unix' ? 1000 : 1));\n } // Plain\n\n\n return internals.date(value);\n};\n\ninternals.date = function (value) {\n var date = new Date(value);\n\n if (!isNaN(date.getTime())) {\n return date;\n }\n\n return null;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst Template = require('../template');\n\nconst internals = {};\n\ninternals.isDate = function (value) {\n return value instanceof Date;\n};\n\nmodule.exports = Any.extend({\n type: 'date',\n // Coerce\n coerce: {\n from: ['number', 'string'],\n method: function method(schema, value, helpers) {\n return {\n value: internals.parse(value, schema._flags.format) || value\n };\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n let {\n error,\n prefs\n } = _ref;\n\n if (value instanceof Date && !isNaN(value.getTime())) {\n return;\n }\n\n if (!prefs.convert) {\n return {\n value,\n errors: error('date.strict')\n };\n }\n\n const format = schema._flags.format;\n const code = !format ? 'date.base' : format === 'iso' ? 'date.isoDate' : \"date.timestamp.\".concat(format);\n return {\n value,\n errors: error(code)\n };\n },\n // Rules\n rules: {\n compare: {\n method: false,\n validate: function validate(value, helpers, _ref2, _ref3) {\n let {\n date\n } = _ref2;\n let {\n name,\n operator,\n args\n } = _ref3;\n const to = date === 'now' ? Date.now() : date.getTime();\n\n if (Common.compare(value.getTime(), to, operator)) {\n return value;\n }\n\n return helpers.error('date.' + name, {\n limit: args.date,\n value\n });\n },\n args: [{\n name: 'date',\n ref: true,\n normalize: date => {\n return date === 'now' ? date : internals.parse(date);\n },\n assert: date => date !== null,\n message: 'must have a valid date format'\n }]\n },\n format: {\n method: function method(format) {\n Assert(['iso', 'javascript', 'unix'].includes(format), 'Unknown date format', format);\n return this.$_setFlag('format', format);\n }\n },\n greater: {\n method: function method(date) {\n return this.$_addRule({\n name: 'greater',\n method: 'compare',\n args: {\n date\n },\n operator: '>'\n });\n }\n },\n iso: {\n method: function method() {\n return this.format('iso');\n }\n },\n less: {\n method: function method(date) {\n return this.$_addRule({\n name: 'less',\n method: 'compare',\n args: {\n date\n },\n operator: '<'\n });\n }\n },\n max: {\n method: function method(date) {\n return this.$_addRule({\n name: 'max',\n method: 'compare',\n args: {\n date\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(date) {\n return this.$_addRule({\n name: 'min',\n method: 'compare',\n args: {\n date\n },\n operator: '>='\n });\n }\n },\n timestamp: {\n method: function method() {\n let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'javascript';\n Assert(['javascript', 'unix'].includes(type), '\"type\" must be one of \"javascript, unix\"');\n return this.format(type);\n }\n }\n },\n // Cast\n cast: {\n number: {\n from: internals.isDate,\n to: function to(value, helpers) {\n return value.getTime();\n }\n },\n string: {\n from: internals.isDate,\n to: function to(value, _ref4) {\n let {\n prefs\n } = _ref4;\n return Template.date(value, prefs);\n }\n }\n },\n // Errors\n messages: {\n 'date.base': '\"{{#label}}\" must be a number of milliseconds or valid date string',\n 'date.greater': '\"{{#label}}\" must be greater than \"{{#limit}}\"',\n 'date.isoDate': '\"{{#label}}\" must be a valid ISO 8601 date',\n 'date.less': '\"{{#label}}\" must be less than \"{{#limit}}\"',\n 'date.max': '\"{{#label}}\" must be less than or equal to \"{{#limit}}\"',\n 'date.min': '\"{{#label}}\" must be larger than or equal to \"{{#limit}}\"',\n 'date.strict': '\"{{#label}}\" must be a valid date',\n 'date.timestamp.javascript': '\"{{#label}}\" must be a valid timestamp or number of milliseconds',\n 'date.timestamp.unix': '\"{{#label}}\" must be a valid timestamp or number of seconds'\n }\n}); // Helpers\n\ninternals.parse = function (value, format) {\n if (value instanceof Date) {\n return value;\n }\n\n if (typeof value !== 'string' && (isNaN(value) || !isFinite(value))) {\n return null;\n } // ISO\n\n\n if (format === 'iso') {\n if (!Common.isIsoDate(value)) {\n return null;\n }\n\n return internals.date(value.toString());\n } // Normalize number string\n\n\n if (typeof value === 'string' && /^[+-]?\\d+(\\.\\d+)?$/.test(value)) {\n value = parseFloat(value);\n } // Timestamp\n\n\n if (format) {\n if (/^\\s*$/.test(value)) {\n return null;\n }\n\n return internals.date(value * (format === 'unix' ? 1000 : 1));\n } // Plain\n\n\n return internals.date(value);\n};\n\ninternals.date = function (value) {\n const date = new Date(value);\n\n if (!isNaN(date.getTime())) {\n return date;\n }\n\n return null;\n};" }, { - "id": 38, + "id": 37, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/function.js", "name": "../lib/types/function.js", "index": 34, "index2": 36, - "size": 2495, + "size": 2536, "cacheable": true, "built": true, "optional": false, @@ -8060,15 +7874,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -8082,7 +7896,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/function", - "loc": "43:14-41" + "loc": "29:14-41" } ], "usedExports": true, @@ -8091,15 +7905,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar ObjectType = require('./object');\n\nvar internals = {};\nmodule.exports = ObjectType.extend({\n type: 'function',\n properties: {\n typeof: 'function'\n },\n // Rules\n rules: {\n arity: {\n method: function method(n) {\n Assert(Number.isSafeInteger(n) && n >= 0, 'n must be a positive integer');\n return this.$_addRule({\n name: 'arity',\n args: {\n n: n\n }\n });\n },\n validate: function validate(value, helpers, _ref) {\n var n = _ref.n;\n\n if (value.length === n) {\n return value;\n }\n\n return helpers.error('function.arity', {\n n: n\n });\n }\n },\n class: {\n method: function method() {\n return this.$_addRule('class');\n },\n validate: function validate(value, helpers) {\n if (/^\\s*class\\s/.test(value.toString())) {\n return value;\n }\n\n return helpers.error('function.class', {\n value: value\n });\n }\n },\n minArity: {\n method: function method(n) {\n Assert(Number.isSafeInteger(n) && n > 0, 'n must be a strict positive integer');\n return this.$_addRule({\n name: 'minArity',\n args: {\n n: n\n }\n });\n },\n validate: function validate(value, helpers, _ref2) {\n var n = _ref2.n;\n\n if (value.length >= n) {\n return value;\n }\n\n return helpers.error('function.minArity', {\n n: n\n });\n }\n },\n maxArity: {\n method: function method(n) {\n Assert(Number.isSafeInteger(n) && n >= 0, 'n must be a positive integer');\n return this.$_addRule({\n name: 'maxArity',\n args: {\n n: n\n }\n });\n },\n validate: function validate(value, helpers, _ref3) {\n var n = _ref3.n;\n\n if (value.length <= n) {\n return value;\n }\n\n return helpers.error('function.maxArity', {\n n: n\n });\n }\n }\n },\n // Cast\n cast: {\n map: null // Disable object cast\n\n },\n // Errors\n messages: {\n 'function.arity': '\"{{#label}}\" must have an arity of {{#n}}',\n 'function.class': '\"{{#label}}\" must be a class',\n 'function.maxArity': '\"{{#label}}\" must have an arity lesser or equal to {{#n}}',\n 'function.minArity': '\"{{#label}}\" must have an arity greater or equal to {{#n}}'\n }\n});" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst ObjectType = require('./object');\n\nconst internals = {};\nmodule.exports = ObjectType.extend({\n type: 'function',\n properties: {\n typeof: 'function'\n },\n // Rules\n rules: {\n arity: {\n method: function method(n) {\n Assert(Number.isSafeInteger(n) && n >= 0, 'n must be a positive integer');\n return this.$_addRule({\n name: 'arity',\n args: {\n n\n }\n });\n },\n validate: function validate(value, helpers, _ref) {\n let {\n n\n } = _ref;\n\n if (value.length === n) {\n return value;\n }\n\n return helpers.error('function.arity', {\n n\n });\n }\n },\n class: {\n method: function method() {\n return this.$_addRule('class');\n },\n validate: function validate(value, helpers) {\n if (/^\\s*class\\s/.test(value.toString())) {\n return value;\n }\n\n return helpers.error('function.class', {\n value\n });\n }\n },\n minArity: {\n method: function method(n) {\n Assert(Number.isSafeInteger(n) && n > 0, 'n must be a strict positive integer');\n return this.$_addRule({\n name: 'minArity',\n args: {\n n\n }\n });\n },\n validate: function validate(value, helpers, _ref2) {\n let {\n n\n } = _ref2;\n\n if (value.length >= n) {\n return value;\n }\n\n return helpers.error('function.minArity', {\n n\n });\n }\n },\n maxArity: {\n method: function method(n) {\n Assert(Number.isSafeInteger(n) && n >= 0, 'n must be a positive integer');\n return this.$_addRule({\n name: 'maxArity',\n args: {\n n\n }\n });\n },\n validate: function validate(value, helpers, _ref3) {\n let {\n n\n } = _ref3;\n\n if (value.length <= n) {\n return value;\n }\n\n return helpers.error('function.maxArity', {\n n\n });\n }\n }\n },\n // Cast\n cast: {\n map: null // Disable object cast\n\n },\n // Errors\n messages: {\n 'function.arity': '\"{{#label}}\" must have an arity of {{#n}}',\n 'function.class': '\"{{#label}}\" must be a class',\n 'function.maxArity': '\"{{#label}}\" must have an arity lesser or equal to {{#n}}',\n 'function.minArity': '\"{{#label}}\" must have an arity greater or equal to {{#n}}'\n }\n});" }, { - "id": 39, + "id": 38, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/applyToDefaults.js", "name": "../node_modules/@hapi/hoek/lib/applyToDefaults.js", "index": 36, "index2": 33, - "size": 2108, + "size": 1755, "cacheable": true, "built": true, "optional": false, @@ -8116,8 +7930,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -8125,16 +7939,16 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/object.js", "name": "../lib/types/object.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 609, - "building": 122, - "dependencies": 125 + "factory": 390, + "building": 59, + "dependencies": 76 }, "failed": false, "errors": 0, @@ -8148,7 +7962,7 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/applyToDefaults", - "loc": "39:22-63" + "loc": "3:24-65" } ], "usedExports": true, @@ -8157,15 +7971,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('./assert');\n\nvar Clone = require('./clone');\n\nvar Merge = require('./merge');\n\nvar Utils = require('./utils');\n\nvar internals = {};\n\nmodule.exports = function (defaults, source) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(defaults && _typeof(defaults) === 'object', 'Invalid defaults value: must be an object');\n Assert(!source || source === true || _typeof(source) === 'object', 'Invalid source value: must be true, falsy or an object');\n Assert(_typeof(options) === 'object', 'Invalid options: must be an object');\n\n if (!source) {\n // If no source, return null\n return null;\n }\n\n if (options.shallow) {\n return internals.applyToDefaultsWithShallow(defaults, source, options);\n }\n\n var copy = Clone(defaults);\n\n if (source === true) {\n // If source is set to true, use defaults\n return copy;\n }\n\n var nullOverride = options.nullOverride !== undefined ? options.nullOverride : false;\n return Merge(copy, source, {\n nullOverride: nullOverride,\n mergeArrays: false\n });\n};\n\ninternals.applyToDefaultsWithShallow = function (defaults, source, options) {\n var keys = options.shallow;\n Assert(Array.isArray(keys), 'Invalid keys');\n options = Object.assign({}, options);\n options.shallow = false;\n var copy = Clone(defaults, {\n shallow: keys\n });\n\n if (source === true) {\n // If source is set to true, use defaults\n return copy;\n }\n\n var storage = Utils.store(source, keys); // Move shallow copy items to storage\n\n Merge(copy, source, {\n mergeArrays: false,\n nullOverride: false\n }); // Deep copy the rest\n\n Utils.restore(copy, source, storage); // Shallow copy the stored items and restore\n\n return copy;\n};" + "source": "'use strict';\n\nconst Assert = require('./assert');\n\nconst Clone = require('./clone');\n\nconst Merge = require('./merge');\n\nconst Utils = require('./utils');\n\nconst internals = {};\n\nmodule.exports = function (defaults, source) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n Assert(defaults && typeof defaults === 'object', 'Invalid defaults value: must be an object');\n Assert(!source || source === true || typeof source === 'object', 'Invalid source value: must be true, falsy or an object');\n Assert(typeof options === 'object', 'Invalid options: must be an object');\n\n if (!source) {\n // If no source, return null\n return null;\n }\n\n if (options.shallow) {\n return internals.applyToDefaultsWithShallow(defaults, source, options);\n }\n\n const copy = Clone(defaults);\n\n if (source === true) {\n // If source is set to true, use defaults\n return copy;\n }\n\n const nullOverride = options.nullOverride !== undefined ? options.nullOverride : false;\n return Merge(copy, source, {\n nullOverride,\n mergeArrays: false\n });\n};\n\ninternals.applyToDefaultsWithShallow = function (defaults, source, options) {\n const keys = options.shallow;\n Assert(Array.isArray(keys), 'Invalid keys');\n options = Object.assign({}, options);\n options.shallow = false;\n const copy = Clone(defaults, {\n shallow: keys\n });\n\n if (source === true) {\n // If source is set to true, use defaults\n return copy;\n }\n\n const storage = Utils.store(source, keys); // Move shallow copy items to storage\n\n Merge(copy, source, {\n mergeArrays: false,\n nullOverride: false\n }); // Deep copy the rest\n\n Utils.restore(copy, source, storage); // Shallow copy the stored items and restore\n\n return copy;\n};" }, { - "id": 40, + "id": 39, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/topo/lib/index.js", "name": "../node_modules/@hapi/topo/lib/index.js", "index": 37, "index2": 34, - "size": 6755, + "size": 5433, "cacheable": true, "built": true, "optional": false, @@ -8182,8 +7996,8 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { @@ -8191,16 +8005,16 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/object.js", "name": "../lib/types/object.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 609, - "building": 122, - "dependencies": 125 + "factory": 390, + "building": 59, + "dependencies": 76 }, "failed": false, "errors": 0, @@ -8214,7 +8028,7 @@ "moduleName": "../lib/types/object.js", "type": "cjs require", "userRequest": "@hapi/topo", - "loc": "47:11-32" + "loc": "11:13-34" } ], "usedExports": true, @@ -8223,15 +8037,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar internals = {};\n\nmodule.exports =\n/*#__PURE__*/\nfunction () {\n function Topo() {\n _classCallCheck(this, Topo);\n\n this._items = [];\n this.nodes = [];\n }\n\n _createClass(Topo, [{\n key: \"add\",\n value: function add(nodes, options) {\n var _this = this;\n\n options = options || {}; // Validate rules\n\n var before = [].concat(options.before || []);\n var after = [].concat(options.after || []);\n var group = options.group || '?';\n var sort = options.sort || 0; // Used for merging only\n\n Assert(!before.includes(group), \"Item cannot come before itself: \".concat(group));\n Assert(!before.includes('?'), 'Item cannot come before unassociated items');\n Assert(!after.includes(group), \"Item cannot come after itself: \".concat(group));\n Assert(!after.includes('?'), 'Item cannot come after unassociated items');\n [].concat(nodes).forEach(function (node, i) {\n var item = {\n seq: _this._items.length,\n sort: sort,\n before: before,\n after: after,\n group: group,\n node: node\n };\n\n _this._items.push(item);\n }); // Insert event\n\n var error = this._sort();\n\n Assert(!error, 'item', group !== '?' ? \"added into group \".concat(group) : '', 'created a dependencies error');\n return this.nodes;\n }\n }, {\n key: \"merge\",\n value: function merge(others) {\n others = [].concat(others);\n\n for (var i = 0; i < others.length; ++i) {\n var other = others[i];\n\n if (other) {\n for (var j = 0; j < other._items.length; ++j) {\n var item = Object.assign({}, other._items[j]); // Shallow cloned\n\n this._items.push(item);\n }\n }\n } // Sort items\n\n\n this._items.sort(internals.mergeSort);\n\n for (var _i = 0; _i < this._items.length; ++_i) {\n this._items[_i].seq = _i;\n }\n\n var error = this._sort();\n\n Assert(!error, 'merge created a dependencies error');\n return this.nodes;\n }\n }, {\n key: \"_sort\",\n value: function _sort() {\n // Construct graph\n var graph = {};\n var graphAfters = Object.create(null); // A prototype can bungle lookups w/ false positives\n\n var groups = Object.create(null);\n\n for (var i = 0; i < this._items.length; ++i) {\n var item = this._items[i];\n var seq = item.seq; // Unique across all items\n\n var group = item.group; // Determine Groups\n\n groups[group] = groups[group] || [];\n groups[group].push(seq); // Build intermediary graph using 'before'\n\n graph[seq] = item.before; // Build second intermediary graph with 'after'\n\n var after = item.after;\n\n for (var j = 0; j < after.length; ++j) {\n graphAfters[after[j]] = (graphAfters[after[j]] || []).concat(seq);\n }\n } // Expand intermediary graph\n\n\n var graphNodes = Object.keys(graph);\n\n for (var _i2 = 0; _i2 < graphNodes.length; ++_i2) {\n var node = graphNodes[_i2];\n var expandedGroups = [];\n var graphNodeItems = Object.keys(graph[node]);\n\n for (var _j = 0; _j < graphNodeItems.length; ++_j) {\n var _group = graph[node][graphNodeItems[_j]];\n groups[_group] = groups[_group] || [];\n\n for (var k = 0; k < groups[_group].length; ++k) {\n expandedGroups.push(groups[_group][k]);\n }\n }\n\n graph[node] = expandedGroups;\n } // Merge intermediary graph using graphAfters into final graph\n\n\n var afterNodes = Object.keys(graphAfters);\n\n for (var _i3 = 0; _i3 < afterNodes.length; ++_i3) {\n var _group2 = afterNodes[_i3];\n\n if (groups[_group2]) {\n for (var _j2 = 0; _j2 < groups[_group2].length; ++_j2) {\n var _node = groups[_group2][_j2];\n graph[_node] = graph[_node].concat(graphAfters[_group2]);\n }\n }\n } // Compile ancestors\n\n\n var children;\n var ancestors = {};\n graphNodes = Object.keys(graph);\n\n for (var _i4 = 0; _i4 < graphNodes.length; ++_i4) {\n var _node2 = graphNodes[_i4];\n children = graph[_node2];\n\n for (var _j3 = 0; _j3 < children.length; ++_j3) {\n ancestors[children[_j3]] = (ancestors[children[_j3]] || []).concat(_node2);\n }\n } // Topo sort\n\n\n var visited = {};\n var sorted = [];\n\n for (var _i5 = 0; _i5 < this._items.length; ++_i5) {\n // Really looping thru item.seq values out of order\n var next = _i5;\n\n if (ancestors[_i5]) {\n next = null;\n\n for (var _j4 = 0; _j4 < this._items.length; ++_j4) {\n // As above, these are item.seq values\n if (visited[_j4] === true) {\n continue;\n }\n\n if (!ancestors[_j4]) {\n ancestors[_j4] = [];\n }\n\n var shouldSeeCount = ancestors[_j4].length;\n var seenCount = 0;\n\n for (var _k = 0; _k < shouldSeeCount; ++_k) {\n if (visited[ancestors[_j4][_k]]) {\n ++seenCount;\n }\n }\n\n if (seenCount === shouldSeeCount) {\n next = _j4;\n break;\n }\n }\n }\n\n if (next !== null) {\n visited[next] = true;\n sorted.push(next);\n }\n }\n\n if (sorted.length !== this._items.length) {\n return new Error('Invalid dependencies');\n }\n\n var seqIndex = {};\n\n for (var _i6 = 0; _i6 < this._items.length; ++_i6) {\n var _item = this._items[_i6];\n seqIndex[_item.seq] = _item;\n }\n\n var sortedNodes = [];\n this._items = sorted.map(function (value) {\n var sortedItem = seqIndex[value];\n sortedNodes.push(sortedItem.node);\n return sortedItem;\n });\n this.nodes = sortedNodes;\n }\n }]);\n\n return Topo;\n}();\n\ninternals.mergeSort = function (a, b) {\n return a.sort === b.sort ? 0 : a.sort < b.sort ? -1 : 1;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst internals = {};\nmodule.exports = class Topo {\n constructor() {\n this._items = [];\n this.nodes = [];\n }\n\n add(nodes, options) {\n options = options || {}; // Validate rules\n\n const before = [].concat(options.before || []);\n const after = [].concat(options.after || []);\n const group = options.group || '?';\n const sort = options.sort || 0; // Used for merging only\n\n Assert(!before.includes(group), \"Item cannot come before itself: \".concat(group));\n Assert(!before.includes('?'), 'Item cannot come before unassociated items');\n Assert(!after.includes(group), \"Item cannot come after itself: \".concat(group));\n Assert(!after.includes('?'), 'Item cannot come after unassociated items');\n [].concat(nodes).forEach((node, i) => {\n const item = {\n seq: this._items.length,\n sort,\n before,\n after,\n group,\n node\n };\n\n this._items.push(item);\n }); // Insert event\n\n const error = this._sort();\n\n Assert(!error, 'item', group !== '?' ? \"added into group \".concat(group) : '', 'created a dependencies error');\n return this.nodes;\n }\n\n merge(others) {\n others = [].concat(others);\n\n for (let i = 0; i < others.length; ++i) {\n const other = others[i];\n\n if (other) {\n for (let j = 0; j < other._items.length; ++j) {\n const item = Object.assign({}, other._items[j]); // Shallow cloned\n\n this._items.push(item);\n }\n }\n } // Sort items\n\n\n this._items.sort(internals.mergeSort);\n\n for (let i = 0; i < this._items.length; ++i) {\n this._items[i].seq = i;\n }\n\n const error = this._sort();\n\n Assert(!error, 'merge created a dependencies error');\n return this.nodes;\n }\n\n _sort() {\n // Construct graph\n const graph = {};\n const graphAfters = Object.create(null); // A prototype can bungle lookups w/ false positives\n\n const groups = Object.create(null);\n\n for (let i = 0; i < this._items.length; ++i) {\n const item = this._items[i];\n const seq = item.seq; // Unique across all items\n\n const group = item.group; // Determine Groups\n\n groups[group] = groups[group] || [];\n groups[group].push(seq); // Build intermediary graph using 'before'\n\n graph[seq] = item.before; // Build second intermediary graph with 'after'\n\n const after = item.after;\n\n for (let j = 0; j < after.length; ++j) {\n graphAfters[after[j]] = (graphAfters[after[j]] || []).concat(seq);\n }\n } // Expand intermediary graph\n\n\n let graphNodes = Object.keys(graph);\n\n for (let i = 0; i < graphNodes.length; ++i) {\n const node = graphNodes[i];\n const expandedGroups = [];\n const graphNodeItems = Object.keys(graph[node]);\n\n for (let j = 0; j < graphNodeItems.length; ++j) {\n const group = graph[node][graphNodeItems[j]];\n groups[group] = groups[group] || [];\n\n for (let k = 0; k < groups[group].length; ++k) {\n expandedGroups.push(groups[group][k]);\n }\n }\n\n graph[node] = expandedGroups;\n } // Merge intermediary graph using graphAfters into final graph\n\n\n const afterNodes = Object.keys(graphAfters);\n\n for (let i = 0; i < afterNodes.length; ++i) {\n const group = afterNodes[i];\n\n if (groups[group]) {\n for (let j = 0; j < groups[group].length; ++j) {\n const node = groups[group][j];\n graph[node] = graph[node].concat(graphAfters[group]);\n }\n }\n } // Compile ancestors\n\n\n let children;\n const ancestors = {};\n graphNodes = Object.keys(graph);\n\n for (let i = 0; i < graphNodes.length; ++i) {\n const node = graphNodes[i];\n children = graph[node];\n\n for (let j = 0; j < children.length; ++j) {\n ancestors[children[j]] = (ancestors[children[j]] || []).concat(node);\n }\n } // Topo sort\n\n\n const visited = {};\n const sorted = [];\n\n for (let i = 0; i < this._items.length; ++i) {\n // Really looping thru item.seq values out of order\n let next = i;\n\n if (ancestors[i]) {\n next = null;\n\n for (let j = 0; j < this._items.length; ++j) {\n // As above, these are item.seq values\n if (visited[j] === true) {\n continue;\n }\n\n if (!ancestors[j]) {\n ancestors[j] = [];\n }\n\n const shouldSeeCount = ancestors[j].length;\n let seenCount = 0;\n\n for (let k = 0; k < shouldSeeCount; ++k) {\n if (visited[ancestors[j][k]]) {\n ++seenCount;\n }\n }\n\n if (seenCount === shouldSeeCount) {\n next = j;\n break;\n }\n }\n }\n\n if (next !== null) {\n visited[next] = true;\n sorted.push(next);\n }\n }\n\n if (sorted.length !== this._items.length) {\n return new Error('Invalid dependencies');\n }\n\n const seqIndex = {};\n\n for (let i = 0; i < this._items.length; ++i) {\n const item = this._items[i];\n seqIndex[item.seq] = item;\n }\n\n const sortedNodes = [];\n this._items = sorted.map(value => {\n const sortedItem = seqIndex[value];\n sortedNodes.push(sortedItem.node);\n return sortedItem;\n });\n this.nodes = sortedNodes;\n }\n\n};\n\ninternals.mergeSort = (a, b) => {\n return a.sort === b.sort ? 0 : a.sort < b.sort ? -1 : 1;\n};" }, { - "id": 41, + "id": 40, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/link.js", "name": "../lib/types/link.js", "index": 38, "index2": 37, - "size": 3107, + "size": 2999, "cacheable": true, "built": true, "optional": false, @@ -8248,15 +8062,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -8270,7 +8084,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/link", - "loc": "44:10-33" + "loc": "30:10-33" } ], "usedExports": true, @@ -8279,15 +8093,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar Compile = require('../compile');\n\nvar internals = {};\nmodule.exports = Any.extend({\n type: 'link',\n properties: {\n schemaChain: true\n },\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.link = null;\n },\n args: function args(schema, ref) {\n return schema.ref(ref);\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n var error = _ref.error,\n state = _ref.state,\n prefs = _ref.prefs;\n\n if (!schema.$_terms.link) {\n return {\n value: value,\n errors: error('link.uninitialized')\n };\n }\n\n var ref = schema.$_terms.link[0].ref;\n var perspective = ref.ancestor === 'root' ? state.schemas[0] : state.schemas[state.schemas.length - ref.ancestor - 1];\n\n if (!perspective) {\n return {\n value: value,\n errors: error('link.depth', {\n ref: ref\n })\n };\n }\n\n try {\n var linked = ref.path.length ? perspective.$_reach(ref.path) : perspective;\n } catch (err) {\n return {\n value: value,\n errors: error('link.ref', {\n ref: ref\n })\n };\n }\n\n if (linked.type === 'link') {\n return {\n value: value,\n errors: error('link.loop', {\n ref: ref\n })\n };\n }\n\n return linked.$_validate(value, state.nest(linked), prefs);\n },\n // Rules\n rules: {\n ref: {\n method: function method(ref) {\n Assert(!this.$_terms.link, 'Cannot reinitialize schema');\n ref = Compile.ref(ref);\n Assert(ref.type === 'value', 'Invalid reference type');\n Assert(ref.ancestor === 'root' || ref.ancestor > 0, 'Link cannot reference itself');\n var obj = this.clone();\n obj.$_terms.link = [{\n ref: ref\n }];\n return obj;\n }\n }\n },\n // Overrides\n overrides: {\n concat: function concat(source) {\n Assert(this.$_terms.link, 'Uninitialized link schema');\n Assert(Common.isSchema(source), 'Invalid schema object');\n Assert(source.type === 'any', 'Cannot merge type link with another type:', source.type);\n return this.super.concat(source);\n },\n when: function when() {\n var _obj$super;\n\n Assert(this.$_terms.link, 'Uninitialized link schema');\n var ref = this.$_terms.link[0].ref.clone();\n ++ref.ancestor;\n ref.updateDisplay();\n var obj = this.clone();\n obj.$_terms.link = [{\n ref: ref\n }];\n return (_obj$super = obj.super).when.apply(_obj$super, arguments);\n }\n },\n // Build\n build: function build(obj, desc) {\n return obj.ref(desc.link);\n },\n // Errors\n messages: {\n 'link.depth': '\"{{#label}}\" contains link reference \"{{#ref}}\" outside of schema boundaries',\n 'link.loop': '\"{{#label}}\" contains link reference to another link \"{{#ref}}\"',\n 'link.ref': '\"{{#label}}\" contains link reference to non-existing \"{{#ref}}\" schema',\n 'link.uninitialized': 'uninitialized schema'\n }\n});" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst Compile = require('../compile');\n\nconst internals = {};\nmodule.exports = Any.extend({\n type: 'link',\n properties: {\n schemaChain: true\n },\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.link = null;\n },\n args: function args(schema, ref) {\n return schema.ref(ref);\n },\n // Base validation\n validate: function validate(schema, value, _ref) {\n let {\n error,\n state,\n prefs\n } = _ref;\n\n if (!schema.$_terms.link) {\n return {\n value,\n errors: error('link.uninitialized')\n };\n }\n\n const ref = schema.$_terms.link[0].ref;\n const perspective = ref.ancestor === 'root' ? state.schemas[0] : state.schemas[state.schemas.length - ref.ancestor - 1];\n\n if (!perspective) {\n return {\n value,\n errors: error('link.depth', {\n ref\n })\n };\n }\n\n try {\n var linked = ref.path.length ? perspective.$_reach(ref.path) : perspective;\n } catch (err) {\n return {\n value,\n errors: error('link.ref', {\n ref\n })\n };\n }\n\n if (linked.type === 'link') {\n return {\n value,\n errors: error('link.loop', {\n ref\n })\n };\n }\n\n return linked.$_validate(value, state.nest(linked), prefs);\n },\n // Rules\n rules: {\n ref: {\n method: function method(ref) {\n Assert(!this.$_terms.link, 'Cannot reinitialize schema');\n ref = Compile.ref(ref);\n Assert(ref.type === 'value', 'Invalid reference type');\n Assert(ref.ancestor === 'root' || ref.ancestor > 0, 'Link cannot reference itself');\n const obj = this.clone();\n obj.$_terms.link = [{\n ref\n }];\n return obj;\n }\n }\n },\n // Overrides\n overrides: {\n concat: function concat(source) {\n Assert(this.$_terms.link, 'Uninitialized link schema');\n Assert(Common.isSchema(source), 'Invalid schema object');\n Assert(source.type === 'any', 'Cannot merge type link with another type:', source.type);\n return this.super.concat(source);\n },\n when: function when() {\n Assert(this.$_terms.link, 'Uninitialized link schema');\n const ref = this.$_terms.link[0].ref.clone();\n ++ref.ancestor;\n ref.updateDisplay();\n const obj = this.clone();\n obj.$_terms.link = [{\n ref\n }];\n return obj.super.when(...arguments);\n }\n },\n // Build\n build: function build(obj, desc) {\n return obj.ref(desc.link);\n },\n // Errors\n messages: {\n 'link.depth': '\"{{#label}}\" contains link reference \"{{#ref}}\" outside of schema boundaries',\n 'link.loop': '\"{{#label}}\" contains link reference to another link \"{{#ref}}\"',\n 'link.ref': '\"{{#label}}\" contains link reference to non-existing \"{{#ref}}\" schema',\n 'link.uninitialized': 'uninitialized schema'\n }\n});" }, { - "id": 42, + "id": 41, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/number.js", "name": "../lib/types/number.js", "index": 39, "index2": 38, - "size": 8735, + "size": 8636, "cacheable": true, "built": true, "optional": false, @@ -8304,15 +8118,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -8326,7 +8140,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/number", - "loc": "45:12-37" + "loc": "31:12-37" } ], "usedExports": true, @@ -8335,15 +8149,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Any = require('./any');\n\nvar Common = require('../common');\n\nvar internals = {\n numberRx: /^\\s*[+-]?(?:(?:\\d+(?:\\.\\d*)?)|(?:\\.\\d+))(?:e([+-]?\\d+))?\\s*$/i,\n precisionRx: /(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/\n};\nmodule.exports = Any.extend({\n type: 'number',\n // Initialize\n initialize: function initialize(schema) {\n schema._flags.unsafe = false;\n },\n // Coerce\n coerce: {\n from: 'string',\n method: function method(schema, value, _ref) {\n var error = _ref.error;\n var matches = value.match(internals.numberRx);\n\n if (!matches) {\n return;\n }\n\n value = value.trim();\n var result = {\n value: parseFloat(value)\n };\n\n if (!schema._flags.unsafe) {\n if (value.includes('e')) {\n var constructed = internals.normalizeExponent(\"\".concat(result.value / Math.pow(10, matches[1]), \"e\").concat(matches[1]));\n\n if (constructed !== internals.normalizeExponent(value)) {\n result.errors = error('number.unsafe');\n return result;\n }\n } else {\n var string = result.value.toString();\n\n if (string.includes('e')) {\n return result;\n }\n\n if (string !== internals.normalizeDecimal(value)) {\n result.errors = error('number.unsafe');\n return result;\n }\n }\n }\n\n return result;\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n var error = _ref2.error,\n prefs = _ref2.prefs;\n\n if (value === Infinity || value === -Infinity) {\n return {\n value: value,\n errors: error('number.infinity')\n };\n }\n\n if (!Common.isNumber(value)) {\n return {\n value: value,\n errors: error('number.base')\n };\n }\n\n var result = {\n value: value\n };\n\n if (prefs.convert) {\n var rule = schema.$_getRule('precision');\n\n if (rule) {\n var precision = Math.pow(10, rule.args.limit); // This is conceptually equivalent to using toFixed but it should be much faster\n\n result.value = Math.round(result.value * precision) / precision;\n }\n }\n\n if (!schema._flags.unsafe && (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER)) {\n result.errors = error('number.unsafe');\n }\n\n return result;\n },\n // Rules\n rules: {\n compare: {\n method: false,\n validate: function validate(value, helpers, _ref3, _ref4) {\n var limit = _ref3.limit;\n var name = _ref4.name,\n operator = _ref4.operator,\n args = _ref4.args;\n\n if (Common.compare(value, limit, operator)) {\n return value;\n }\n\n return helpers.error('number.' + name, {\n limit: args.limit,\n value: value\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.isNumber,\n message: 'must be a number'\n }]\n },\n greater: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'greater',\n method: 'compare',\n args: {\n limit: limit\n },\n operator: '>'\n });\n }\n },\n integer: {\n method: function method() {\n return this.$_addRule('integer');\n },\n validate: function validate(value, helpers) {\n if (Math.trunc(value) - value === 0) {\n return value;\n }\n\n return helpers.error('number.integer');\n }\n },\n less: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'less',\n method: 'compare',\n args: {\n limit: limit\n },\n operator: '<'\n });\n }\n },\n max: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'max',\n method: 'compare',\n args: {\n limit: limit\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'min',\n method: 'compare',\n args: {\n limit: limit\n },\n operator: '>='\n });\n }\n },\n multiple: {\n method: function method(base) {\n return this.$_addRule({\n name: 'multiple',\n args: {\n base: base\n }\n });\n },\n validate: function validate(value, helpers, _ref5, options) {\n var base = _ref5.base;\n\n if (value % base === 0) {\n return value;\n }\n\n return helpers.error('number.multiple', {\n multiple: options.args.base,\n value: value\n });\n },\n args: [{\n name: 'base',\n ref: true,\n assert: function assert(value) {\n return typeof value === 'number' && isFinite(value) && value > 0;\n },\n message: 'must be a positive number'\n }],\n multi: true\n },\n negative: {\n method: function method() {\n return this.sign('negative');\n }\n },\n port: {\n method: function method() {\n return this.$_addRule('port');\n },\n validate: function validate(value, helpers) {\n if (Number.isSafeInteger(value) && value >= 0 && value <= 65535) {\n return value;\n }\n\n return helpers.error('number.port');\n }\n },\n positive: {\n method: function method() {\n return this.sign('positive');\n }\n },\n precision: {\n method: function method(limit) {\n Assert(Number.isSafeInteger(limit), 'limit must be an integer');\n return this.$_addRule({\n name: 'precision',\n args: {\n limit: limit\n }\n });\n },\n validate: function validate(value, helpers, _ref6) {\n var limit = _ref6.limit;\n var places = value.toString().match(internals.precisionRx);\n var decimals = Math.max((places[1] ? places[1].length : 0) - (places[2] ? parseInt(places[2], 10) : 0), 0);\n\n if (decimals <= limit) {\n return value;\n }\n\n return helpers.error('number.precision', {\n limit: limit,\n value: value\n });\n },\n convert: true\n },\n sign: {\n method: function method(sign) {\n Assert(['negative', 'positive'].includes(sign), 'Invalid sign', sign);\n return this.$_addRule({\n name: 'sign',\n args: {\n sign: sign\n }\n });\n },\n validate: function validate(value, helpers, _ref7) {\n var sign = _ref7.sign;\n\n if (sign === 'negative' && value < 0 || sign === 'positive' && value > 0) {\n return value;\n }\n\n return helpers.error(\"number.\".concat(sign));\n }\n },\n unsafe: {\n method: function method() {\n var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof enabled === 'boolean', 'enabled must be a boolean');\n return this.$_setFlag('unsafe', enabled);\n }\n }\n },\n // Cast\n cast: {\n string: {\n from: function from(value) {\n return typeof value === 'number';\n },\n to: function to(value, helpers) {\n return value.toString();\n }\n }\n },\n // Errors\n messages: {\n 'number.base': '\"{{#label}}\" must be a number',\n 'number.greater': '\"{{#label}}\" must be greater than {{#limit}}',\n 'number.infinity': '\"{{#label}}\" cannot be infinity',\n 'number.integer': '\"{{#label}}\" must be an integer',\n 'number.less': '\"{{#label}}\" must be less than {{#limit}}',\n 'number.max': '\"{{#label}}\" must be less than or equal to {{#limit}}',\n 'number.min': '\"{{#label}}\" must be larger than or equal to {{#limit}}',\n 'number.multiple': '\"{{#label}}\" must be a multiple of {{#multiple}}',\n 'number.negative': '\"{{#label}}\" must be a negative number',\n 'number.port': '\"{{#label}}\" must be a valid port',\n 'number.positive': '\"{{#label}}\" must be a positive number',\n 'number.precision': '\"{{#label}}\" must have no more than {{#limit}} decimal places',\n 'number.unsafe': '\"{{#label}}\" must be a safe number'\n }\n}); // Helpers\n\ninternals.normalizeExponent = function (str) {\n return str.replace(/\\.(\\d*[1-9])?0+e/, '.$1e').replace(/\\.e/, 'e').replace(/e\\+/, 'e').replace(/^\\+/, '').replace(/^(-?)0+([1-9])/, '$1$2');\n};\n\ninternals.normalizeDecimal = function (str) {\n str = str.replace(/^\\+/, '').replace(/\\.0+$/, '').replace(/^(-?)\\.([^\\.]*)$/, '$10.$2').replace(/^(-?)0+([1-9])/, '$1$2');\n\n if (str.includes('.') && str.endsWith('0')) {\n str = str.replace(/0+$/, '');\n }\n\n return str;\n};" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Any = require('./any');\n\nconst Common = require('../common');\n\nconst internals = {\n numberRx: /^\\s*[+-]?(?:(?:\\d+(?:\\.\\d*)?)|(?:\\.\\d+))(?:e([+-]?\\d+))?\\s*$/i,\n precisionRx: /(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/\n};\nmodule.exports = Any.extend({\n type: 'number',\n // Initialize\n initialize: function initialize(schema) {\n schema._flags.unsafe = false;\n },\n // Coerce\n coerce: {\n from: 'string',\n method: function method(schema, value, _ref) {\n let {\n error\n } = _ref;\n const matches = value.match(internals.numberRx);\n\n if (!matches) {\n return;\n }\n\n value = value.trim();\n const result = {\n value: parseFloat(value)\n };\n\n if (!schema._flags.unsafe) {\n if (value.includes('e')) {\n const constructed = internals.normalizeExponent(\"\".concat(result.value / Math.pow(10, matches[1]), \"e\").concat(matches[1]));\n\n if (constructed !== internals.normalizeExponent(value)) {\n result.errors = error('number.unsafe');\n return result;\n }\n } else {\n const string = result.value.toString();\n\n if (string.includes('e')) {\n return result;\n }\n\n if (string !== internals.normalizeDecimal(value)) {\n result.errors = error('number.unsafe');\n return result;\n }\n }\n }\n\n return result;\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n let {\n error,\n prefs\n } = _ref2;\n\n if (value === Infinity || value === -Infinity) {\n return {\n value,\n errors: error('number.infinity')\n };\n }\n\n if (!Common.isNumber(value)) {\n return {\n value,\n errors: error('number.base')\n };\n }\n\n const result = {\n value\n };\n\n if (prefs.convert) {\n const rule = schema.$_getRule('precision');\n\n if (rule) {\n const precision = Math.pow(10, rule.args.limit); // This is conceptually equivalent to using toFixed but it should be much faster\n\n result.value = Math.round(result.value * precision) / precision;\n }\n }\n\n if (!schema._flags.unsafe && (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER)) {\n result.errors = error('number.unsafe');\n }\n\n return result;\n },\n // Rules\n rules: {\n compare: {\n method: false,\n validate: function validate(value, helpers, _ref3, _ref4) {\n let {\n limit\n } = _ref3;\n let {\n name,\n operator,\n args\n } = _ref4;\n\n if (Common.compare(value, limit, operator)) {\n return value;\n }\n\n return helpers.error('number.' + name, {\n limit: args.limit,\n value\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.isNumber,\n message: 'must be a number'\n }]\n },\n greater: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'greater',\n method: 'compare',\n args: {\n limit\n },\n operator: '>'\n });\n }\n },\n integer: {\n method: function method() {\n return this.$_addRule('integer');\n },\n validate: function validate(value, helpers) {\n if (Math.trunc(value) - value === 0) {\n return value;\n }\n\n return helpers.error('number.integer');\n }\n },\n less: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'less',\n method: 'compare',\n args: {\n limit\n },\n operator: '<'\n });\n }\n },\n max: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'max',\n method: 'compare',\n args: {\n limit\n },\n operator: '<='\n });\n }\n },\n min: {\n method: function method(limit) {\n return this.$_addRule({\n name: 'min',\n method: 'compare',\n args: {\n limit\n },\n operator: '>='\n });\n }\n },\n multiple: {\n method: function method(base) {\n return this.$_addRule({\n name: 'multiple',\n args: {\n base\n }\n });\n },\n validate: function validate(value, helpers, _ref5, options) {\n let {\n base\n } = _ref5;\n\n if (value % base === 0) {\n return value;\n }\n\n return helpers.error('number.multiple', {\n multiple: options.args.base,\n value\n });\n },\n args: [{\n name: 'base',\n ref: true,\n assert: value => typeof value === 'number' && isFinite(value) && value > 0,\n message: 'must be a positive number'\n }],\n multi: true\n },\n negative: {\n method: function method() {\n return this.sign('negative');\n }\n },\n port: {\n method: function method() {\n return this.$_addRule('port');\n },\n validate: function validate(value, helpers) {\n if (Number.isSafeInteger(value) && value >= 0 && value <= 65535) {\n return value;\n }\n\n return helpers.error('number.port');\n }\n },\n positive: {\n method: function method() {\n return this.sign('positive');\n }\n },\n precision: {\n method: function method(limit) {\n Assert(Number.isSafeInteger(limit), 'limit must be an integer');\n return this.$_addRule({\n name: 'precision',\n args: {\n limit\n }\n });\n },\n validate: function validate(value, helpers, _ref6) {\n let {\n limit\n } = _ref6;\n const places = value.toString().match(internals.precisionRx);\n const decimals = Math.max((places[1] ? places[1].length : 0) - (places[2] ? parseInt(places[2], 10) : 0), 0);\n\n if (decimals <= limit) {\n return value;\n }\n\n return helpers.error('number.precision', {\n limit,\n value\n });\n },\n convert: true\n },\n sign: {\n method: function method(sign) {\n Assert(['negative', 'positive'].includes(sign), 'Invalid sign', sign);\n return this.$_addRule({\n name: 'sign',\n args: {\n sign\n }\n });\n },\n validate: function validate(value, helpers, _ref7) {\n let {\n sign\n } = _ref7;\n\n if (sign === 'negative' && value < 0 || sign === 'positive' && value > 0) {\n return value;\n }\n\n return helpers.error(\"number.\".concat(sign));\n }\n },\n unsafe: {\n method: function method() {\n let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof enabled === 'boolean', 'enabled must be a boolean');\n return this.$_setFlag('unsafe', enabled);\n }\n }\n },\n // Cast\n cast: {\n string: {\n from: value => typeof value === 'number',\n to: function to(value, helpers) {\n return value.toString();\n }\n }\n },\n // Errors\n messages: {\n 'number.base': '\"{{#label}}\" must be a number',\n 'number.greater': '\"{{#label}}\" must be greater than {{#limit}}',\n 'number.infinity': '\"{{#label}}\" cannot be infinity',\n 'number.integer': '\"{{#label}}\" must be an integer',\n 'number.less': '\"{{#label}}\" must be less than {{#limit}}',\n 'number.max': '\"{{#label}}\" must be less than or equal to {{#limit}}',\n 'number.min': '\"{{#label}}\" must be larger than or equal to {{#limit}}',\n 'number.multiple': '\"{{#label}}\" must be a multiple of {{#multiple}}',\n 'number.negative': '\"{{#label}}\" must be a negative number',\n 'number.port': '\"{{#label}}\" must be a valid port',\n 'number.positive': '\"{{#label}}\" must be a positive number',\n 'number.precision': '\"{{#label}}\" must have no more than {{#limit}} decimal places',\n 'number.unsafe': '\"{{#label}}\" must be a safe number'\n }\n}); // Helpers\n\ninternals.normalizeExponent = function (str) {\n return str.replace(/\\.(\\d*[1-9])?0+e/, '.$1e').replace(/\\.e/, 'e').replace(/e\\+/, 'e').replace(/^\\+/, '').replace(/^(-?)0+([1-9])/, '$1$2');\n};\n\ninternals.normalizeDecimal = function (str) {\n str = str.replace(/^\\+/, '').replace(/\\.0+$/, '').replace(/^(-?)\\.([^\\.]*)$/, '$10.$2').replace(/^(-?)0+([1-9])/, '$1$2');\n\n if (str.includes('.') && str.endsWith('0')) {\n str = str.replace(/0+$/, '');\n }\n\n return str;\n};" }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "index": 40, - "index2": 50, - "size": 31086, + "index2": 49, + "size": 28602, "cacheable": true, "built": true, "optional": false, @@ -8360,15 +8174,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -8382,7 +8196,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/string", - "loc": "47:12-37" + "loc": "33:12-37" } ], "usedExports": true, @@ -8391,15 +8205,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nvar Address = require('@hapi/address');\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar EscapeRegex = require('@hapi/hoek/lib/escapeRegex');\n\nvar Contain = require('@hapi/hoek/lib/contain');\n\nvar Any = require('../any');\n\nvar Common = require('../../common');\n\nvar Ip = require('./ip');\n\nvar Uri = require('./uri');\n\nvar internals = {\n base64Regex: {\n // paddingRequired\n true: {\n // urlSafe\n true: /^(?:[\\w\\-]{2}[\\w\\-]{2})*(?:[\\w\\-]{2}==|[\\w\\-]{3}=)?$/,\n false: /^(?:[A-Za-z0-9+\\/]{2}[A-Za-z0-9+\\/]{2})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/\n },\n false: {\n true: /^(?:[\\w\\-]{2}[\\w\\-]{2})*(?:[\\w\\-]{2}(==)?|[\\w\\-]{3}=?)?$/,\n false: /^(?:[A-Za-z0-9+\\/]{2}[A-Za-z0-9+\\/]{2})*(?:[A-Za-z0-9+\\/]{2}(==)?|[A-Za-z0-9+\\/]{3}=?)?$/\n }\n },\n dataUriRegex: {\n format: /^data:[\\w+.-]+\\/[\\w+.-]+;((charset=[\\w-]+|base64),)?(.*)$/,\n base64: {\n // paddingRequired\n true: /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/,\n false: /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}(==)?|[A-Za-z0-9+\\/]{3}=?)?$/\n }\n },\n hexRegex: /^[a-f0-9]+$/i,\n hostRegex: /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$/,\n ipRegex: Ip.createIpRegex(['ipv4', 'ipv6', 'ipvfuture'], 'optional'),\n isoDurationRegex: /^P(?!$)(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?$/,\n guidBrackets: {\n '{': '}',\n '[': ']',\n '(': ')',\n '': ''\n },\n guidVersions: {\n uuidv1: '1',\n uuidv2: '2',\n uuidv3: '3',\n uuidv4: '4',\n uuidv5: '5'\n },\n cidrPresences: ['required', 'optional', 'forbidden'],\n normalizationForms: ['NFC', 'NFD', 'NFKC', 'NFKD']\n};\nmodule.exports = Any.extend({\n type: 'string',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.replacements = null;\n },\n // Coerce\n coerce: {\n from: 'string',\n method: function method(schema, value, _ref) {\n var state = _ref.state,\n prefs = _ref.prefs;\n var normalize = schema.$_getRule('normalize');\n\n if (normalize) {\n value = value.normalize(normalize.args.form);\n }\n\n var casing = schema.$_getRule('case');\n\n if (casing) {\n value = casing.args.direction === 'upper' ? value.toLocaleUpperCase() : value.toLocaleLowerCase();\n }\n\n var trim = schema.$_getRule('trim');\n\n if (trim && trim.args.enabled) {\n value = value.trim();\n }\n\n if (schema.$_terms.replacements) {\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = schema.$_terms.replacements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var replacement = _step.value;\n value = value.replace(replacement.pattern, replacement.replacement);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n }\n\n var hex = schema.$_getRule('hex');\n\n if (hex && hex.args.options.byteAligned && value.length % 2 !== 0) {\n value = \"0\".concat(value);\n }\n\n if (schema.$_getRule('isoDate')) {\n var valid = false;\n\n if (Common.isIsoDate(value)) {\n var date = new Date(value);\n\n if (!isNaN(date.getTime())) {\n value = date.toISOString();\n valid = true;\n }\n }\n\n if (!valid) {\n return {\n value: value,\n errors: schema.$_createError('string.isoDate', value, null, state, prefs)\n };\n }\n }\n\n if (schema._flags.truncate) {\n var rule = schema.$_getRule('max');\n\n if (rule) {\n var limit = rule.args.limit;\n\n if (Common.isResolvable(limit)) {\n limit = limit.resolve(value, state, prefs);\n\n if (!Common.limit(limit)) {\n return {\n value: value,\n errors: schema.$_createError('any.ref', limit, {\n ref: rule.args.limit,\n arg: 'limit',\n reason: 'must be a positive integer'\n }, state, prefs)\n };\n }\n }\n\n value = value.slice(0, limit);\n }\n }\n\n return {\n value: value\n };\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n var error = _ref2.error;\n\n if (typeof value !== 'string') {\n return {\n value: value,\n errors: error('string.base')\n };\n }\n\n if (value === '') {\n return {\n value: value,\n errors: error('string.empty')\n };\n }\n },\n // Rules\n rules: {\n alphanum: {\n method: function method() {\n return this.$_addRule('alphanum');\n },\n validate: function validate(value, helpers) {\n if (/^[a-zA-Z0-9]+$/.test(value)) {\n return value;\n }\n\n return helpers.error('string.alphanum');\n }\n },\n base64: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['paddingRequired', 'urlSafe']);\n options = _objectSpread({\n urlSafe: false,\n paddingRequired: true\n }, options);\n Assert(typeof options.paddingRequired === 'boolean', 'paddingRequired must be boolean');\n Assert(typeof options.urlSafe === 'boolean', 'urlSafe must be boolean');\n return this.$_addRule({\n name: 'base64',\n args: {\n options: options\n }\n });\n },\n validate: function validate(value, helpers, _ref3) {\n var options = _ref3.options;\n var regex = internals.base64Regex[options.paddingRequired][options.urlSafe];\n\n if (regex.test(value)) {\n return value;\n }\n\n return helpers.error('string.base64');\n }\n },\n case: {\n method: function method(direction) {\n Assert(['lower', 'upper'].includes(direction), 'Invalid case:', direction);\n return this.$_addRule({\n name: 'case',\n args: {\n direction: direction\n }\n });\n },\n validate: function validate(value, helpers, _ref4) {\n var direction = _ref4.direction;\n\n if (direction === 'lower' && value === value.toLocaleLowerCase() || direction === 'upper' && value === value.toLocaleUpperCase()) {\n return value;\n }\n\n return helpers.error(\"string.\".concat(direction, \"case\"));\n },\n convert: true\n },\n creditCard: {\n method: function method() {\n return this.$_addRule('creditCard');\n },\n validate: function validate(value, helpers) {\n var i = value.length;\n var sum = 0;\n var mul = 1;\n\n while (i--) {\n var char = value.charAt(i) * mul;\n sum = sum + (char - (char > 9) * 9);\n mul = mul ^ 3;\n }\n\n if (sum > 0 && sum % 10 === 0) {\n return value;\n }\n\n return helpers.error('string.creditCard');\n }\n },\n dataUri: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['paddingRequired']);\n options = _objectSpread({\n paddingRequired: true\n }, options);\n Assert(typeof options.paddingRequired === 'boolean', 'paddingRequired must be boolean');\n return this.$_addRule({\n name: 'dataUri',\n args: {\n options: options\n }\n });\n },\n validate: function validate(value, helpers, _ref5) {\n var options = _ref5.options;\n var matches = value.match(internals.dataUriRegex.format);\n\n if (matches) {\n if (!matches[2]) {\n return value;\n }\n\n if (matches[2] !== 'base64') {\n return value;\n }\n\n var base64regex = internals.dataUriRegex.base64[options.paddingRequired];\n\n if (base64regex.test(matches[3])) {\n return value;\n }\n }\n\n return helpers.error('string.dataUri');\n }\n },\n domain: {\n method: function method(options) {\n if (options) {\n Common.assertOptions(options, ['allowUnicode', 'minDomainSegments', 'tlds']);\n options = internals.addressOptions(options);\n }\n\n return this.$_addRule({\n name: 'domain',\n args: {\n options: options\n }\n });\n },\n validate: function validate(value, helpers, _ref6) {\n var options = _ref6.options;\n\n if (Address.domain.isValid(value, options)) {\n return value;\n }\n\n return helpers.error('string.domain');\n }\n },\n email: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['allowUnicode', 'minDomainSegments', 'multiple', 'separator', 'tlds']);\n Assert(options.multiple === undefined || typeof options.multiple === 'boolean', 'multiple option must be an boolean');\n options = internals.addressOptions(options);\n var regex = new RegExp(\"\\\\s*[\".concat(options.separator ? EscapeRegex(options.separator) : ',', \"]\\\\s*\"));\n return this.$_addRule({\n name: 'email',\n args: {\n options: options\n },\n regex: regex\n });\n },\n validate: function validate(value, helpers, _ref7, _ref8) {\n var options = _ref7.options;\n var regex = _ref8.regex;\n var emails = options.multiple ? value.split(regex) : [value];\n var invalids = [];\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = emails[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var email = _step2.value;\n\n if (!Address.email.isValid(email, options)) {\n invalids.push(email);\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n\n if (!invalids.length) {\n return value;\n }\n\n return helpers.error('string.email', {\n value: value,\n invalids: invalids\n });\n }\n },\n guid: {\n alias: 'uuid',\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['version']);\n var versionNumbers = '';\n\n if (options.version) {\n var versions = [].concat(options.version);\n Assert(versions.length >= 1, 'version must have at least 1 valid version specified');\n var set = new Set();\n\n for (var i = 0; i < versions.length; ++i) {\n var version = versions[i];\n Assert(typeof version === 'string', 'version at position ' + i + ' must be a string');\n var versionNumber = internals.guidVersions[version.toLowerCase()];\n Assert(versionNumber, 'version at position ' + i + ' must be one of ' + Object.keys(internals.guidVersions).join(', '));\n Assert(!set.has(versionNumber), 'version at position ' + i + ' must not be a duplicate');\n versionNumbers += versionNumber;\n set.add(versionNumber);\n }\n }\n\n var regex = new RegExp(\"^([\\\\[{\\\\(]?)[0-9A-F]{8}([:-]?)[0-9A-F]{4}\\\\2?[\".concat(versionNumbers || '0-9A-F', \"][0-9A-F]{3}\\\\2?[\").concat(versionNumbers ? '89AB' : '0-9A-F', \"][0-9A-F]{3}\\\\2?[0-9A-F]{12}([\\\\]}\\\\)]?)$\"), 'i');\n return this.$_addRule({\n name: 'guid',\n args: {\n options: options\n },\n regex: regex\n });\n },\n validate: function validate(value, helpers, args, _ref9) {\n var regex = _ref9.regex;\n var results = regex.exec(value);\n\n if (!results) {\n return helpers.error('string.guid');\n } // Matching braces\n\n\n if (internals.guidBrackets[results[1]] !== results[results.length - 1]) {\n return helpers.error('string.guid');\n }\n\n return value;\n }\n },\n hex: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['byteAligned']);\n options = _objectSpread({\n byteAligned: false\n }, options);\n Assert(typeof options.byteAligned === 'boolean', 'byteAligned must be boolean');\n return this.$_addRule({\n name: 'hex',\n args: {\n options: options\n }\n });\n },\n validate: function validate(value, helpers, _ref10) {\n var options = _ref10.options;\n\n if (!internals.hexRegex.test(value)) {\n return helpers.error('string.hex');\n }\n\n if (options.byteAligned && value.length % 2 !== 0) {\n return helpers.error('string.hexAlign');\n }\n\n return value;\n }\n },\n hostname: {\n method: function method() {\n return this.$_addRule('hostname');\n },\n validate: function validate(value, helpers) {\n if (value.length <= 255 && internals.hostRegex.test(value) || internals.ipRegex.test(value)) {\n return value;\n }\n\n return helpers.error('string.hostname');\n }\n },\n insensitive: {\n method: function method() {\n return this.$_setFlag('insensitive', true);\n }\n },\n ip: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['cidr', 'version']);\n options = Object.assign({}, options); // Shallow cloned\n\n var regex = internals.ipRegex;\n\n if (options.cidr) {\n Assert(typeof options.cidr === 'string', 'cidr must be a string');\n options.cidr = options.cidr.toLowerCase();\n Assert(Contain(internals.cidrPresences, options.cidr), 'cidr must be one of ' + internals.cidrPresences.join(', '));\n\n if (!options.version && options.cidr !== 'optional') {\n regex = Ip.createIpRegex(['ipv4', 'ipv6', 'ipvfuture'], options.cidr);\n }\n } else {\n options.cidr = 'optional';\n }\n\n var versions;\n\n if (options.version) {\n if (!Array.isArray(options.version)) {\n options.version = [options.version];\n }\n\n Assert(options.version.length >= 1, 'version must have at least 1 version specified');\n versions = [];\n\n for (var i = 0; i < options.version.length; ++i) {\n var version = options.version[i];\n Assert(typeof version === 'string', 'version at position ' + i + ' must be a string');\n version = version.toLowerCase();\n Assert(Ip.versions[version], 'version at position ' + i + ' must be one of ' + Object.keys(Ip.versions).join(', '));\n versions.push(version);\n }\n\n versions = Array.from(new Set(versions));\n regex = Ip.createIpRegex(versions, options.cidr);\n }\n\n return this.$_addRule({\n name: 'ip',\n args: {\n options: options\n },\n versions: versions,\n regex: regex\n });\n },\n validate: function validate(value, helpers, _ref11, _ref12) {\n var options = _ref11.options;\n var versions = _ref12.versions,\n regex = _ref12.regex;\n\n if (regex.test(value)) {\n return value;\n }\n\n if (versions) {\n return helpers.error('string.ipVersion', {\n value: value,\n cidr: options.cidr,\n version: versions\n });\n }\n\n return helpers.error('string.ip', {\n value: value,\n cidr: options.cidr\n });\n }\n },\n isoDate: {\n method: function method() {\n return this.$_addRule('isoDate');\n },\n validate: function validate(value, _ref13) {\n var error = _ref13.error;\n\n if (Common.isIsoDate(value)) {\n return value;\n }\n\n return error('string.isoDate');\n },\n convert: true\n },\n isoDuration: {\n method: function method() {\n return this.$_addRule('isoDuration');\n },\n validate: function validate(value, helpers) {\n if (internals.isoDurationRegex.test(value)) {\n return value;\n }\n\n return helpers.error('string.isoDuration');\n }\n },\n length: {\n method: function method(limit, encoding) {\n return internals.length(this, 'length', limit, '=', encoding);\n },\n validate: function validate(value, helpers, _ref14, _ref15) {\n var limit = _ref14.limit,\n encoding = _ref14.encoding;\n var name = _ref15.name,\n operator = _ref15.operator,\n args = _ref15.args;\n var length =\n /*encoding ? Buffer.byteLength(value, encoding) :*/\n value.length;\n\n if (Common.compare(length, limit, operator)) {\n return value;\n }\n\n return helpers.error('string.' + name, {\n limit: args.limit,\n value: value,\n encoding: encoding\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.limit,\n message: 'must be a positive integer'\n }, 'encoding']\n },\n lowercase: {\n method: function method() {\n return this.case('lower');\n }\n },\n max: {\n method: function method(limit, encoding) {\n return internals.length(this, 'max', limit, '<=', encoding);\n },\n args: ['limit', 'encoding']\n },\n min: {\n method: function method(limit, encoding) {\n return internals.length(this, 'min', limit, '>=', encoding);\n },\n args: ['limit', 'encoding']\n },\n normalize: {\n method: function method() {\n var form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'NFC';\n Assert(Contain(internals.normalizationForms, form), 'normalization form must be one of ' + internals.normalizationForms.join(', '));\n return this.$_addRule({\n name: 'normalize',\n args: {\n form: form\n }\n });\n },\n validate: function validate(value, _ref16, _ref17) {\n var error = _ref16.error;\n var form = _ref17.form;\n\n if (value === value.normalize(form)) {\n return value;\n }\n\n return error('string.normalize', {\n value: value,\n form: form\n });\n },\n convert: true\n },\n pattern: {\n alias: 'regex',\n method: function method(regex) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(regex instanceof RegExp, 'regex must be a RegExp');\n Assert(!regex.flags.includes('g') && !regex.flags.includes('y'), 'regex should not use global or sticky mode');\n\n if (typeof options === 'string') {\n options = {\n name: options\n };\n }\n\n Common.assertOptions(options, ['invert', 'name']);\n var errorCode = ['string.pattern', options.invert ? '.invert' : '', options.name ? '.name' : '.base'].join('');\n return this.$_addRule({\n name: 'pattern',\n args: {\n regex: regex,\n options: options\n },\n errorCode: errorCode\n });\n },\n validate: function validate(value, helpers, _ref18, _ref19) {\n var regex = _ref18.regex,\n options = _ref18.options;\n var errorCode = _ref19.errorCode;\n var patternMatch = regex.test(value);\n\n if (patternMatch ^ options.invert) {\n return value;\n }\n\n return helpers.error(errorCode, {\n name: options.name,\n regex: regex,\n value: value\n });\n },\n args: ['regex', 'options'],\n multi: true\n },\n replace: {\n method: function method(pattern, replacement) {\n if (typeof pattern === 'string') {\n pattern = new RegExp(EscapeRegex(pattern), 'g');\n }\n\n Assert(pattern instanceof RegExp, 'pattern must be a RegExp');\n Assert(typeof replacement === 'string', 'replacement must be a String');\n var obj = this.clone();\n\n if (!obj.$_terms.replacements) {\n obj.$_terms.replacements = [];\n }\n\n obj.$_terms.replacements.push({\n pattern: pattern,\n replacement: replacement\n });\n return obj;\n }\n },\n token: {\n method: function method() {\n return this.$_addRule('token');\n },\n validate: function validate(value, helpers) {\n if (/^\\w+$/.test(value)) {\n return value;\n }\n\n return helpers.error('string.token');\n }\n },\n trim: {\n method: function method() {\n var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof enabled === 'boolean', 'enabled must be a boolean');\n return this.$_addRule({\n name: 'trim',\n args: {\n enabled: enabled\n }\n });\n },\n validate: function validate(value, helpers, _ref20) {\n var enabled = _ref20.enabled;\n\n if (!enabled || value === value.trim()) {\n return value;\n }\n\n return helpers.error('string.trim');\n },\n convert: true\n },\n truncate: {\n method: function method() {\n var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof enabled === 'boolean', 'enabled must be a boolean');\n return this.$_setFlag('truncate', enabled);\n }\n },\n uppercase: {\n method: function method() {\n return this.case('upper');\n }\n },\n uri: {\n method: function method() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['allowRelative', 'allowQuerySquareBrackets', 'domain', 'relativeOnly', 'scheme']);\n var unknownOptions = Object.keys(options).filter(function (key) {\n return !['scheme', 'allowRelative', 'relativeOnly', 'allowQuerySquareBrackets', 'domain'].includes(key);\n });\n Assert(unknownOptions.length === 0, \"options contain unknown keys: \".concat(unknownOptions));\n\n if (options.domain) {\n options = Object.assign({}, options); // Shallow cloned\n\n options.domain = internals.addressOptions(options.domain);\n }\n\n var regex = Uri.createRegex(options);\n return this.$_addRule({\n name: 'uri',\n args: {\n options: options\n },\n regex: regex\n });\n },\n validate: function validate(value, helpers, _ref21, _ref22) {\n var options = _ref21.options;\n var regex = _ref22.regex;\n\n if (['http:/', 'https:/'].includes(value)) {\n // scheme:/ is technically valid but makes no sense\n return helpers.error('string.uri');\n }\n\n var match = regex.exec(value);\n\n if (match) {\n if (options.domain && !Address.domain.isValid(match[1], options.domain)) {\n return helpers.error('string.domain', {\n value: match[1]\n });\n }\n\n return value;\n }\n\n if (options.relativeOnly) {\n return helpers.error('string.uriRelativeOnly');\n }\n\n if (options.scheme) {\n return helpers.error('string.uriCustomScheme', {\n scheme: regex.scheme,\n value: value\n });\n }\n\n return helpers.error('string.uri');\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n var _iteratorNormalCompletion3 = true;\n var _didIteratorError3 = false;\n var _iteratorError3 = undefined;\n\n try {\n for (var _iterator3 = desc.replacements[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {\n var _step3$value = _step3.value,\n pattern = _step3$value.pattern,\n replacement = _step3$value.replacement;\n obj = obj.replace(pattern, replacement);\n }\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n\n return obj;\n },\n // Errors\n messages: {\n 'string.alphanum': '\"{{#label}}\" must only contain alpha-numeric characters',\n 'string.base': '\"{{#label}}\" must be a string',\n 'string.base64': '\"{{#label}}\" must be a valid base64 string',\n 'string.creditCard': '\"{{#label}}\" must be a credit card',\n 'string.dataUri': '\"{{#label}}\" must be a valid dataUri string',\n 'string.domain': '\"{{#label}}\" must contain a valid domain name',\n 'string.email': '\"{{#label}}\" must be a valid email',\n 'string.empty': '\"{{#label}}\" is not allowed to be empty',\n 'string.guid': '\"{{#label}}\" must be a valid GUID',\n 'string.hex': '\"{{#label}}\" must only contain hexadecimal characters',\n 'string.hexAlign': '\"{{#label}}\" hex decoded representation must be byte aligned',\n 'string.hostname': '\"{{#label}}\" must be a valid hostname',\n 'string.ip': '\"{{#label}}\" must be a valid ip address with a {{#cidr}} CIDR',\n 'string.ipVersion': '\"{{#label}}\" must be a valid ip address of one of the following versions {{#version}} with a {{#cidr}} CIDR',\n 'string.isoDate': '\"{{#label}}\" must be a valid ISO 8601 date',\n 'string.isoDuration': '\"{{#label}}\" must be a valid ISO 8601 duration',\n 'string.length': '\"{{#label}}\" length must be {{#limit}} characters long',\n 'string.lowercase': '\"{{#label}}\" must only contain lowercase characters',\n 'string.max': '\"{{#label}}\" length must be less than or equal to {{#limit}} characters long',\n 'string.min': '\"{{#label}}\" length must be at least {{#limit}} characters long',\n 'string.normalize': '\"{{#label}}\" must be unicode normalized in the {{#form}} form',\n 'string.token': '\"{{#label}}\" must only contain alpha-numeric and underscore characters',\n 'string.pattern.base': '\"{{#label}}\" with value \"{[.]}\" fails to match the required pattern: {{#regex}}',\n 'string.pattern.name': '\"{{#label}}\" with value \"{[.]}\" fails to match the {{#name}} pattern',\n 'string.pattern.invert.base': '\"{{#label}}\" with value \"{[.]}\" matches the inverted pattern: {{#regex}}',\n 'string.pattern.invert.name': '\"{{#label}}\" with value \"{[.]}\" matches the inverted {{#name}} pattern',\n 'string.trim': '\"{{#label}}\" must not have leading or trailing whitespace',\n 'string.uri': '\"{{#label}}\" must be a valid uri',\n 'string.uriCustomScheme': '\"{{#label}}\" must be a valid uri with a scheme matching the {{#scheme}} pattern',\n 'string.uriRelativeOnly': '\"{{#label}}\" must be a valid relative uri',\n 'string.uppercase': '\"{{#label}}\" must only contain uppercase characters'\n }\n}); // Helpers\n\ninternals.addressOptions = function (options) {\n if (options.tlds && _typeof(options.tlds) === 'object') {\n Assert(options.tlds.allow === undefined || options.tlds.allow === false || options.tlds.allow === true || Array.isArray(options.tlds.allow) || options.tlds.allow instanceof Set, 'tlds.allow must be an array, Set, or boolean');\n Assert(options.tlds.deny === undefined || Array.isArray(options.tlds.deny) || options.tlds.deny instanceof Set, 'tlds.deny must be an array or Set');\n\n var normalizeTable = function normalizeTable(table) {\n if (table === undefined || typeof table === 'boolean' || table instanceof Set) {\n return table;\n }\n\n return new Set(table);\n };\n\n options = Object.assign({}, options); // Shallow cloned\n\n options.tlds = {\n allow: normalizeTable(options.tlds.allow),\n deny: normalizeTable(options.tlds.deny)\n };\n }\n\n Assert(options.minDomainSegments === undefined || Number.isSafeInteger(options.minDomainSegments) && options.minDomainSegments > 0, 'minDomainSegments must be a positive integer');\n return options;\n};\n\ninternals.length = function (schema, name, limit, operator, encoding) {\n // Assert(!encoding || Buffer.isEncoding(encoding), 'Invalid encoding:', encoding);\n return schema.$_addRule({\n name: name,\n method: 'length',\n args: {\n limit: limit,\n encoding: encoding\n },\n operator: operator\n });\n};" + "source": "'use strict';\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nconst Address = require('@hapi/address');\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst EscapeRegex = require('@hapi/hoek/lib/escapeRegex');\n\nconst Contain = require('@hapi/hoek/lib/contain');\n\nconst Any = require('../any');\n\nconst Common = require('../../common');\n\nconst Ip = require('./ip');\n\nconst Uri = require('./uri');\n\nconst internals = {\n base64Regex: {\n // paddingRequired\n true: {\n // urlSafe\n true: /^(?:[\\w\\-]{2}[\\w\\-]{2})*(?:[\\w\\-]{2}==|[\\w\\-]{3}=)?$/,\n false: /^(?:[A-Za-z0-9+\\/]{2}[A-Za-z0-9+\\/]{2})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/\n },\n false: {\n true: /^(?:[\\w\\-]{2}[\\w\\-]{2})*(?:[\\w\\-]{2}(==)?|[\\w\\-]{3}=?)?$/,\n false: /^(?:[A-Za-z0-9+\\/]{2}[A-Za-z0-9+\\/]{2})*(?:[A-Za-z0-9+\\/]{2}(==)?|[A-Za-z0-9+\\/]{3}=?)?$/\n }\n },\n dataUriRegex: {\n format: /^data:[\\w+.-]+\\/[\\w+.-]+;((charset=[\\w-]+|base64),)?(.*)$/,\n base64: {\n // paddingRequired\n true: /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$/,\n false: /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}(==)?|[A-Za-z0-9+\\/]{3}=?)?$/\n }\n },\n hexRegex: /^[a-f0-9]+$/i,\n hostRegex: /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$/,\n ipRegex: Ip.createIpRegex(['ipv4', 'ipv6', 'ipvfuture'], 'optional'),\n isoDurationRegex: /^P(?!$)(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?$/,\n guidBrackets: {\n '{': '}',\n '[': ']',\n '(': ')',\n '': ''\n },\n guidVersions: {\n uuidv1: '1',\n uuidv2: '2',\n uuidv3: '3',\n uuidv4: '4',\n uuidv5: '5'\n },\n cidrPresences: ['required', 'optional', 'forbidden'],\n normalizationForms: ['NFC', 'NFD', 'NFKC', 'NFKD']\n};\nmodule.exports = Any.extend({\n type: 'string',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.replacements = null;\n },\n // Coerce\n coerce: {\n from: 'string',\n method: function method(schema, value, _ref) {\n let {\n state,\n prefs\n } = _ref;\n const normalize = schema.$_getRule('normalize');\n\n if (normalize) {\n value = value.normalize(normalize.args.form);\n }\n\n const casing = schema.$_getRule('case');\n\n if (casing) {\n value = casing.args.direction === 'upper' ? value.toLocaleUpperCase() : value.toLocaleLowerCase();\n }\n\n const trim = schema.$_getRule('trim');\n\n if (trim && trim.args.enabled) {\n value = value.trim();\n }\n\n if (schema.$_terms.replacements) {\n for (const replacement of schema.$_terms.replacements) {\n value = value.replace(replacement.pattern, replacement.replacement);\n }\n }\n\n const hex = schema.$_getRule('hex');\n\n if (hex && hex.args.options.byteAligned && value.length % 2 !== 0) {\n value = \"0\".concat(value);\n }\n\n if (schema.$_getRule('isoDate')) {\n let valid = false;\n\n if (Common.isIsoDate(value)) {\n const date = new Date(value);\n\n if (!isNaN(date.getTime())) {\n value = date.toISOString();\n valid = true;\n }\n }\n\n if (!valid) {\n return {\n value,\n errors: schema.$_createError('string.isoDate', value, null, state, prefs)\n };\n }\n }\n\n if (schema._flags.truncate) {\n const rule = schema.$_getRule('max');\n\n if (rule) {\n let limit = rule.args.limit;\n\n if (Common.isResolvable(limit)) {\n limit = limit.resolve(value, state, prefs);\n\n if (!Common.limit(limit)) {\n return {\n value,\n errors: schema.$_createError('any.ref', limit, {\n ref: rule.args.limit,\n arg: 'limit',\n reason: 'must be a positive integer'\n }, state, prefs)\n };\n }\n }\n\n value = value.slice(0, limit);\n }\n }\n\n return {\n value\n };\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n let {\n error\n } = _ref2;\n\n if (typeof value !== 'string') {\n return {\n value,\n errors: error('string.base')\n };\n }\n\n if (value === '') {\n return {\n value,\n errors: error('string.empty')\n };\n }\n },\n // Rules\n rules: {\n alphanum: {\n method: function method() {\n return this.$_addRule('alphanum');\n },\n validate: function validate(value, helpers) {\n if (/^[a-zA-Z0-9]+$/.test(value)) {\n return value;\n }\n\n return helpers.error('string.alphanum');\n }\n },\n base64: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['paddingRequired', 'urlSafe']);\n options = _objectSpread({\n urlSafe: false,\n paddingRequired: true\n }, options);\n Assert(typeof options.paddingRequired === 'boolean', 'paddingRequired must be boolean');\n Assert(typeof options.urlSafe === 'boolean', 'urlSafe must be boolean');\n return this.$_addRule({\n name: 'base64',\n args: {\n options\n }\n });\n },\n validate: function validate(value, helpers, _ref3) {\n let {\n options\n } = _ref3;\n const regex = internals.base64Regex[options.paddingRequired][options.urlSafe];\n\n if (regex.test(value)) {\n return value;\n }\n\n return helpers.error('string.base64');\n }\n },\n case: {\n method: function method(direction) {\n Assert(['lower', 'upper'].includes(direction), 'Invalid case:', direction);\n return this.$_addRule({\n name: 'case',\n args: {\n direction\n }\n });\n },\n validate: function validate(value, helpers, _ref4) {\n let {\n direction\n } = _ref4;\n\n if (direction === 'lower' && value === value.toLocaleLowerCase() || direction === 'upper' && value === value.toLocaleUpperCase()) {\n return value;\n }\n\n return helpers.error(\"string.\".concat(direction, \"case\"));\n },\n convert: true\n },\n creditCard: {\n method: function method() {\n return this.$_addRule('creditCard');\n },\n validate: function validate(value, helpers) {\n let i = value.length;\n let sum = 0;\n let mul = 1;\n\n while (i--) {\n const char = value.charAt(i) * mul;\n sum = sum + (char - (char > 9) * 9);\n mul = mul ^ 3;\n }\n\n if (sum > 0 && sum % 10 === 0) {\n return value;\n }\n\n return helpers.error('string.creditCard');\n }\n },\n dataUri: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['paddingRequired']);\n options = _objectSpread({\n paddingRequired: true\n }, options);\n Assert(typeof options.paddingRequired === 'boolean', 'paddingRequired must be boolean');\n return this.$_addRule({\n name: 'dataUri',\n args: {\n options\n }\n });\n },\n validate: function validate(value, helpers, _ref5) {\n let {\n options\n } = _ref5;\n const matches = value.match(internals.dataUriRegex.format);\n\n if (matches) {\n if (!matches[2]) {\n return value;\n }\n\n if (matches[2] !== 'base64') {\n return value;\n }\n\n const base64regex = internals.dataUriRegex.base64[options.paddingRequired];\n\n if (base64regex.test(matches[3])) {\n return value;\n }\n }\n\n return helpers.error('string.dataUri');\n }\n },\n domain: {\n method: function method(options) {\n if (options) {\n Common.assertOptions(options, ['allowUnicode', 'minDomainSegments', 'tlds']);\n options = internals.addressOptions(options);\n }\n\n return this.$_addRule({\n name: 'domain',\n args: {\n options\n }\n });\n },\n validate: function validate(value, helpers, _ref6) {\n let {\n options\n } = _ref6;\n\n if (Address.domain.isValid(value, options)) {\n return value;\n }\n\n return helpers.error('string.domain');\n }\n },\n email: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['allowUnicode', 'minDomainSegments', 'multiple', 'separator', 'tlds']);\n Assert(options.multiple === undefined || typeof options.multiple === 'boolean', 'multiple option must be an boolean');\n options = internals.addressOptions(options);\n const regex = new RegExp(\"\\\\s*[\".concat(options.separator ? EscapeRegex(options.separator) : ',', \"]\\\\s*\"));\n return this.$_addRule({\n name: 'email',\n args: {\n options\n },\n regex\n });\n },\n validate: function validate(value, helpers, _ref7, _ref8) {\n let {\n options\n } = _ref7;\n let {\n regex\n } = _ref8;\n const emails = options.multiple ? value.split(regex) : [value];\n const invalids = [];\n\n for (const email of emails) {\n if (!Address.email.isValid(email, options)) {\n invalids.push(email);\n }\n }\n\n if (!invalids.length) {\n return value;\n }\n\n return helpers.error('string.email', {\n value,\n invalids\n });\n }\n },\n guid: {\n alias: 'uuid',\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['version']);\n let versionNumbers = '';\n\n if (options.version) {\n const versions = [].concat(options.version);\n Assert(versions.length >= 1, 'version must have at least 1 valid version specified');\n const set = new Set();\n\n for (let i = 0; i < versions.length; ++i) {\n const version = versions[i];\n Assert(typeof version === 'string', 'version at position ' + i + ' must be a string');\n const versionNumber = internals.guidVersions[version.toLowerCase()];\n Assert(versionNumber, 'version at position ' + i + ' must be one of ' + Object.keys(internals.guidVersions).join(', '));\n Assert(!set.has(versionNumber), 'version at position ' + i + ' must not be a duplicate');\n versionNumbers += versionNumber;\n set.add(versionNumber);\n }\n }\n\n const regex = new RegExp(\"^([\\\\[{\\\\(]?)[0-9A-F]{8}([:-]?)[0-9A-F]{4}\\\\2?[\".concat(versionNumbers || '0-9A-F', \"][0-9A-F]{3}\\\\2?[\").concat(versionNumbers ? '89AB' : '0-9A-F', \"][0-9A-F]{3}\\\\2?[0-9A-F]{12}([\\\\]}\\\\)]?)$\"), 'i');\n return this.$_addRule({\n name: 'guid',\n args: {\n options\n },\n regex\n });\n },\n validate: function validate(value, helpers, args, _ref9) {\n let {\n regex\n } = _ref9;\n const results = regex.exec(value);\n\n if (!results) {\n return helpers.error('string.guid');\n } // Matching braces\n\n\n if (internals.guidBrackets[results[1]] !== results[results.length - 1]) {\n return helpers.error('string.guid');\n }\n\n return value;\n }\n },\n hex: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['byteAligned']);\n options = _objectSpread({\n byteAligned: false\n }, options);\n Assert(typeof options.byteAligned === 'boolean', 'byteAligned must be boolean');\n return this.$_addRule({\n name: 'hex',\n args: {\n options\n }\n });\n },\n validate: function validate(value, helpers, _ref10) {\n let {\n options\n } = _ref10;\n\n if (!internals.hexRegex.test(value)) {\n return helpers.error('string.hex');\n }\n\n if (options.byteAligned && value.length % 2 !== 0) {\n return helpers.error('string.hexAlign');\n }\n\n return value;\n }\n },\n hostname: {\n method: function method() {\n return this.$_addRule('hostname');\n },\n validate: function validate(value, helpers) {\n if (value.length <= 255 && internals.hostRegex.test(value) || internals.ipRegex.test(value)) {\n return value;\n }\n\n return helpers.error('string.hostname');\n }\n },\n insensitive: {\n method: function method() {\n return this.$_setFlag('insensitive', true);\n }\n },\n ip: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['cidr', 'version']);\n options = Object.assign({}, options); // Shallow cloned\n\n let regex = internals.ipRegex;\n\n if (options.cidr) {\n Assert(typeof options.cidr === 'string', 'cidr must be a string');\n options.cidr = options.cidr.toLowerCase();\n Assert(Contain(internals.cidrPresences, options.cidr), 'cidr must be one of ' + internals.cidrPresences.join(', '));\n\n if (!options.version && options.cidr !== 'optional') {\n regex = Ip.createIpRegex(['ipv4', 'ipv6', 'ipvfuture'], options.cidr);\n }\n } else {\n options.cidr = 'optional';\n }\n\n let versions;\n\n if (options.version) {\n if (!Array.isArray(options.version)) {\n options.version = [options.version];\n }\n\n Assert(options.version.length >= 1, 'version must have at least 1 version specified');\n versions = [];\n\n for (let i = 0; i < options.version.length; ++i) {\n let version = options.version[i];\n Assert(typeof version === 'string', 'version at position ' + i + ' must be a string');\n version = version.toLowerCase();\n Assert(Ip.versions[version], 'version at position ' + i + ' must be one of ' + Object.keys(Ip.versions).join(', '));\n versions.push(version);\n }\n\n versions = Array.from(new Set(versions));\n regex = Ip.createIpRegex(versions, options.cidr);\n }\n\n return this.$_addRule({\n name: 'ip',\n args: {\n options\n },\n versions,\n regex\n });\n },\n validate: function validate(value, helpers, _ref11, _ref12) {\n let {\n options\n } = _ref11;\n let {\n versions,\n regex\n } = _ref12;\n\n if (regex.test(value)) {\n return value;\n }\n\n if (versions) {\n return helpers.error('string.ipVersion', {\n value,\n cidr: options.cidr,\n version: versions\n });\n }\n\n return helpers.error('string.ip', {\n value,\n cidr: options.cidr\n });\n }\n },\n isoDate: {\n method: function method() {\n return this.$_addRule('isoDate');\n },\n validate: function validate(value, _ref13) {\n let {\n error\n } = _ref13;\n\n if (Common.isIsoDate(value)) {\n return value;\n }\n\n return error('string.isoDate');\n },\n convert: true\n },\n isoDuration: {\n method: function method() {\n return this.$_addRule('isoDuration');\n },\n validate: function validate(value, helpers) {\n if (internals.isoDurationRegex.test(value)) {\n return value;\n }\n\n return helpers.error('string.isoDuration');\n }\n },\n length: {\n method: function method(limit, encoding) {\n return internals.length(this, 'length', limit, '=', encoding);\n },\n validate: function validate(value, helpers, _ref14, _ref15) {\n let {\n limit,\n encoding\n } = _ref14;\n let {\n name,\n operator,\n args\n } = _ref15;\n const length = encoding ? Buffer && Buffer.byteLength(value, encoding) : value.length; // $lab:coverage:ignore$\n\n if (Common.compare(length, limit, operator)) {\n return value;\n }\n\n return helpers.error('string.' + name, {\n limit: args.limit,\n value,\n encoding\n });\n },\n args: [{\n name: 'limit',\n ref: true,\n assert: Common.limit,\n message: 'must be a positive integer'\n }, 'encoding']\n },\n lowercase: {\n method: function method() {\n return this.case('lower');\n }\n },\n max: {\n method: function method(limit, encoding) {\n return internals.length(this, 'max', limit, '<=', encoding);\n },\n args: ['limit', 'encoding']\n },\n min: {\n method: function method(limit, encoding) {\n return internals.length(this, 'min', limit, '>=', encoding);\n },\n args: ['limit', 'encoding']\n },\n normalize: {\n method: function method() {\n let form = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'NFC';\n Assert(Contain(internals.normalizationForms, form), 'normalization form must be one of ' + internals.normalizationForms.join(', '));\n return this.$_addRule({\n name: 'normalize',\n args: {\n form\n }\n });\n },\n validate: function validate(value, _ref16, _ref17) {\n let {\n error\n } = _ref16;\n let {\n form\n } = _ref17;\n\n if (value === value.normalize(form)) {\n return value;\n }\n\n return error('string.normalize', {\n value,\n form\n });\n },\n convert: true\n },\n pattern: {\n alias: 'regex',\n method: function method(regex) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n Assert(regex instanceof RegExp, 'regex must be a RegExp');\n Assert(!regex.flags.includes('g') && !regex.flags.includes('y'), 'regex should not use global or sticky mode');\n\n if (typeof options === 'string') {\n options = {\n name: options\n };\n }\n\n Common.assertOptions(options, ['invert', 'name']);\n const errorCode = ['string.pattern', options.invert ? '.invert' : '', options.name ? '.name' : '.base'].join('');\n return this.$_addRule({\n name: 'pattern',\n args: {\n regex,\n options\n },\n errorCode\n });\n },\n validate: function validate(value, helpers, _ref18, _ref19) {\n let {\n regex,\n options\n } = _ref18;\n let {\n errorCode\n } = _ref19;\n const patternMatch = regex.test(value);\n\n if (patternMatch ^ options.invert) {\n return value;\n }\n\n return helpers.error(errorCode, {\n name: options.name,\n regex,\n value\n });\n },\n args: ['regex', 'options'],\n multi: true\n },\n replace: {\n method: function method(pattern, replacement) {\n if (typeof pattern === 'string') {\n pattern = new RegExp(EscapeRegex(pattern), 'g');\n }\n\n Assert(pattern instanceof RegExp, 'pattern must be a RegExp');\n Assert(typeof replacement === 'string', 'replacement must be a String');\n const obj = this.clone();\n\n if (!obj.$_terms.replacements) {\n obj.$_terms.replacements = [];\n }\n\n obj.$_terms.replacements.push({\n pattern,\n replacement\n });\n return obj;\n }\n },\n token: {\n method: function method() {\n return this.$_addRule('token');\n },\n validate: function validate(value, helpers) {\n if (/^\\w+$/.test(value)) {\n return value;\n }\n\n return helpers.error('string.token');\n }\n },\n trim: {\n method: function method() {\n let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof enabled === 'boolean', 'enabled must be a boolean');\n return this.$_addRule({\n name: 'trim',\n args: {\n enabled\n }\n });\n },\n validate: function validate(value, helpers, _ref20) {\n let {\n enabled\n } = _ref20;\n\n if (!enabled || value === value.trim()) {\n return value;\n }\n\n return helpers.error('string.trim');\n },\n convert: true\n },\n truncate: {\n method: function method() {\n let enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n Assert(typeof enabled === 'boolean', 'enabled must be a boolean');\n return this.$_setFlag('truncate', enabled);\n }\n },\n uppercase: {\n method: function method() {\n return this.case('upper');\n }\n },\n uri: {\n method: function method() {\n let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n Common.assertOptions(options, ['allowRelative', 'allowQuerySquareBrackets', 'domain', 'relativeOnly', 'scheme']);\n const unknownOptions = Object.keys(options).filter(key => !['scheme', 'allowRelative', 'relativeOnly', 'allowQuerySquareBrackets', 'domain'].includes(key));\n Assert(unknownOptions.length === 0, \"options contain unknown keys: \".concat(unknownOptions));\n\n if (options.domain) {\n options = Object.assign({}, options); // Shallow cloned\n\n options.domain = internals.addressOptions(options.domain);\n }\n\n const regex = Uri.createRegex(options);\n return this.$_addRule({\n name: 'uri',\n args: {\n options\n },\n regex\n });\n },\n validate: function validate(value, helpers, _ref21, _ref22) {\n let {\n options\n } = _ref21;\n let {\n regex\n } = _ref22;\n\n if (['http:/', 'https:/'].includes(value)) {\n // scheme:/ is technically valid but makes no sense\n return helpers.error('string.uri');\n }\n\n const match = regex.exec(value);\n\n if (match) {\n if (options.domain && !Address.domain.isValid(match[1], options.domain)) {\n return helpers.error('string.domain', {\n value: match[1]\n });\n }\n\n return value;\n }\n\n if (options.relativeOnly) {\n return helpers.error('string.uriRelativeOnly');\n }\n\n if (options.scheme) {\n return helpers.error('string.uriCustomScheme', {\n scheme: regex.scheme,\n value\n });\n }\n\n return helpers.error('string.uri');\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n for (const _ref23 of desc.replacements) {\n const {\n pattern,\n replacement\n } = _ref23;\n obj = obj.replace(pattern, replacement);\n }\n\n return obj;\n },\n // Errors\n messages: {\n 'string.alphanum': '\"{{#label}}\" must only contain alpha-numeric characters',\n 'string.base': '\"{{#label}}\" must be a string',\n 'string.base64': '\"{{#label}}\" must be a valid base64 string',\n 'string.creditCard': '\"{{#label}}\" must be a credit card',\n 'string.dataUri': '\"{{#label}}\" must be a valid dataUri string',\n 'string.domain': '\"{{#label}}\" must contain a valid domain name',\n 'string.email': '\"{{#label}}\" must be a valid email',\n 'string.empty': '\"{{#label}}\" is not allowed to be empty',\n 'string.guid': '\"{{#label}}\" must be a valid GUID',\n 'string.hex': '\"{{#label}}\" must only contain hexadecimal characters',\n 'string.hexAlign': '\"{{#label}}\" hex decoded representation must be byte aligned',\n 'string.hostname': '\"{{#label}}\" must be a valid hostname',\n 'string.ip': '\"{{#label}}\" must be a valid ip address with a {{#cidr}} CIDR',\n 'string.ipVersion': '\"{{#label}}\" must be a valid ip address of one of the following versions {{#version}} with a {{#cidr}} CIDR',\n 'string.isoDate': '\"{{#label}}\" must be a valid ISO 8601 date',\n 'string.isoDuration': '\"{{#label}}\" must be a valid ISO 8601 duration',\n 'string.length': '\"{{#label}}\" length must be {{#limit}} characters long',\n 'string.lowercase': '\"{{#label}}\" must only contain lowercase characters',\n 'string.max': '\"{{#label}}\" length must be less than or equal to {{#limit}} characters long',\n 'string.min': '\"{{#label}}\" length must be at least {{#limit}} characters long',\n 'string.normalize': '\"{{#label}}\" must be unicode normalized in the {{#form}} form',\n 'string.token': '\"{{#label}}\" must only contain alpha-numeric and underscore characters',\n 'string.pattern.base': '\"{{#label}}\" with value \"{[.]}\" fails to match the required pattern: {{#regex}}',\n 'string.pattern.name': '\"{{#label}}\" with value \"{[.]}\" fails to match the {{#name}} pattern',\n 'string.pattern.invert.base': '\"{{#label}}\" with value \"{[.]}\" matches the inverted pattern: {{#regex}}',\n 'string.pattern.invert.name': '\"{{#label}}\" with value \"{[.]}\" matches the inverted {{#name}} pattern',\n 'string.trim': '\"{{#label}}\" must not have leading or trailing whitespace',\n 'string.uri': '\"{{#label}}\" must be a valid uri',\n 'string.uriCustomScheme': '\"{{#label}}\" must be a valid uri with a scheme matching the {{#scheme}} pattern',\n 'string.uriRelativeOnly': '\"{{#label}}\" must be a valid relative uri',\n 'string.uppercase': '\"{{#label}}\" must only contain uppercase characters'\n }\n}); // Helpers\n\ninternals.addressOptions = function (options) {\n if (options.tlds && typeof options.tlds === 'object') {\n Assert(options.tlds.allow === undefined || options.tlds.allow === false || options.tlds.allow === true || Array.isArray(options.tlds.allow) || options.tlds.allow instanceof Set, 'tlds.allow must be an array, Set, or boolean');\n Assert(options.tlds.deny === undefined || Array.isArray(options.tlds.deny) || options.tlds.deny instanceof Set, 'tlds.deny must be an array or Set');\n\n const normalizeTable = table => {\n if (table === undefined || typeof table === 'boolean' || table instanceof Set) {\n return table;\n }\n\n return new Set(table);\n };\n\n options = Object.assign({}, options); // Shallow cloned\n\n options.tlds = {\n allow: normalizeTable(options.tlds.allow),\n deny: normalizeTable(options.tlds.deny)\n };\n }\n\n Assert(options.minDomainSegments === undefined || Number.isSafeInteger(options.minDomainSegments) && options.minDomainSegments > 0, 'minDomainSegments must be a positive integer');\n return options;\n};\n\ninternals.length = function (schema, name, limit, operator, encoding) {\n Assert(!encoding || Buffer && Buffer.isEncoding(encoding), 'Invalid encoding:', encoding); // $lab:coverage:ignore$\n\n return schema.$_addRule({\n name,\n method: 'length',\n args: {\n limit,\n encoding\n },\n operator\n });\n};" }, { - "id": 44, + "id": 43, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "name": "../node_modules/@hapi/address/lib/index.js", "index": 41, - "index2": 45, - "size": 7870, + "index2": 44, + "size": 6236, "cacheable": true, "built": true, "optional": false, @@ -8408,7 +8222,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", - "issuerId": 43, + "issuerId": 42, "issuerName": "../lib/types/string/index.js", "issuerPath": [ { @@ -8416,25 +8230,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 }, "failed": false, "errors": 0, @@ -8442,13 +8256,13 @@ "assets": [], "reasons": [ { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "@hapi/address", - "loc": "11:14-38" + "loc": "9:16-40" } ], "usedExports": true, @@ -8457,15 +8271,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Punycode = require('punycode');\n\nvar Abnf = require('./abnf');\n\nvar Tlds = require('./tlds');\n\nvar internals = {\n nonAsciiRx: /[^\\x00-\\x7f]/,\n minDomainSegments: 2,\n defaultTlds: {\n allow: Tlds,\n deny: null\n }\n};\nmodule.exports = {\n email: {\n analyze: function analyze(email, options) {\n return internals.email(email, options);\n },\n isValid: function isValid(email, options) {\n return !internals.email(email, options);\n }\n },\n domain: {\n analyze: function analyze(domain) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n internals.options(domain, options);\n\n if (!domain) {\n return internals.error('Domain must be a non-empty string');\n }\n\n if (domain.length > 256) {\n return internals.error('Domain too long');\n }\n\n var ascii = !internals.nonAsciiRx.test(domain);\n\n if (!ascii) {\n if (options.allowUnicode === false) {\n // Defaults to true\n return internals.error('Domain contains forbidden Unicode characters');\n }\n\n var normalized = domain.normalize('NFC');\n domain = Punycode.toASCII(normalized);\n }\n\n return internals.domain(domain, options);\n },\n isValid: function isValid(domain, options) {\n return !module.exports.domain.analyze(domain, options);\n }\n }\n};\n\ninternals.email = function (email) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n internals.options(email, options);\n\n if (!email) {\n return internals.error('Address must be a non-empty string');\n } // Unicode\n\n\n var ascii = !internals.nonAsciiRx.test(email);\n\n if (!ascii) {\n if (options.allowUnicode === false) {\n // Defaults to true\n return internals.error('Address contains forbidden Unicode characters');\n }\n\n var normalized = email.normalize('NFC');\n email = Punycode.toASCII(normalized);\n } // Basic structure\n\n\n var parts = email.split('@');\n\n if (parts.length !== 2) {\n return internals.error(parts.length > 2 ? 'Address cannot contain more than one @ character' : 'Address must contain one @ character');\n }\n\n var local = parts[0];\n var domain = parts[1];\n\n if (!local) {\n return internals.error('Address local part cannot be empty');\n }\n\n if (!domain) {\n return internals.error('Domain cannot be empty');\n }\n\n if (email.length > 254) {\n // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.3\n return internals.error('Address too long');\n }\n\n if (Buffer.byteLength(local, 'utf-8') > 64) {\n // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.1\n return internals.error('Address local part too long');\n } // Validate parts\n\n\n return internals.local(local, ascii) || internals.domain(domain, options);\n};\n\ninternals.options = function (value, options) {\n // Options validation\n if (options.tlds && options.tlds !== true) {\n if (_typeof(options.tlds) !== 'object') {\n throw new Error('Invalid options: tlds must be a boolean or an object');\n }\n\n if (options.tlds.allow !== undefined && options.tlds.allow !== true && options.tlds.allow instanceof Set === false) {\n throw new Error('Invalid options: tlds.allow must be a Set object or true');\n }\n\n if (options.tlds.deny) {\n if (options.tlds.deny instanceof Set === false) {\n throw new Error('Invalid options: tlds.deny must be a Set object');\n }\n\n if (options.tlds.allow instanceof Set) {\n throw new Error('Invalid options: cannot specify both tlds.allow and tlds.deny lists');\n }\n }\n } // Input validation\n\n\n if (typeof value !== 'string') {\n throw new Error('Invalid input: value must be a string');\n }\n};\n\ninternals.local = function (local, ascii) {\n var segments = local.split('.');\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = segments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var segment = _step.value;\n\n if (!segment.length) {\n return internals.error('Address local part contains empty dot-separated segment');\n }\n\n if (ascii) {\n if (!Abnf.atextRx.test(segment)) {\n return internals.error('Address local part contains invalid character');\n }\n } else {\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = segment[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var char = _step2.value;\n var binary = Buffer.from(char).toString('binary');\n\n if (!Abnf.atomRx.test(binary)) {\n return internals.error('Address local part contains invalid character');\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n};\n\ninternals.tldSegmentRx = /^[a-zA-Z](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?$/;\ninternals.domainSegmentRx = /^[a-zA-Z0-9](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?$/;\n\ninternals.domain = function (domain, options) {\n // https://tools.ietf.org/html/rfc1035 section 2.3.1\n var minDomainSegments = options.minDomainSegments || internals.minDomainSegments;\n var segments = domain.split('.');\n\n if (segments.length < minDomainSegments) {\n return internals.error('Domain lacks the minimum required number of segments');\n }\n\n var tlds = internals.tlds(options);\n\n if (tlds) {\n var tld = segments[segments.length - 1].toLowerCase();\n\n if (tlds.deny && tlds.deny.has(tld) || tlds.allow && !tlds.allow.has(tld)) {\n return internals.error('Domain uses forbidden TLD');\n }\n }\n\n for (var i = 0; i < segments.length; ++i) {\n var segment = segments[i];\n\n if (!segment.length) {\n return internals.error('Domain contains empty dot-separated segment');\n }\n\n if (segment.length > 63) {\n return internals.error('Domain contains dot-separated segment that is too long');\n }\n\n if (i < segments.length - 1) {\n if (!internals.domainSegmentRx.test(segment)) {\n return internals.error('Domain contains invalid character');\n }\n } else {\n if (!internals.tldSegmentRx.test(segment)) {\n return internals.error('Domain contains invalid tld character');\n }\n }\n }\n};\n\ninternals.tlds = function (options) {\n if (options.tlds === false) {\n // Defaults to true\n return null;\n }\n\n if (!options.tlds || options.tlds === true) {\n return internals.defaultTlds;\n }\n\n return {\n allow: options.tlds.allow === true ? null : options.tlds.allow || Tlds,\n deny: options.tlds.deny || null\n };\n};\n\ninternals.error = function (reason) {\n return {\n error: reason\n };\n};" + "source": "'use strict';\n\nconst Punycode = require('punycode');\n\nconst Abnf = require('./abnf');\n\nconst Tlds = require('./tlds');\n\nconst internals = {\n nonAsciiRx: /[^\\x00-\\x7f]/,\n minDomainSegments: 2,\n defaultTlds: {\n allow: Tlds,\n deny: null\n }\n};\nmodule.exports = {\n email: {\n analyze: function analyze(email, options) {\n return internals.email(email, options);\n },\n isValid: function isValid(email, options) {\n return !internals.email(email, options);\n }\n },\n domain: {\n analyze: function analyze(domain) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n internals.options(domain, options);\n\n if (!domain) {\n return internals.error('Domain must be a non-empty string');\n }\n\n if (domain.length > 256) {\n return internals.error('Domain too long');\n }\n\n const ascii = !internals.nonAsciiRx.test(domain);\n\n if (!ascii) {\n if (options.allowUnicode === false) {\n // Defaults to true\n return internals.error('Domain contains forbidden Unicode characters');\n }\n\n const normalized = domain.normalize('NFC');\n domain = Punycode.toASCII(normalized);\n }\n\n return internals.domain(domain, options);\n },\n isValid: function isValid(domain, options) {\n return !module.exports.domain.analyze(domain, options);\n }\n }\n};\n\ninternals.email = function (email) {\n let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n internals.options(email, options);\n\n if (!email) {\n return internals.error('Address must be a non-empty string');\n } // Unicode\n\n\n const ascii = !internals.nonAsciiRx.test(email);\n\n if (!ascii) {\n if (options.allowUnicode === false) {\n // Defaults to true\n return internals.error('Address contains forbidden Unicode characters');\n }\n\n const normalized = email.normalize('NFC');\n email = Punycode.toASCII(normalized);\n } // Basic structure\n\n\n const parts = email.split('@');\n\n if (parts.length !== 2) {\n return internals.error(parts.length > 2 ? 'Address cannot contain more than one @ character' : 'Address must contain one @ character');\n }\n\n const local = parts[0];\n const domain = parts[1];\n\n if (!local) {\n return internals.error('Address local part cannot be empty');\n }\n\n if (!domain) {\n return internals.error('Domain cannot be empty');\n }\n\n if (email.length > 254) {\n // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.3\n return internals.error('Address too long');\n }\n\n if (Buffer.byteLength(local, 'utf-8') > 64) {\n // http://tools.ietf.org/html/rfc5321#section-4.5.3.1.1\n return internals.error('Address local part too long');\n } // Validate parts\n\n\n return internals.local(local, ascii) || internals.domain(domain, options);\n};\n\ninternals.options = function (value, options) {\n // Options validation\n if (options.tlds && options.tlds !== true) {\n if (typeof options.tlds !== 'object') {\n throw new Error('Invalid options: tlds must be a boolean or an object');\n }\n\n if (options.tlds.allow !== undefined && options.tlds.allow !== true && options.tlds.allow instanceof Set === false) {\n throw new Error('Invalid options: tlds.allow must be a Set object or true');\n }\n\n if (options.tlds.deny) {\n if (options.tlds.deny instanceof Set === false) {\n throw new Error('Invalid options: tlds.deny must be a Set object');\n }\n\n if (options.tlds.allow instanceof Set) {\n throw new Error('Invalid options: cannot specify both tlds.allow and tlds.deny lists');\n }\n }\n } // Input validation\n\n\n if (typeof value !== 'string') {\n throw new Error('Invalid input: value must be a string');\n }\n};\n\ninternals.local = function (local, ascii) {\n const segments = local.split('.');\n\n for (const segment of segments) {\n if (!segment.length) {\n return internals.error('Address local part contains empty dot-separated segment');\n }\n\n if (ascii) {\n if (!Abnf.atextRx.test(segment)) {\n return internals.error('Address local part contains invalid character');\n }\n } else {\n for (const char of segment) {\n const binary = Buffer.from(char).toString('binary');\n\n if (!Abnf.atomRx.test(binary)) {\n return internals.error('Address local part contains invalid character');\n }\n }\n }\n }\n};\n\ninternals.tldSegmentRx = /^[a-zA-Z](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?$/;\ninternals.domainSegmentRx = /^[a-zA-Z0-9](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?$/;\n\ninternals.domain = function (domain, options) {\n // https://tools.ietf.org/html/rfc1035 section 2.3.1\n const minDomainSegments = options.minDomainSegments || internals.minDomainSegments;\n const segments = domain.split('.');\n\n if (segments.length < minDomainSegments) {\n return internals.error('Domain lacks the minimum required number of segments');\n }\n\n const tlds = internals.tlds(options);\n\n if (tlds) {\n const tld = segments[segments.length - 1].toLowerCase();\n\n if (tlds.deny && tlds.deny.has(tld) || tlds.allow && !tlds.allow.has(tld)) {\n return internals.error('Domain uses forbidden TLD');\n }\n }\n\n for (let i = 0; i < segments.length; ++i) {\n const segment = segments[i];\n\n if (!segment.length) {\n return internals.error('Domain contains empty dot-separated segment');\n }\n\n if (segment.length > 63) {\n return internals.error('Domain contains dot-separated segment that is too long');\n }\n\n if (i < segments.length - 1) {\n if (!internals.domainSegmentRx.test(segment)) {\n return internals.error('Domain contains invalid character');\n }\n } else {\n if (!internals.tldSegmentRx.test(segment)) {\n return internals.error('Domain contains invalid tld character');\n }\n }\n }\n};\n\ninternals.tlds = function (options) {\n if (options.tlds === false) {\n // Defaults to true\n return null;\n }\n\n if (!options.tlds || options.tlds === true) {\n return internals.defaultTlds;\n }\n\n return {\n allow: options.tlds.allow === true ? null : options.tlds.allow || Tlds,\n deny: options.tlds.deny || null\n };\n};\n\ninternals.error = function (reason) {\n return {\n error: reason\n };\n};" }, { - "id": 45, + "id": 44, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", "name": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "index": 42, - "index2": 42, - "size": 16159, + "index2": 41, + "size": 15653, "cacheable": true, "built": true, "optional": false, @@ -8474,7 +8288,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", - "issuerId": 44, + "issuerId": 43, "issuerName": "../node_modules/@hapi/address/lib/index.js", "issuerPath": [ { @@ -8482,34 +8296,34 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 44, + "id": 43, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "name": "../node_modules/@hapi/address/lib/index.js", "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 } } ], "profile": { - "factory": 4, - "building": 95 + "factory": 3, + "building": 94 }, "failed": false, "errors": 0, @@ -8517,13 +8331,13 @@ "assets": [], "reasons": [ { - "moduleId": 44, + "moduleId": 43, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "module": "../node_modules/@hapi/address/lib/index.js", "moduleName": "../node_modules/@hapi/address/lib/index.js", "type": "cjs require", "userRequest": "punycode", - "loc": "5:15-34" + "loc": "3:17-36" } ], "usedExports": true, @@ -8532,10 +8346,10 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n/*! https://mths.be/punycode v1.4.1 by @mathias */\n;\n\n(function (root) {\n /** Detect free variables */\n var freeExports = (typeof exports === \"undefined\" ? \"undefined\" : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports;\n var freeModule = (typeof module === \"undefined\" ? \"undefined\" : _typeof(module)) == 'object' && module && !module.nodeType && module;\n var freeGlobal = (typeof global === \"undefined\" ? \"undefined\" : _typeof(global)) == 'object' && global;\n\n if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {\n root = freeGlobal;\n }\n /**\n * The `punycode` object.\n * @name punycode\n * @type Object\n */\n\n\n var punycode,\n\n /** Highest positive signed 32-bit float value */\n maxInt = 2147483647,\n // aka. 0x7FFFFFFF or 2^31-1\n\n /** Bootstring parameters */\n base = 36,\n tMin = 1,\n tMax = 26,\n skew = 38,\n damp = 700,\n initialBias = 72,\n initialN = 128,\n // 0x80\n delimiter = '-',\n // '\\x2D'\n\n /** Regular expressions */\n regexPunycode = /^xn--/,\n regexNonASCII = /[^\\x20-\\x7E]/,\n // unprintable ASCII chars + non-ASCII chars\n regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g,\n // RFC 3490 separators\n\n /** Error messages */\n errors = {\n 'overflow': 'Overflow: input needs wider integers to process',\n 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',\n 'invalid-input': 'Invalid input'\n },\n\n /** Convenience shortcuts */\n baseMinusTMin = base - tMin,\n floor = Math.floor,\n stringFromCharCode = String.fromCharCode,\n\n /** Temporary variable */\n key;\n /*--------------------------------------------------------------------------*/\n\n /**\n * A generic error utility function.\n * @private\n * @param {String} type The error type.\n * @returns {Error} Throws a `RangeError` with the applicable error message.\n */\n\n function error(type) {\n throw new RangeError(errors[type]);\n }\n /**\n * A generic `Array#map` utility function.\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} callback The function that gets called for every array\n * item.\n * @returns {Array} A new array of values returned by the callback function.\n */\n\n\n function map(array, fn) {\n var length = array.length;\n var result = [];\n\n while (length--) {\n result[length] = fn(array[length]);\n }\n\n return result;\n }\n /**\n * A simple `Array#map`-like wrapper to work with domain name strings or email\n * addresses.\n * @private\n * @param {String} domain The domain name or email address.\n * @param {Function} callback The function that gets called for every\n * character.\n * @returns {Array} A new string of characters returned by the callback\n * function.\n */\n\n\n function mapDomain(string, fn) {\n var parts = string.split('@');\n var result = '';\n\n if (parts.length > 1) {\n // In email addresses, only the domain name should be punycoded. Leave\n // the local part (i.e. everything up to `@`) intact.\n result = parts[0] + '@';\n string = parts[1];\n } // Avoid `split(regex)` for IE8 compatibility. See #17.\n\n\n string = string.replace(regexSeparators, '\\x2E');\n var labels = string.split('.');\n var encoded = map(labels, fn).join('.');\n return result + encoded;\n }\n /**\n * Creates an array containing the numeric code points of each Unicode\n * character in the string. While JavaScript uses UCS-2 internally,\n * this function will convert a pair of surrogate halves (each of which\n * UCS-2 exposes as separate characters) into a single code point,\n * matching UTF-16.\n * @see `punycode.ucs2.encode`\n * @see \n * @memberOf punycode.ucs2\n * @name decode\n * @param {String} string The Unicode input string (UCS-2).\n * @returns {Array} The new array of code points.\n */\n\n\n function ucs2decode(string) {\n var output = [],\n counter = 0,\n length = string.length,\n value,\n extra;\n\n while (counter < length) {\n value = string.charCodeAt(counter++);\n\n if (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n // high surrogate, and there is a next character\n extra = string.charCodeAt(counter++);\n\n if ((extra & 0xFC00) == 0xDC00) {\n // low surrogate\n output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n } else {\n // unmatched surrogate; only append this code unit, in case the next\n // code unit is the high surrogate of a surrogate pair\n output.push(value);\n counter--;\n }\n } else {\n output.push(value);\n }\n }\n\n return output;\n }\n /**\n * Creates a string based on an array of numeric code points.\n * @see `punycode.ucs2.decode`\n * @memberOf punycode.ucs2\n * @name encode\n * @param {Array} codePoints The array of numeric code points.\n * @returns {String} The new Unicode string (UCS-2).\n */\n\n\n function ucs2encode(array) {\n return map(array, function (value) {\n var output = '';\n\n if (value > 0xFFFF) {\n value -= 0x10000;\n output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);\n value = 0xDC00 | value & 0x3FF;\n }\n\n output += stringFromCharCode(value);\n return output;\n }).join('');\n }\n /**\n * Converts a basic code point into a digit/integer.\n * @see `digitToBasic()`\n * @private\n * @param {Number} codePoint The basic numeric code point value.\n * @returns {Number} The numeric value of a basic code point (for use in\n * representing integers) in the range `0` to `base - 1`, or `base` if\n * the code point does not represent a value.\n */\n\n\n function basicToDigit(codePoint) {\n if (codePoint - 48 < 10) {\n return codePoint - 22;\n }\n\n if (codePoint - 65 < 26) {\n return codePoint - 65;\n }\n\n if (codePoint - 97 < 26) {\n return codePoint - 97;\n }\n\n return base;\n }\n /**\n * Converts a digit/integer into a basic code point.\n * @see `basicToDigit()`\n * @private\n * @param {Number} digit The numeric value of a basic code point.\n * @returns {Number} The basic code point whose value (when used for\n * representing integers) is `digit`, which needs to be in the range\n * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is\n * used; else, the lowercase form is used. The behavior is undefined\n * if `flag` is non-zero and `digit` has no uppercase form.\n */\n\n\n function digitToBasic(digit, flag) {\n // 0..25 map to ASCII a..z or A..Z\n // 26..35 map to ASCII 0..9\n return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);\n }\n /**\n * Bias adaptation function as per section 3.4 of RFC 3492.\n * https://tools.ietf.org/html/rfc3492#section-3.4\n * @private\n */\n\n\n function adapt(delta, numPoints, firstTime) {\n var k = 0;\n delta = firstTime ? floor(delta / damp) : delta >> 1;\n delta += floor(delta / numPoints);\n\n for (;\n /* no initialization */\n delta > baseMinusTMin * tMax >> 1; k += base) {\n delta = floor(delta / baseMinusTMin);\n }\n\n return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n }\n /**\n * Converts a Punycode string of ASCII-only symbols to a string of Unicode\n * symbols.\n * @memberOf punycode\n * @param {String} input The Punycode string of ASCII-only symbols.\n * @returns {String} The resulting string of Unicode symbols.\n */\n\n\n function decode(input) {\n // Don't use UCS-2\n var output = [],\n inputLength = input.length,\n out,\n i = 0,\n n = initialN,\n bias = initialBias,\n basic,\n j,\n index,\n oldi,\n w,\n k,\n digit,\n t,\n\n /** Cached calculation results */\n baseMinusT; // Handle the basic code points: let `basic` be the number of input code\n // points before the last delimiter, or `0` if there is none, then copy\n // the first basic code points to the output.\n\n basic = input.lastIndexOf(delimiter);\n\n if (basic < 0) {\n basic = 0;\n }\n\n for (j = 0; j < basic; ++j) {\n // if it's not a basic code point\n if (input.charCodeAt(j) >= 0x80) {\n error('not-basic');\n }\n\n output.push(input.charCodeAt(j));\n } // Main decoding loop: start just after the last delimiter if any basic code\n // points were copied; start at the beginning otherwise.\n\n\n for (index = basic > 0 ? basic + 1 : 0; index < inputLength;)\n /* no final expression */\n {\n // `index` is the index of the next character to be consumed.\n // Decode a generalized variable-length integer into `delta`,\n // which gets added to `i`. The overflow checking is easier\n // if we increase `i` as we go, then subtract off its starting\n // value at the end to obtain `delta`.\n for (oldi = i, w = 1, k = base;;\n /* no condition */\n k += base) {\n if (index >= inputLength) {\n error('invalid-input');\n }\n\n digit = basicToDigit(input.charCodeAt(index++));\n\n if (digit >= base || digit > floor((maxInt - i) / w)) {\n error('overflow');\n }\n\n i += digit * w;\n t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n\n if (digit < t) {\n break;\n }\n\n baseMinusT = base - t;\n\n if (w > floor(maxInt / baseMinusT)) {\n error('overflow');\n }\n\n w *= baseMinusT;\n }\n\n out = output.length + 1;\n bias = adapt(i - oldi, out, oldi == 0); // `i` was supposed to wrap around from `out` to `0`,\n // incrementing `n` each time, so we'll fix that now:\n\n if (floor(i / out) > maxInt - n) {\n error('overflow');\n }\n\n n += floor(i / out);\n i %= out; // Insert `n` at position `i` of the output\n\n output.splice(i++, 0, n);\n }\n\n return ucs2encode(output);\n }\n /**\n * Converts a string of Unicode symbols (e.g. a domain name label) to a\n * Punycode string of ASCII-only symbols.\n * @memberOf punycode\n * @param {String} input The string of Unicode symbols.\n * @returns {String} The resulting Punycode string of ASCII-only symbols.\n */\n\n\n function encode(input) {\n var n,\n delta,\n handledCPCount,\n basicLength,\n bias,\n j,\n m,\n q,\n k,\n t,\n currentValue,\n output = [],\n\n /** `inputLength` will hold the number of code points in `input`. */\n inputLength,\n\n /** Cached calculation results */\n handledCPCountPlusOne,\n baseMinusT,\n qMinusT; // Convert the input in UCS-2 to Unicode\n\n input = ucs2decode(input); // Cache the length\n\n inputLength = input.length; // Initialize the state\n\n n = initialN;\n delta = 0;\n bias = initialBias; // Handle the basic code points\n\n for (j = 0; j < inputLength; ++j) {\n currentValue = input[j];\n\n if (currentValue < 0x80) {\n output.push(stringFromCharCode(currentValue));\n }\n }\n\n handledCPCount = basicLength = output.length; // `handledCPCount` is the number of code points that have been handled;\n // `basicLength` is the number of basic code points.\n // Finish the basic string - if it is not empty - with a delimiter\n\n if (basicLength) {\n output.push(delimiter);\n } // Main encoding loop:\n\n\n while (handledCPCount < inputLength) {\n // All non-basic code points < n have been handled already. Find the next\n // larger one:\n for (m = maxInt, j = 0; j < inputLength; ++j) {\n currentValue = input[j];\n\n if (currentValue >= n && currentValue < m) {\n m = currentValue;\n }\n } // Increase `delta` enough to advance the decoder's state to ,\n // but guard against overflow\n\n\n handledCPCountPlusOne = handledCPCount + 1;\n\n if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n error('overflow');\n }\n\n delta += (m - n) * handledCPCountPlusOne;\n n = m;\n\n for (j = 0; j < inputLength; ++j) {\n currentValue = input[j];\n\n if (currentValue < n && ++delta > maxInt) {\n error('overflow');\n }\n\n if (currentValue == n) {\n // Represent delta as a generalized variable-length integer\n for (q = delta, k = base;;\n /* no condition */\n k += base) {\n t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n\n if (q < t) {\n break;\n }\n\n qMinusT = q - t;\n baseMinusT = base - t;\n output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));\n q = floor(qMinusT / baseMinusT);\n }\n\n output.push(stringFromCharCode(digitToBasic(q, 0)));\n bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);\n delta = 0;\n ++handledCPCount;\n }\n }\n\n ++delta;\n ++n;\n }\n\n return output.join('');\n }\n /**\n * Converts a Punycode string representing a domain name or an email address\n * to Unicode. Only the Punycoded parts of the input will be converted, i.e.\n * it doesn't matter if you call it on a string that has already been\n * converted to Unicode.\n * @memberOf punycode\n * @param {String} input The Punycoded domain name or email address to\n * convert to Unicode.\n * @returns {String} The Unicode representation of the given Punycode\n * string.\n */\n\n\n function toUnicode(input) {\n return mapDomain(input, function (string) {\n return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;\n });\n }\n /**\n * Converts a Unicode string representing a domain name or an email address to\n * Punycode. Only the non-ASCII parts of the domain name will be converted,\n * i.e. it doesn't matter if you call it with a domain that's already in\n * ASCII.\n * @memberOf punycode\n * @param {String} input The domain name or email address to convert, as a\n * Unicode string.\n * @returns {String} The Punycode representation of the given domain name or\n * email address.\n */\n\n\n function toASCII(input) {\n return mapDomain(input, function (string) {\n return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;\n });\n }\n /*--------------------------------------------------------------------------*/\n\n /** Define the public API */\n\n\n punycode = {\n /**\n * A string representing the current Punycode.js version number.\n * @memberOf punycode\n * @type String\n */\n 'version': '1.4.1',\n\n /**\n * An object of methods to convert from JavaScript's internal character\n * representation (UCS-2) to Unicode code points, and back.\n * @see \n * @memberOf punycode\n * @type Object\n */\n 'ucs2': {\n 'decode': ucs2decode,\n 'encode': ucs2encode\n },\n 'decode': decode,\n 'encode': encode,\n 'toASCII': toASCII,\n 'toUnicode': toUnicode\n };\n /** Expose `punycode` */\n // Some AMD build optimizers, like r.js, check for specific condition patterns\n // like the following:\n\n if (typeof define == 'function' && _typeof(define.amd) == 'object' && define.amd) {\n define('punycode', function () {\n return punycode;\n });\n } else if (freeExports && freeModule) {\n if (module.exports == freeExports) {\n // in Node.js, io.js, or RingoJS v0.8.0+\n freeModule.exports = punycode;\n } else {\n // in Narwhal or RingoJS v0.7.0-\n for (key in punycode) {\n punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);\n }\n }\n } else {\n // in Rhino or a web browser\n root.punycode = punycode;\n }\n})(this);" + "source": "/*! https://mths.be/punycode v1.4.1 by @mathias */\n;\n\n(function (root) {\n /** Detect free variables */\n var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n var freeModule = typeof module == 'object' && module && !module.nodeType && module;\n var freeGlobal = typeof global == 'object' && global;\n\n if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {\n root = freeGlobal;\n }\n /**\n * The `punycode` object.\n * @name punycode\n * @type Object\n */\n\n\n var punycode,\n\n /** Highest positive signed 32-bit float value */\n maxInt = 2147483647,\n // aka. 0x7FFFFFFF or 2^31-1\n\n /** Bootstring parameters */\n base = 36,\n tMin = 1,\n tMax = 26,\n skew = 38,\n damp = 700,\n initialBias = 72,\n initialN = 128,\n // 0x80\n delimiter = '-',\n // '\\x2D'\n\n /** Regular expressions */\n regexPunycode = /^xn--/,\n regexNonASCII = /[^\\x20-\\x7E]/,\n // unprintable ASCII chars + non-ASCII chars\n regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g,\n // RFC 3490 separators\n\n /** Error messages */\n errors = {\n 'overflow': 'Overflow: input needs wider integers to process',\n 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',\n 'invalid-input': 'Invalid input'\n },\n\n /** Convenience shortcuts */\n baseMinusTMin = base - tMin,\n floor = Math.floor,\n stringFromCharCode = String.fromCharCode,\n\n /** Temporary variable */\n key;\n /*--------------------------------------------------------------------------*/\n\n /**\n * A generic error utility function.\n * @private\n * @param {String} type The error type.\n * @returns {Error} Throws a `RangeError` with the applicable error message.\n */\n\n function error(type) {\n throw new RangeError(errors[type]);\n }\n /**\n * A generic `Array#map` utility function.\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} callback The function that gets called for every array\n * item.\n * @returns {Array} A new array of values returned by the callback function.\n */\n\n\n function map(array, fn) {\n var length = array.length;\n var result = [];\n\n while (length--) {\n result[length] = fn(array[length]);\n }\n\n return result;\n }\n /**\n * A simple `Array#map`-like wrapper to work with domain name strings or email\n * addresses.\n * @private\n * @param {String} domain The domain name or email address.\n * @param {Function} callback The function that gets called for every\n * character.\n * @returns {Array} A new string of characters returned by the callback\n * function.\n */\n\n\n function mapDomain(string, fn) {\n var parts = string.split('@');\n var result = '';\n\n if (parts.length > 1) {\n // In email addresses, only the domain name should be punycoded. Leave\n // the local part (i.e. everything up to `@`) intact.\n result = parts[0] + '@';\n string = parts[1];\n } // Avoid `split(regex)` for IE8 compatibility. See #17.\n\n\n string = string.replace(regexSeparators, '\\x2E');\n var labels = string.split('.');\n var encoded = map(labels, fn).join('.');\n return result + encoded;\n }\n /**\n * Creates an array containing the numeric code points of each Unicode\n * character in the string. While JavaScript uses UCS-2 internally,\n * this function will convert a pair of surrogate halves (each of which\n * UCS-2 exposes as separate characters) into a single code point,\n * matching UTF-16.\n * @see `punycode.ucs2.encode`\n * @see \n * @memberOf punycode.ucs2\n * @name decode\n * @param {String} string The Unicode input string (UCS-2).\n * @returns {Array} The new array of code points.\n */\n\n\n function ucs2decode(string) {\n var output = [],\n counter = 0,\n length = string.length,\n value,\n extra;\n\n while (counter < length) {\n value = string.charCodeAt(counter++);\n\n if (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n // high surrogate, and there is a next character\n extra = string.charCodeAt(counter++);\n\n if ((extra & 0xFC00) == 0xDC00) {\n // low surrogate\n output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n } else {\n // unmatched surrogate; only append this code unit, in case the next\n // code unit is the high surrogate of a surrogate pair\n output.push(value);\n counter--;\n }\n } else {\n output.push(value);\n }\n }\n\n return output;\n }\n /**\n * Creates a string based on an array of numeric code points.\n * @see `punycode.ucs2.decode`\n * @memberOf punycode.ucs2\n * @name encode\n * @param {Array} codePoints The array of numeric code points.\n * @returns {String} The new Unicode string (UCS-2).\n */\n\n\n function ucs2encode(array) {\n return map(array, function (value) {\n var output = '';\n\n if (value > 0xFFFF) {\n value -= 0x10000;\n output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);\n value = 0xDC00 | value & 0x3FF;\n }\n\n output += stringFromCharCode(value);\n return output;\n }).join('');\n }\n /**\n * Converts a basic code point into a digit/integer.\n * @see `digitToBasic()`\n * @private\n * @param {Number} codePoint The basic numeric code point value.\n * @returns {Number} The numeric value of a basic code point (for use in\n * representing integers) in the range `0` to `base - 1`, or `base` if\n * the code point does not represent a value.\n */\n\n\n function basicToDigit(codePoint) {\n if (codePoint - 48 < 10) {\n return codePoint - 22;\n }\n\n if (codePoint - 65 < 26) {\n return codePoint - 65;\n }\n\n if (codePoint - 97 < 26) {\n return codePoint - 97;\n }\n\n return base;\n }\n /**\n * Converts a digit/integer into a basic code point.\n * @see `basicToDigit()`\n * @private\n * @param {Number} digit The numeric value of a basic code point.\n * @returns {Number} The basic code point whose value (when used for\n * representing integers) is `digit`, which needs to be in the range\n * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is\n * used; else, the lowercase form is used. The behavior is undefined\n * if `flag` is non-zero and `digit` has no uppercase form.\n */\n\n\n function digitToBasic(digit, flag) {\n // 0..25 map to ASCII a..z or A..Z\n // 26..35 map to ASCII 0..9\n return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);\n }\n /**\n * Bias adaptation function as per section 3.4 of RFC 3492.\n * https://tools.ietf.org/html/rfc3492#section-3.4\n * @private\n */\n\n\n function adapt(delta, numPoints, firstTime) {\n var k = 0;\n delta = firstTime ? floor(delta / damp) : delta >> 1;\n delta += floor(delta / numPoints);\n\n for (;\n /* no initialization */\n delta > baseMinusTMin * tMax >> 1; k += base) {\n delta = floor(delta / baseMinusTMin);\n }\n\n return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n }\n /**\n * Converts a Punycode string of ASCII-only symbols to a string of Unicode\n * symbols.\n * @memberOf punycode\n * @param {String} input The Punycode string of ASCII-only symbols.\n * @returns {String} The resulting string of Unicode symbols.\n */\n\n\n function decode(input) {\n // Don't use UCS-2\n var output = [],\n inputLength = input.length,\n out,\n i = 0,\n n = initialN,\n bias = initialBias,\n basic,\n j,\n index,\n oldi,\n w,\n k,\n digit,\n t,\n\n /** Cached calculation results */\n baseMinusT; // Handle the basic code points: let `basic` be the number of input code\n // points before the last delimiter, or `0` if there is none, then copy\n // the first basic code points to the output.\n\n basic = input.lastIndexOf(delimiter);\n\n if (basic < 0) {\n basic = 0;\n }\n\n for (j = 0; j < basic; ++j) {\n // if it's not a basic code point\n if (input.charCodeAt(j) >= 0x80) {\n error('not-basic');\n }\n\n output.push(input.charCodeAt(j));\n } // Main decoding loop: start just after the last delimiter if any basic code\n // points were copied; start at the beginning otherwise.\n\n\n for (index = basic > 0 ? basic + 1 : 0; index < inputLength;)\n /* no final expression */\n {\n // `index` is the index of the next character to be consumed.\n // Decode a generalized variable-length integer into `delta`,\n // which gets added to `i`. The overflow checking is easier\n // if we increase `i` as we go, then subtract off its starting\n // value at the end to obtain `delta`.\n for (oldi = i, w = 1, k = base;;\n /* no condition */\n k += base) {\n if (index >= inputLength) {\n error('invalid-input');\n }\n\n digit = basicToDigit(input.charCodeAt(index++));\n\n if (digit >= base || digit > floor((maxInt - i) / w)) {\n error('overflow');\n }\n\n i += digit * w;\n t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n\n if (digit < t) {\n break;\n }\n\n baseMinusT = base - t;\n\n if (w > floor(maxInt / baseMinusT)) {\n error('overflow');\n }\n\n w *= baseMinusT;\n }\n\n out = output.length + 1;\n bias = adapt(i - oldi, out, oldi == 0); // `i` was supposed to wrap around from `out` to `0`,\n // incrementing `n` each time, so we'll fix that now:\n\n if (floor(i / out) > maxInt - n) {\n error('overflow');\n }\n\n n += floor(i / out);\n i %= out; // Insert `n` at position `i` of the output\n\n output.splice(i++, 0, n);\n }\n\n return ucs2encode(output);\n }\n /**\n * Converts a string of Unicode symbols (e.g. a domain name label) to a\n * Punycode string of ASCII-only symbols.\n * @memberOf punycode\n * @param {String} input The string of Unicode symbols.\n * @returns {String} The resulting Punycode string of ASCII-only symbols.\n */\n\n\n function encode(input) {\n var n,\n delta,\n handledCPCount,\n basicLength,\n bias,\n j,\n m,\n q,\n k,\n t,\n currentValue,\n output = [],\n\n /** `inputLength` will hold the number of code points in `input`. */\n inputLength,\n\n /** Cached calculation results */\n handledCPCountPlusOne,\n baseMinusT,\n qMinusT; // Convert the input in UCS-2 to Unicode\n\n input = ucs2decode(input); // Cache the length\n\n inputLength = input.length; // Initialize the state\n\n n = initialN;\n delta = 0;\n bias = initialBias; // Handle the basic code points\n\n for (j = 0; j < inputLength; ++j) {\n currentValue = input[j];\n\n if (currentValue < 0x80) {\n output.push(stringFromCharCode(currentValue));\n }\n }\n\n handledCPCount = basicLength = output.length; // `handledCPCount` is the number of code points that have been handled;\n // `basicLength` is the number of basic code points.\n // Finish the basic string - if it is not empty - with a delimiter\n\n if (basicLength) {\n output.push(delimiter);\n } // Main encoding loop:\n\n\n while (handledCPCount < inputLength) {\n // All non-basic code points < n have been handled already. Find the next\n // larger one:\n for (m = maxInt, j = 0; j < inputLength; ++j) {\n currentValue = input[j];\n\n if (currentValue >= n && currentValue < m) {\n m = currentValue;\n }\n } // Increase `delta` enough to advance the decoder's state to ,\n // but guard against overflow\n\n\n handledCPCountPlusOne = handledCPCount + 1;\n\n if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n error('overflow');\n }\n\n delta += (m - n) * handledCPCountPlusOne;\n n = m;\n\n for (j = 0; j < inputLength; ++j) {\n currentValue = input[j];\n\n if (currentValue < n && ++delta > maxInt) {\n error('overflow');\n }\n\n if (currentValue == n) {\n // Represent delta as a generalized variable-length integer\n for (q = delta, k = base;;\n /* no condition */\n k += base) {\n t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n\n if (q < t) {\n break;\n }\n\n qMinusT = q - t;\n baseMinusT = base - t;\n output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));\n q = floor(qMinusT / baseMinusT);\n }\n\n output.push(stringFromCharCode(digitToBasic(q, 0)));\n bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);\n delta = 0;\n ++handledCPCount;\n }\n }\n\n ++delta;\n ++n;\n }\n\n return output.join('');\n }\n /**\n * Converts a Punycode string representing a domain name or an email address\n * to Unicode. Only the Punycoded parts of the input will be converted, i.e.\n * it doesn't matter if you call it on a string that has already been\n * converted to Unicode.\n * @memberOf punycode\n * @param {String} input The Punycoded domain name or email address to\n * convert to Unicode.\n * @returns {String} The Unicode representation of the given Punycode\n * string.\n */\n\n\n function toUnicode(input) {\n return mapDomain(input, function (string) {\n return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;\n });\n }\n /**\n * Converts a Unicode string representing a domain name or an email address to\n * Punycode. Only the non-ASCII parts of the domain name will be converted,\n * i.e. it doesn't matter if you call it with a domain that's already in\n * ASCII.\n * @memberOf punycode\n * @param {String} input The domain name or email address to convert, as a\n * Unicode string.\n * @returns {String} The Punycode representation of the given domain name or\n * email address.\n */\n\n\n function toASCII(input) {\n return mapDomain(input, function (string) {\n return regexNonASCII.test(string) ? 'xn--' + encode(string) : string;\n });\n }\n /*--------------------------------------------------------------------------*/\n\n /** Define the public API */\n\n\n punycode = {\n /**\n * A string representing the current Punycode.js version number.\n * @memberOf punycode\n * @type String\n */\n 'version': '1.4.1',\n\n /**\n * An object of methods to convert from JavaScript's internal character\n * representation (UCS-2) to Unicode code points, and back.\n * @see \n * @memberOf punycode\n * @type Object\n */\n 'ucs2': {\n 'decode': ucs2decode,\n 'encode': ucs2encode\n },\n 'decode': decode,\n 'encode': encode,\n 'toASCII': toASCII,\n 'toUnicode': toUnicode\n };\n /** Expose `punycode` */\n // Some AMD build optimizers, like r.js, check for specific condition patterns\n // like the following:\n\n if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {\n define('punycode', function () {\n return punycode;\n });\n } else if (freeExports && freeModule) {\n if (module.exports == freeExports) {\n // in Node.js, io.js, or RingoJS v0.8.0+\n freeModule.exports = punycode;\n } else {\n // in Narwhal or RingoJS v0.7.0-\n for (key in punycode) {\n punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);\n }\n }\n } else {\n // in Rhino or a web browser\n root.punycode = punycode;\n }\n})(this);" }, { - "id": 46, + "id": 45, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/webpack/buildin/module.js", "name": "(webpack)/buildin/module.js", "index": 43, @@ -8549,7 +8363,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "issuerId": 45, + "issuerId": 44, "issuerName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "issuerPath": [ { @@ -8557,43 +8371,43 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 44, + "id": 43, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "name": "../node_modules/@hapi/address/lib/index.js", "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 } }, { - "id": 45, + "id": 44, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", "name": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "profile": { - "factory": 4, - "building": 95 + "factory": 3, + "building": 94 } } ], "profile": { - "factory": 56, - "building": 8 + "factory": 55, + "building": 5 }, "failed": false, "errors": 0, @@ -8601,7 +8415,7 @@ "assets": [], "reasons": [ { - "moduleId": 45, + "moduleId": 44, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", "module": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "moduleName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", @@ -8619,12 +8433,12 @@ "source": "module.exports = function (module) {\n if (!module.webpackPolyfill) {\n module.deprecate = function () {};\n\n module.paths = []; // module.parent = undefined by default\n\n if (!module.children) module.children = [];\n Object.defineProperty(module, \"loaded\", {\n enumerable: true,\n get: function get() {\n return module.l;\n }\n });\n Object.defineProperty(module, \"id\", {\n enumerable: true,\n get: function get() {\n return module.i;\n }\n });\n module.webpackPolyfill = 1;\n }\n\n return module;\n};" }, { - "id": 47, + "id": 46, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/webpack/buildin/global.js", "name": "(webpack)/buildin/global.js", "index": 44, "index2": 40, - "size": 878, + "size": 475, "cacheable": true, "built": true, "optional": false, @@ -8633,7 +8447,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", - "issuerId": 45, + "issuerId": 44, "issuerName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "issuerPath": [ { @@ -8641,43 +8455,43 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 44, + "id": 43, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "name": "../node_modules/@hapi/address/lib/index.js", "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 } }, { - "id": 45, + "id": 44, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", "name": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "profile": { - "factory": 4, - "building": 95 + "factory": 3, + "building": 94 } } ], "profile": { - "factory": 56, - "building": 8 + "factory": 55, + "building": 5 }, "failed": false, "errors": 0, @@ -8685,7 +8499,7 @@ "assets": [], "reasons": [ { - "moduleId": 45, + "moduleId": 44, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/browser/node_modules/node-libs-browser/node_modules/punycode/punycode.js", "module": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", "moduleName": "./node_modules/node-libs-browser/node_modules/punycode/punycode.js", @@ -8700,15 +8514,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 4, - "source": "function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar g; // This works in non-strict mode\n\ng = function () {\n return this;\n}();\n\ntry {\n // This works if eval is allowed (see CSP)\n g = g || new Function(\"return this\")();\n} catch (e) {\n // This works if the window reference is available\n if ((typeof window === \"undefined\" ? \"undefined\" : _typeof(window)) === \"object\") g = window;\n} // g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\n\nmodule.exports = g;" + "source": "var g; // This works in non-strict mode\n\ng = function () {\n return this;\n}();\n\ntry {\n // This works if eval is allowed (see CSP)\n g = g || new Function(\"return this\")();\n} catch (e) {\n // This works if the window reference is available\n if (typeof window === \"object\") g = window;\n} // g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\n\nmodule.exports = g;" }, { - "id": 48, + "id": 47, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/abnf.js", "name": "../node_modules/@hapi/address/lib/abnf.js", - "index": 46, - "index2": 43, - "size": 2297, + "index": 45, + "index2": 42, + "size": 2299, "cacheable": true, "built": true, "optional": false, @@ -8717,7 +8531,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", - "issuerId": 44, + "issuerId": 43, "issuerName": "../node_modules/@hapi/address/lib/index.js", "issuerPath": [ { @@ -8725,34 +8539,34 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 44, + "id": 43, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "name": "../node_modules/@hapi/address/lib/index.js", "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 } } ], "profile": { - "factory": 4, - "building": 95 + "factory": 3, + "building": 94 }, "failed": false, "errors": 0, @@ -8760,13 +8574,13 @@ "assets": [], "reasons": [ { - "moduleId": 44, + "moduleId": 43, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "module": "../node_modules/@hapi/address/lib/index.js", "moduleName": "../node_modules/@hapi/address/lib/index.js", "type": "cjs require", "userRequest": "./abnf", - "loc": "7:11-28" + "loc": "5:13-30" } ], "usedExports": true, @@ -8775,15 +8589,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nvar internals = {};\n/*\r\n From RFC 5321:\r\n\r\n Mailbox = Local-part \"@\" ( Domain / address-literal )\r\n\r\n Local-part = Dot-string / Quoted-string\r\n Dot-string = Atom *(\".\" Atom)\r\n Atom = 1*atext\r\n atext = ALPHA / DIGIT / \"!\" / \"#\" / \"$\" / \"%\" / \"&\" / \"'\" / \"*\" / \"+\" / \"-\" / \"/\" / \"=\" / \"?\" / \"^\" / \"_\" / \"`\" / \"{\" / \"|\" / \"}\" / \"~\"\r\n\r\n Domain = sub-domain *(\".\" sub-domain)\r\n sub-domain = Let-dig [Ldh-str]\r\n Let-dig = ALPHA / DIGIT\r\n Ldh-str = *( ALPHA / DIGIT / \"-\" ) Let-dig\r\n\r\n ALPHA = %x41-5A / %x61-7A ; a-z, A-Z\r\n DIGIT = %x30-39 ; 0-9\r\n\r\n From RFC 6531:\r\n\r\n sub-domain =/ U-label\r\n atext =/ UTF8-non-ascii\r\n\r\n UTF8-non-ascii = UTF8-2 / UTF8-3 / UTF8-4\r\n\r\n UTF8-2 = %xC2-DF UTF8-tail\r\n UTF8-3 = %xE0 %xA0-BF UTF8-tail /\r\n %xE1-EC 2( UTF8-tail ) /\r\n %xED %x80-9F UTF8-tail /\r\n %xEE-EF 2( UTF8-tail )\r\n UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) /\r\n %xF1-F3 3( UTF8-tail ) /\r\n %xF4 %x80-8F 2( UTF8-tail )\r\n\r\n UTF8-tail = %x80-BF\r\n\r\n Note: The following are not supported:\r\n\r\n RFC 5321: address-literal, Quoted-string\r\n RFC 5322: obs-*, CFWS\r\n*/\n\ninternals.atext = '[\\\\w!#\\\\$%&\\'\\\\*\\\\+\\\\-/=\\\\?\\\\^`\\\\{\\\\|\\\\}~]'; // _ included in \\w\n\nexports.atextRx = new RegExp(\"^\".concat(internals.atext, \"+$\"));\nexports.atomRx = new RegExp([internals.atext, // %xC2-DF UTF8-tail\n'(?:[\\\\xc2-\\\\xdf][\\\\x80-\\\\xbf])', // %xE0 %xA0-BF UTF8-tail %xE1-EC 2( UTF8-tail ) %xED %x80-9F UTF8-tail %xEE-EF 2( UTF8-tail )\n'(?:\\\\xe0[\\\\xa0-\\\\xbf][\\\\x80-\\\\xbf])|(?:[\\\\xe1-\\\\xec][\\\\x80-\\\\xbf]{2})|(?:\\\\xed[\\\\x80-\\\\x9f][\\\\x80-\\\\xbf])|(?:[\\\\xee-\\\\xef][\\\\x80-\\\\xbf]{2})', // %xF0 %x90-BF 2( UTF8-tail ) %xF1-F3 3( UTF8-tail ) %xF4 %x80-8F 2( UTF8-tail )\n'(?:\\\\xf0[\\\\x90-\\\\xbf][\\\\x80-\\\\xbf]{2})|(?:[\\\\xf1-\\\\xf3][\\\\x80-\\\\xbf]{3})|(?:\\\\xf4[\\\\x80-\\\\x8f][\\\\x80-\\\\xbf]{2})'].join('|'));" + "source": "'use strict';\n\nconst internals = {};\n/*\r\n From RFC 5321:\r\n\r\n Mailbox = Local-part \"@\" ( Domain / address-literal )\r\n\r\n Local-part = Dot-string / Quoted-string\r\n Dot-string = Atom *(\".\" Atom)\r\n Atom = 1*atext\r\n atext = ALPHA / DIGIT / \"!\" / \"#\" / \"$\" / \"%\" / \"&\" / \"'\" / \"*\" / \"+\" / \"-\" / \"/\" / \"=\" / \"?\" / \"^\" / \"_\" / \"`\" / \"{\" / \"|\" / \"}\" / \"~\"\r\n\r\n Domain = sub-domain *(\".\" sub-domain)\r\n sub-domain = Let-dig [Ldh-str]\r\n Let-dig = ALPHA / DIGIT\r\n Ldh-str = *( ALPHA / DIGIT / \"-\" ) Let-dig\r\n\r\n ALPHA = %x41-5A / %x61-7A ; a-z, A-Z\r\n DIGIT = %x30-39 ; 0-9\r\n\r\n From RFC 6531:\r\n\r\n sub-domain =/ U-label\r\n atext =/ UTF8-non-ascii\r\n\r\n UTF8-non-ascii = UTF8-2 / UTF8-3 / UTF8-4\r\n\r\n UTF8-2 = %xC2-DF UTF8-tail\r\n UTF8-3 = %xE0 %xA0-BF UTF8-tail /\r\n %xE1-EC 2( UTF8-tail ) /\r\n %xED %x80-9F UTF8-tail /\r\n %xEE-EF 2( UTF8-tail )\r\n UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) /\r\n %xF1-F3 3( UTF8-tail ) /\r\n %xF4 %x80-8F 2( UTF8-tail )\r\n\r\n UTF8-tail = %x80-BF\r\n\r\n Note: The following are not supported:\r\n\r\n RFC 5321: address-literal, Quoted-string\r\n RFC 5322: obs-*, CFWS\r\n*/\n\ninternals.atext = '[\\\\w!#\\\\$%&\\'\\\\*\\\\+\\\\-/=\\\\?\\\\^`\\\\{\\\\|\\\\}~]'; // _ included in \\w\n\nexports.atextRx = new RegExp(\"^\".concat(internals.atext, \"+$\"));\nexports.atomRx = new RegExp([internals.atext, // %xC2-DF UTF8-tail\n'(?:[\\\\xc2-\\\\xdf][\\\\x80-\\\\xbf])', // %xE0 %xA0-BF UTF8-tail %xE1-EC 2( UTF8-tail ) %xED %x80-9F UTF8-tail %xEE-EF 2( UTF8-tail )\n'(?:\\\\xe0[\\\\xa0-\\\\xbf][\\\\x80-\\\\xbf])|(?:[\\\\xe1-\\\\xec][\\\\x80-\\\\xbf]{2})|(?:\\\\xed[\\\\x80-\\\\x9f][\\\\x80-\\\\xbf])|(?:[\\\\xee-\\\\xef][\\\\x80-\\\\xbf]{2})', // %xF0 %x90-BF 2( UTF8-tail ) %xF1-F3 3( UTF8-tail ) %xF4 %x80-8F 2( UTF8-tail )\n'(?:\\\\xf0[\\\\x90-\\\\xbf][\\\\x80-\\\\xbf]{2})|(?:[\\\\xf1-\\\\xf3][\\\\x80-\\\\xbf]{3})|(?:\\\\xf4[\\\\x80-\\\\x8f][\\\\x80-\\\\xbf]{2})'].join('|'));" }, { - "id": 49, + "id": 48, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/tlds.js", "name": "../node_modules/@hapi/address/lib/tlds.js", - "index": 47, - "index2": 44, - "size": 15195, + "index": 46, + "index2": 43, + "size": 15175, "cacheable": true, "built": true, "optional": false, @@ -8792,7 +8606,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", - "issuerId": 44, + "issuerId": 43, "issuerName": "../node_modules/@hapi/address/lib/index.js", "issuerPath": [ { @@ -8800,34 +8614,34 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } }, { - "id": 44, + "id": 43, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "name": "../node_modules/@hapi/address/lib/index.js", "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 } } ], "profile": { - "factory": 4, - "building": 95 + "factory": 3, + "building": 94 }, "failed": false, "errors": 0, @@ -8835,13 +8649,13 @@ "assets": [], "reasons": [ { - "moduleId": 44, + "moduleId": 43, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/address/lib/index.js", "module": "../node_modules/@hapi/address/lib/index.js", "moduleName": "../node_modules/@hapi/address/lib/index.js", "type": "cjs require", "userRequest": "./tlds", - "loc": "9:11-28" + "loc": "7:13-30" } ], "usedExports": true, @@ -8850,15 +8664,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 3, - "source": "'use strict';\n\nvar internals = {}; // http://data.iana.org/TLD/tlds-alpha-by-domain.txt\n// # Version 2019032300, Last Updated Sat Mar 23 07:07:02 2019 UTC\n\ninternals.tlds = ['AAA', 'AARP', 'ABARTH', 'ABB', 'ABBOTT', 'ABBVIE', 'ABC', 'ABLE', 'ABOGADO', 'ABUDHABI', 'AC', 'ACADEMY', 'ACCENTURE', 'ACCOUNTANT', 'ACCOUNTANTS', 'ACO', 'ACTOR', 'AD', 'ADAC', 'ADS', 'ADULT', 'AE', 'AEG', 'AERO', 'AETNA', 'AF', 'AFAMILYCOMPANY', 'AFL', 'AFRICA', 'AG', 'AGAKHAN', 'AGENCY', 'AI', 'AIG', 'AIGO', 'AIRBUS', 'AIRFORCE', 'AIRTEL', 'AKDN', 'AL', 'ALFAROMEO', 'ALIBABA', 'ALIPAY', 'ALLFINANZ', 'ALLSTATE', 'ALLY', 'ALSACE', 'ALSTOM', 'AM', 'AMERICANEXPRESS', 'AMERICANFAMILY', 'AMEX', 'AMFAM', 'AMICA', 'AMSTERDAM', 'ANALYTICS', 'ANDROID', 'ANQUAN', 'ANZ', 'AO', 'AOL', 'APARTMENTS', 'APP', 'APPLE', 'AQ', 'AQUARELLE', 'AR', 'ARAB', 'ARAMCO', 'ARCHI', 'ARMY', 'ARPA', 'ART', 'ARTE', 'AS', 'ASDA', 'ASIA', 'ASSOCIATES', 'AT', 'ATHLETA', 'ATTORNEY', 'AU', 'AUCTION', 'AUDI', 'AUDIBLE', 'AUDIO', 'AUSPOST', 'AUTHOR', 'AUTO', 'AUTOS', 'AVIANCA', 'AW', 'AWS', 'AX', 'AXA', 'AZ', 'AZURE', 'BA', 'BABY', 'BAIDU', 'BANAMEX', 'BANANAREPUBLIC', 'BAND', 'BANK', 'BAR', 'BARCELONA', 'BARCLAYCARD', 'BARCLAYS', 'BAREFOOT', 'BARGAINS', 'BASEBALL', 'BASKETBALL', 'BAUHAUS', 'BAYERN', 'BB', 'BBC', 'BBT', 'BBVA', 'BCG', 'BCN', 'BD', 'BE', 'BEATS', 'BEAUTY', 'BEER', 'BENTLEY', 'BERLIN', 'BEST', 'BESTBUY', 'BET', 'BF', 'BG', 'BH', 'BHARTI', 'BI', 'BIBLE', 'BID', 'BIKE', 'BING', 'BINGO', 'BIO', 'BIZ', 'BJ', 'BLACK', 'BLACKFRIDAY', 'BLOCKBUSTER', 'BLOG', 'BLOOMBERG', 'BLUE', 'BM', 'BMS', 'BMW', 'BN', 'BNL', 'BNPPARIBAS', 'BO', 'BOATS', 'BOEHRINGER', 'BOFA', 'BOM', 'BOND', 'BOO', 'BOOK', 'BOOKING', 'BOSCH', 'BOSTIK', 'BOSTON', 'BOT', 'BOUTIQUE', 'BOX', 'BR', 'BRADESCO', 'BRIDGESTONE', 'BROADWAY', 'BROKER', 'BROTHER', 'BRUSSELS', 'BS', 'BT', 'BUDAPEST', 'BUGATTI', 'BUILD', 'BUILDERS', 'BUSINESS', 'BUY', 'BUZZ', 'BV', 'BW', 'BY', 'BZ', 'BZH', 'CA', 'CAB', 'CAFE', 'CAL', 'CALL', 'CALVINKLEIN', 'CAM', 'CAMERA', 'CAMP', 'CANCERRESEARCH', 'CANON', 'CAPETOWN', 'CAPITAL', 'CAPITALONE', 'CAR', 'CARAVAN', 'CARDS', 'CARE', 'CAREER', 'CAREERS', 'CARS', 'CARTIER', 'CASA', 'CASE', 'CASEIH', 'CASH', 'CASINO', 'CAT', 'CATERING', 'CATHOLIC', 'CBA', 'CBN', 'CBRE', 'CBS', 'CC', 'CD', 'CEB', 'CENTER', 'CEO', 'CERN', 'CF', 'CFA', 'CFD', 'CG', 'CH', 'CHANEL', 'CHANNEL', 'CHARITY', 'CHASE', 'CHAT', 'CHEAP', 'CHINTAI', 'CHRISTMAS', 'CHROME', 'CHRYSLER', 'CHURCH', 'CI', 'CIPRIANI', 'CIRCLE', 'CISCO', 'CITADEL', 'CITI', 'CITIC', 'CITY', 'CITYEATS', 'CK', 'CL', 'CLAIMS', 'CLEANING', 'CLICK', 'CLINIC', 'CLINIQUE', 'CLOTHING', 'CLOUD', 'CLUB', 'CLUBMED', 'CM', 'CN', 'CO', 'COACH', 'CODES', 'COFFEE', 'COLLEGE', 'COLOGNE', 'COM', 'COMCAST', 'COMMBANK', 'COMMUNITY', 'COMPANY', 'COMPARE', 'COMPUTER', 'COMSEC', 'CONDOS', 'CONSTRUCTION', 'CONSULTING', 'CONTACT', 'CONTRACTORS', 'COOKING', 'COOKINGCHANNEL', 'COOL', 'COOP', 'CORSICA', 'COUNTRY', 'COUPON', 'COUPONS', 'COURSES', 'CR', 'CREDIT', 'CREDITCARD', 'CREDITUNION', 'CRICKET', 'CROWN', 'CRS', 'CRUISE', 'CRUISES', 'CSC', 'CU', 'CUISINELLA', 'CV', 'CW', 'CX', 'CY', 'CYMRU', 'CYOU', 'CZ', 'DABUR', 'DAD', 'DANCE', 'DATA', 'DATE', 'DATING', 'DATSUN', 'DAY', 'DCLK', 'DDS', 'DE', 'DEAL', 'DEALER', 'DEALS', 'DEGREE', 'DELIVERY', 'DELL', 'DELOITTE', 'DELTA', 'DEMOCRAT', 'DENTAL', 'DENTIST', 'DESI', 'DESIGN', 'DEV', 'DHL', 'DIAMONDS', 'DIET', 'DIGITAL', 'DIRECT', 'DIRECTORY', 'DISCOUNT', 'DISCOVER', 'DISH', 'DIY', 'DJ', 'DK', 'DM', 'DNP', 'DO', 'DOCS', 'DOCTOR', 'DODGE', 'DOG', 'DOHA', 'DOMAINS', 'DOT', 'DOWNLOAD', 'DRIVE', 'DTV', 'DUBAI', 'DUCK', 'DUNLOP', 'DUNS', 'DUPONT', 'DURBAN', 'DVAG', 'DVR', 'DZ', 'EARTH', 'EAT', 'EC', 'ECO', 'EDEKA', 'EDU', 'EDUCATION', 'EE', 'EG', 'EMAIL', 'EMERCK', 'ENERGY', 'ENGINEER', 'ENGINEERING', 'ENTERPRISES', 'EPSON', 'EQUIPMENT', 'ER', 'ERICSSON', 'ERNI', 'ES', 'ESQ', 'ESTATE', 'ESURANCE', 'ET', 'ETISALAT', 'EU', 'EUROVISION', 'EUS', 'EVENTS', 'EVERBANK', 'EXCHANGE', 'EXPERT', 'EXPOSED', 'EXPRESS', 'EXTRASPACE', 'FAGE', 'FAIL', 'FAIRWINDS', 'FAITH', 'FAMILY', 'FAN', 'FANS', 'FARM', 'FARMERS', 'FASHION', 'FAST', 'FEDEX', 'FEEDBACK', 'FERRARI', 'FERRERO', 'FI', 'FIAT', 'FIDELITY', 'FIDO', 'FILM', 'FINAL', 'FINANCE', 'FINANCIAL', 'FIRE', 'FIRESTONE', 'FIRMDALE', 'FISH', 'FISHING', 'FIT', 'FITNESS', 'FJ', 'FK', 'FLICKR', 'FLIGHTS', 'FLIR', 'FLORIST', 'FLOWERS', 'FLY', 'FM', 'FO', 'FOO', 'FOOD', 'FOODNETWORK', 'FOOTBALL', 'FORD', 'FOREX', 'FORSALE', 'FORUM', 'FOUNDATION', 'FOX', 'FR', 'FREE', 'FRESENIUS', 'FRL', 'FROGANS', 'FRONTDOOR', 'FRONTIER', 'FTR', 'FUJITSU', 'FUJIXEROX', 'FUN', 'FUND', 'FURNITURE', 'FUTBOL', 'FYI', 'GA', 'GAL', 'GALLERY', 'GALLO', 'GALLUP', 'GAME', 'GAMES', 'GAP', 'GARDEN', 'GB', 'GBIZ', 'GD', 'GDN', 'GE', 'GEA', 'GENT', 'GENTING', 'GEORGE', 'GF', 'GG', 'GGEE', 'GH', 'GI', 'GIFT', 'GIFTS', 'GIVES', 'GIVING', 'GL', 'GLADE', 'GLASS', 'GLE', 'GLOBAL', 'GLOBO', 'GM', 'GMAIL', 'GMBH', 'GMO', 'GMX', 'GN', 'GODADDY', 'GOLD', 'GOLDPOINT', 'GOLF', 'GOO', 'GOODYEAR', 'GOOG', 'GOOGLE', 'GOP', 'GOT', 'GOV', 'GP', 'GQ', 'GR', 'GRAINGER', 'GRAPHICS', 'GRATIS', 'GREEN', 'GRIPE', 'GROCERY', 'GROUP', 'GS', 'GT', 'GU', 'GUARDIAN', 'GUCCI', 'GUGE', 'GUIDE', 'GUITARS', 'GURU', 'GW', 'GY', 'HAIR', 'HAMBURG', 'HANGOUT', 'HAUS', 'HBO', 'HDFC', 'HDFCBANK', 'HEALTH', 'HEALTHCARE', 'HELP', 'HELSINKI', 'HERE', 'HERMES', 'HGTV', 'HIPHOP', 'HISAMITSU', 'HITACHI', 'HIV', 'HK', 'HKT', 'HM', 'HN', 'HOCKEY', 'HOLDINGS', 'HOLIDAY', 'HOMEDEPOT', 'HOMEGOODS', 'HOMES', 'HOMESENSE', 'HONDA', 'HONEYWELL', 'HORSE', 'HOSPITAL', 'HOST', 'HOSTING', 'HOT', 'HOTELES', 'HOTELS', 'HOTMAIL', 'HOUSE', 'HOW', 'HR', 'HSBC', 'HT', 'HU', 'HUGHES', 'HYATT', 'HYUNDAI', 'IBM', 'ICBC', 'ICE', 'ICU', 'ID', 'IE', 'IEEE', 'IFM', 'IKANO', 'IL', 'IM', 'IMAMAT', 'IMDB', 'IMMO', 'IMMOBILIEN', 'IN', 'INC', 'INDUSTRIES', 'INFINITI', 'INFO', 'ING', 'INK', 'INSTITUTE', 'INSURANCE', 'INSURE', 'INT', 'INTEL', 'INTERNATIONAL', 'INTUIT', 'INVESTMENTS', 'IO', 'IPIRANGA', 'IQ', 'IR', 'IRISH', 'IS', 'ISELECT', 'ISMAILI', 'IST', 'ISTANBUL', 'IT', 'ITAU', 'ITV', 'IVECO', 'JAGUAR', 'JAVA', 'JCB', 'JCP', 'JE', 'JEEP', 'JETZT', 'JEWELRY', 'JIO', 'JLL', 'JM', 'JMP', 'JNJ', 'JO', 'JOBS', 'JOBURG', 'JOT', 'JOY', 'JP', 'JPMORGAN', 'JPRS', 'JUEGOS', 'JUNIPER', 'KAUFEN', 'KDDI', 'KE', 'KERRYHOTELS', 'KERRYLOGISTICS', 'KERRYPROPERTIES', 'KFH', 'KG', 'KH', 'KI', 'KIA', 'KIM', 'KINDER', 'KINDLE', 'KITCHEN', 'KIWI', 'KM', 'KN', 'KOELN', 'KOMATSU', 'KOSHER', 'KP', 'KPMG', 'KPN', 'KR', 'KRD', 'KRED', 'KUOKGROUP', 'KW', 'KY', 'KYOTO', 'KZ', 'LA', 'LACAIXA', 'LADBROKES', 'LAMBORGHINI', 'LAMER', 'LANCASTER', 'LANCIA', 'LANCOME', 'LAND', 'LANDROVER', 'LANXESS', 'LASALLE', 'LAT', 'LATINO', 'LATROBE', 'LAW', 'LAWYER', 'LB', 'LC', 'LDS', 'LEASE', 'LECLERC', 'LEFRAK', 'LEGAL', 'LEGO', 'LEXUS', 'LGBT', 'LI', 'LIAISON', 'LIDL', 'LIFE', 'LIFEINSURANCE', 'LIFESTYLE', 'LIGHTING', 'LIKE', 'LILLY', 'LIMITED', 'LIMO', 'LINCOLN', 'LINDE', 'LINK', 'LIPSY', 'LIVE', 'LIVING', 'LIXIL', 'LK', 'LLC', 'LOAN', 'LOANS', 'LOCKER', 'LOCUS', 'LOFT', 'LOL', 'LONDON', 'LOTTE', 'LOTTO', 'LOVE', 'LPL', 'LPLFINANCIAL', 'LR', 'LS', 'LT', 'LTD', 'LTDA', 'LU', 'LUNDBECK', 'LUPIN', 'LUXE', 'LUXURY', 'LV', 'LY', 'MA', 'MACYS', 'MADRID', 'MAIF', 'MAISON', 'MAKEUP', 'MAN', 'MANAGEMENT', 'MANGO', 'MAP', 'MARKET', 'MARKETING', 'MARKETS', 'MARRIOTT', 'MARSHALLS', 'MASERATI', 'MATTEL', 'MBA', 'MC', 'MCKINSEY', 'MD', 'ME', 'MED', 'MEDIA', 'MEET', 'MELBOURNE', 'MEME', 'MEMORIAL', 'MEN', 'MENU', 'MERCKMSD', 'METLIFE', 'MG', 'MH', 'MIAMI', 'MICROSOFT', 'MIL', 'MINI', 'MINT', 'MIT', 'MITSUBISHI', 'MK', 'ML', 'MLB', 'MLS', 'MM', 'MMA', 'MN', 'MO', 'MOBI', 'MOBILE', 'MOBILY', 'MODA', 'MOE', 'MOI', 'MOM', 'MONASH', 'MONEY', 'MONSTER', 'MOPAR', 'MORMON', 'MORTGAGE', 'MOSCOW', 'MOTO', 'MOTORCYCLES', 'MOV', 'MOVIE', 'MOVISTAR', 'MP', 'MQ', 'MR', 'MS', 'MSD', 'MT', 'MTN', 'MTR', 'MU', 'MUSEUM', 'MUTUAL', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NAB', 'NADEX', 'NAGOYA', 'NAME', 'NATIONWIDE', 'NATURA', 'NAVY', 'NBA', 'NC', 'NE', 'NEC', 'NET', 'NETBANK', 'NETFLIX', 'NETWORK', 'NEUSTAR', 'NEW', 'NEWHOLLAND', 'NEWS', 'NEXT', 'NEXTDIRECT', 'NEXUS', 'NF', 'NFL', 'NG', 'NGO', 'NHK', 'NI', 'NICO', 'NIKE', 'NIKON', 'NINJA', 'NISSAN', 'NISSAY', 'NL', 'NO', 'NOKIA', 'NORTHWESTERNMUTUAL', 'NORTON', 'NOW', 'NOWRUZ', 'NOWTV', 'NP', 'NR', 'NRA', 'NRW', 'NTT', 'NU', 'NYC', 'NZ', 'OBI', 'OBSERVER', 'OFF', 'OFFICE', 'OKINAWA', 'OLAYAN', 'OLAYANGROUP', 'OLDNAVY', 'OLLO', 'OM', 'OMEGA', 'ONE', 'ONG', 'ONL', 'ONLINE', 'ONYOURSIDE', 'OOO', 'OPEN', 'ORACLE', 'ORANGE', 'ORG', 'ORGANIC', 'ORIGINS', 'OSAKA', 'OTSUKA', 'OTT', 'OVH', 'PA', 'PAGE', 'PANASONIC', 'PARIS', 'PARS', 'PARTNERS', 'PARTS', 'PARTY', 'PASSAGENS', 'PAY', 'PCCW', 'PE', 'PET', 'PF', 'PFIZER', 'PG', 'PH', 'PHARMACY', 'PHD', 'PHILIPS', 'PHONE', 'PHOTO', 'PHOTOGRAPHY', 'PHOTOS', 'PHYSIO', 'PIAGET', 'PICS', 'PICTET', 'PICTURES', 'PID', 'PIN', 'PING', 'PINK', 'PIONEER', 'PIZZA', 'PK', 'PL', 'PLACE', 'PLAY', 'PLAYSTATION', 'PLUMBING', 'PLUS', 'PM', 'PN', 'PNC', 'POHL', 'POKER', 'POLITIE', 'PORN', 'POST', 'PR', 'PRAMERICA', 'PRAXI', 'PRESS', 'PRIME', 'PRO', 'PROD', 'PRODUCTIONS', 'PROF', 'PROGRESSIVE', 'PROMO', 'PROPERTIES', 'PROPERTY', 'PROTECTION', 'PRU', 'PRUDENTIAL', 'PS', 'PT', 'PUB', 'PW', 'PWC', 'PY', 'QA', 'QPON', 'QUEBEC', 'QUEST', 'QVC', 'RACING', 'RADIO', 'RAID', 'RE', 'READ', 'REALESTATE', 'REALTOR', 'REALTY', 'RECIPES', 'RED', 'REDSTONE', 'REDUMBRELLA', 'REHAB', 'REISE', 'REISEN', 'REIT', 'RELIANCE', 'REN', 'RENT', 'RENTALS', 'REPAIR', 'REPORT', 'REPUBLICAN', 'REST', 'RESTAURANT', 'REVIEW', 'REVIEWS', 'REXROTH', 'RICH', 'RICHARDLI', 'RICOH', 'RIGHTATHOME', 'RIL', 'RIO', 'RIP', 'RMIT', 'RO', 'ROCHER', 'ROCKS', 'RODEO', 'ROGERS', 'ROOM', 'RS', 'RSVP', 'RU', 'RUGBY', 'RUHR', 'RUN', 'RW', 'RWE', 'RYUKYU', 'SA', 'SAARLAND', 'SAFE', 'SAFETY', 'SAKURA', 'SALE', 'SALON', 'SAMSCLUB', 'SAMSUNG', 'SANDVIK', 'SANDVIKCOROMANT', 'SANOFI', 'SAP', 'SARL', 'SAS', 'SAVE', 'SAXO', 'SB', 'SBI', 'SBS', 'SC', 'SCA', 'SCB', 'SCHAEFFLER', 'SCHMIDT', 'SCHOLARSHIPS', 'SCHOOL', 'SCHULE', 'SCHWARZ', 'SCIENCE', 'SCJOHNSON', 'SCOR', 'SCOT', 'SD', 'SE', 'SEARCH', 'SEAT', 'SECURE', 'SECURITY', 'SEEK', 'SELECT', 'SENER', 'SERVICES', 'SES', 'SEVEN', 'SEW', 'SEX', 'SEXY', 'SFR', 'SG', 'SH', 'SHANGRILA', 'SHARP', 'SHAW', 'SHELL', 'SHIA', 'SHIKSHA', 'SHOES', 'SHOP', 'SHOPPING', 'SHOUJI', 'SHOW', 'SHOWTIME', 'SHRIRAM', 'SI', 'SILK', 'SINA', 'SINGLES', 'SITE', 'SJ', 'SK', 'SKI', 'SKIN', 'SKY', 'SKYPE', 'SL', 'SLING', 'SM', 'SMART', 'SMILE', 'SN', 'SNCF', 'SO', 'SOCCER', 'SOCIAL', 'SOFTBANK', 'SOFTWARE', 'SOHU', 'SOLAR', 'SOLUTIONS', 'SONG', 'SONY', 'SOY', 'SPACE', 'SPORT', 'SPOT', 'SPREADBETTING', 'SR', 'SRL', 'SRT', 'SS', 'ST', 'STADA', 'STAPLES', 'STAR', 'STARHUB', 'STATEBANK', 'STATEFARM', 'STC', 'STCGROUP', 'STOCKHOLM', 'STORAGE', 'STORE', 'STREAM', 'STUDIO', 'STUDY', 'STYLE', 'SU', 'SUCKS', 'SUPPLIES', 'SUPPLY', 'SUPPORT', 'SURF', 'SURGERY', 'SUZUKI', 'SV', 'SWATCH', 'SWIFTCOVER', 'SWISS', 'SX', 'SY', 'SYDNEY', 'SYMANTEC', 'SYSTEMS', 'SZ', 'TAB', 'TAIPEI', 'TALK', 'TAOBAO', 'TARGET', 'TATAMOTORS', 'TATAR', 'TATTOO', 'TAX', 'TAXI', 'TC', 'TCI', 'TD', 'TDK', 'TEAM', 'TECH', 'TECHNOLOGY', 'TEL', 'TELEFONICA', 'TEMASEK', 'TENNIS', 'TEVA', 'TF', 'TG', 'TH', 'THD', 'THEATER', 'THEATRE', 'TIAA', 'TICKETS', 'TIENDA', 'TIFFANY', 'TIPS', 'TIRES', 'TIROL', 'TJ', 'TJMAXX', 'TJX', 'TK', 'TKMAXX', 'TL', 'TM', 'TMALL', 'TN', 'TO', 'TODAY', 'TOKYO', 'TOOLS', 'TOP', 'TORAY', 'TOSHIBA', 'TOTAL', 'TOURS', 'TOWN', 'TOYOTA', 'TOYS', 'TR', 'TRADE', 'TRADING', 'TRAINING', 'TRAVEL', 'TRAVELCHANNEL', 'TRAVELERS', 'TRAVELERSINSURANCE', 'TRUST', 'TRV', 'TT', 'TUBE', 'TUI', 'TUNES', 'TUSHU', 'TV', 'TVS', 'TW', 'TZ', 'UA', 'UBANK', 'UBS', 'UCONNECT', 'UG', 'UK', 'UNICOM', 'UNIVERSITY', 'UNO', 'UOL', 'UPS', 'US', 'UY', 'UZ', 'VA', 'VACATIONS', 'VANA', 'VANGUARD', 'VC', 'VE', 'VEGAS', 'VENTURES', 'VERISIGN', 'VERSICHERUNG', 'VET', 'VG', 'VI', 'VIAJES', 'VIDEO', 'VIG', 'VIKING', 'VILLAS', 'VIN', 'VIP', 'VIRGIN', 'VISA', 'VISION', 'VISTAPRINT', 'VIVA', 'VIVO', 'VLAANDEREN', 'VN', 'VODKA', 'VOLKSWAGEN', 'VOLVO', 'VOTE', 'VOTING', 'VOTO', 'VOYAGE', 'VU', 'VUELOS', 'WALES', 'WALMART', 'WALTER', 'WANG', 'WANGGOU', 'WARMAN', 'WATCH', 'WATCHES', 'WEATHER', 'WEATHERCHANNEL', 'WEBCAM', 'WEBER', 'WEBSITE', 'WED', 'WEDDING', 'WEIBO', 'WEIR', 'WF', 'WHOSWHO', 'WIEN', 'WIKI', 'WILLIAMHILL', 'WIN', 'WINDOWS', 'WINE', 'WINNERS', 'WME', 'WOLTERSKLUWER', 'WOODSIDE', 'WORK', 'WORKS', 'WORLD', 'WOW', 'WS', 'WTC', 'WTF', 'XBOX', 'XEROX', 'XFINITY', 'XIHUAN', 'XIN', 'XN--11B4C3D', 'XN--1CK2E1B', 'XN--1QQW23A', 'XN--2SCRJ9C', 'XN--30RR7Y', 'XN--3BST00M', 'XN--3DS443G', 'XN--3E0B707E', 'XN--3HCRJ9C', 'XN--3OQ18VL8PN36A', 'XN--3PXU8K', 'XN--42C2D9A', 'XN--45BR5CYL', 'XN--45BRJ9C', 'XN--45Q11C', 'XN--4GBRIM', 'XN--54B7FTA0CC', 'XN--55QW42G', 'XN--55QX5D', 'XN--5SU34J936BGSG', 'XN--5TZM5G', 'XN--6FRZ82G', 'XN--6QQ986B3XL', 'XN--80ADXHKS', 'XN--80AO21A', 'XN--80AQECDR1A', 'XN--80ASEHDB', 'XN--80ASWG', 'XN--8Y0A063A', 'XN--90A3AC', 'XN--90AE', 'XN--90AIS', 'XN--9DBQ2A', 'XN--9ET52U', 'XN--9KRT00A', 'XN--B4W605FERD', 'XN--BCK1B9A5DRE4C', 'XN--C1AVG', 'XN--C2BR7G', 'XN--CCK2B3B', 'XN--CG4BKI', 'XN--CLCHC0EA0B2G2A9GCD', 'XN--CZR694B', 'XN--CZRS0T', 'XN--CZRU2D', 'XN--D1ACJ3B', 'XN--D1ALF', 'XN--E1A4C', 'XN--ECKVDTC9D', 'XN--EFVY88H', 'XN--ESTV75G', 'XN--FCT429K', 'XN--FHBEI', 'XN--FIQ228C5HS', 'XN--FIQ64B', 'XN--FIQS8S', 'XN--FIQZ9S', 'XN--FJQ720A', 'XN--FLW351E', 'XN--FPCRJ9C3D', 'XN--FZC2C9E2C', 'XN--FZYS8D69UVGM', 'XN--G2XX48C', 'XN--GCKR3F0F', 'XN--GECRJ9C', 'XN--GK3AT1E', 'XN--H2BREG3EVE', 'XN--H2BRJ9C', 'XN--H2BRJ9C8C', 'XN--HXT814E', 'XN--I1B6B1A6A2E', 'XN--IMR513N', 'XN--IO0A7I', 'XN--J1AEF', 'XN--J1AMH', 'XN--J6W193G', 'XN--JLQ61U9W7B', 'XN--JVR189M', 'XN--KCRX77D1X4A', 'XN--KPRW13D', 'XN--KPRY57D', 'XN--KPU716F', 'XN--KPUT3I', 'XN--L1ACC', 'XN--LGBBAT1AD8J', 'XN--MGB9AWBF', 'XN--MGBA3A3EJT', 'XN--MGBA3A4F16A', 'XN--MGBA7C0BBN0A', 'XN--MGBAAKC7DVF', 'XN--MGBAAM7A8H', 'XN--MGBAB2BD', 'XN--MGBAH1A3HJKRD', 'XN--MGBAI9AZGQP6J', 'XN--MGBAYH7GPA', 'XN--MGBB9FBPOB', 'XN--MGBBH1A', 'XN--MGBBH1A71E', 'XN--MGBC0A9AZCG', 'XN--MGBCA7DZDO', 'XN--MGBERP4A5D4AR', 'XN--MGBGU82A', 'XN--MGBI4ECEXP', 'XN--MGBPL2FH', 'XN--MGBT3DHD', 'XN--MGBTX2B', 'XN--MGBX4CD0AB', 'XN--MIX891F', 'XN--MK1BU44C', 'XN--MXTQ1M', 'XN--NGBC5AZD', 'XN--NGBE9E0A', 'XN--NGBRX', 'XN--NODE', 'XN--NQV7F', 'XN--NQV7FS00EMA', 'XN--NYQY26A', 'XN--O3CW4H', 'XN--OGBPF8FL', 'XN--OTU796D', 'XN--P1ACF', 'XN--P1AI', 'XN--PBT977C', 'XN--PGBS0DH', 'XN--PSSY2U', 'XN--Q9JYB4C', 'XN--QCKA1PMC', 'XN--QXAM', 'XN--RHQV96G', 'XN--ROVU88B', 'XN--RVC1E0AM3E', 'XN--S9BRJ9C', 'XN--SES554G', 'XN--T60B56A', 'XN--TCKWE', 'XN--TIQ49XQYJ', 'XN--UNUP4Y', 'XN--VERMGENSBERATER-CTB', 'XN--VERMGENSBERATUNG-PWB', 'XN--VHQUV', 'XN--VUQ861B', 'XN--W4R85EL8FHU5DNRA', 'XN--W4RS40L', 'XN--WGBH1C', 'XN--WGBL6A', 'XN--XHQ521B', 'XN--XKC2AL3HYE2A', 'XN--XKC2DL3A5EE0H', 'XN--Y9A3AQ', 'XN--YFRO4I67O', 'XN--YGBI2AMMX', 'XN--ZFR164B', 'XXX', 'XYZ', 'YACHTS', 'YAHOO', 'YAMAXUN', 'YANDEX', 'YE', 'YODOBASHI', 'YOGA', 'YOKOHAMA', 'YOU', 'YOUTUBE', 'YT', 'YUN', 'ZA', 'ZAPPOS', 'ZARA', 'ZERO', 'ZIP', 'ZM', 'ZONE', 'ZUERICH', 'ZW']; // Keep as upper-case to make updating from source easier\n\nmodule.exports = new Set(internals.tlds.map(function (tld) {\n return tld.toLowerCase();\n}));" + "source": "'use strict';\n\nconst internals = {}; // http://data.iana.org/TLD/tlds-alpha-by-domain.txt\n// # Version 2019032300, Last Updated Sat Mar 23 07:07:02 2019 UTC\n\ninternals.tlds = ['AAA', 'AARP', 'ABARTH', 'ABB', 'ABBOTT', 'ABBVIE', 'ABC', 'ABLE', 'ABOGADO', 'ABUDHABI', 'AC', 'ACADEMY', 'ACCENTURE', 'ACCOUNTANT', 'ACCOUNTANTS', 'ACO', 'ACTOR', 'AD', 'ADAC', 'ADS', 'ADULT', 'AE', 'AEG', 'AERO', 'AETNA', 'AF', 'AFAMILYCOMPANY', 'AFL', 'AFRICA', 'AG', 'AGAKHAN', 'AGENCY', 'AI', 'AIG', 'AIGO', 'AIRBUS', 'AIRFORCE', 'AIRTEL', 'AKDN', 'AL', 'ALFAROMEO', 'ALIBABA', 'ALIPAY', 'ALLFINANZ', 'ALLSTATE', 'ALLY', 'ALSACE', 'ALSTOM', 'AM', 'AMERICANEXPRESS', 'AMERICANFAMILY', 'AMEX', 'AMFAM', 'AMICA', 'AMSTERDAM', 'ANALYTICS', 'ANDROID', 'ANQUAN', 'ANZ', 'AO', 'AOL', 'APARTMENTS', 'APP', 'APPLE', 'AQ', 'AQUARELLE', 'AR', 'ARAB', 'ARAMCO', 'ARCHI', 'ARMY', 'ARPA', 'ART', 'ARTE', 'AS', 'ASDA', 'ASIA', 'ASSOCIATES', 'AT', 'ATHLETA', 'ATTORNEY', 'AU', 'AUCTION', 'AUDI', 'AUDIBLE', 'AUDIO', 'AUSPOST', 'AUTHOR', 'AUTO', 'AUTOS', 'AVIANCA', 'AW', 'AWS', 'AX', 'AXA', 'AZ', 'AZURE', 'BA', 'BABY', 'BAIDU', 'BANAMEX', 'BANANAREPUBLIC', 'BAND', 'BANK', 'BAR', 'BARCELONA', 'BARCLAYCARD', 'BARCLAYS', 'BAREFOOT', 'BARGAINS', 'BASEBALL', 'BASKETBALL', 'BAUHAUS', 'BAYERN', 'BB', 'BBC', 'BBT', 'BBVA', 'BCG', 'BCN', 'BD', 'BE', 'BEATS', 'BEAUTY', 'BEER', 'BENTLEY', 'BERLIN', 'BEST', 'BESTBUY', 'BET', 'BF', 'BG', 'BH', 'BHARTI', 'BI', 'BIBLE', 'BID', 'BIKE', 'BING', 'BINGO', 'BIO', 'BIZ', 'BJ', 'BLACK', 'BLACKFRIDAY', 'BLOCKBUSTER', 'BLOG', 'BLOOMBERG', 'BLUE', 'BM', 'BMS', 'BMW', 'BN', 'BNL', 'BNPPARIBAS', 'BO', 'BOATS', 'BOEHRINGER', 'BOFA', 'BOM', 'BOND', 'BOO', 'BOOK', 'BOOKING', 'BOSCH', 'BOSTIK', 'BOSTON', 'BOT', 'BOUTIQUE', 'BOX', 'BR', 'BRADESCO', 'BRIDGESTONE', 'BROADWAY', 'BROKER', 'BROTHER', 'BRUSSELS', 'BS', 'BT', 'BUDAPEST', 'BUGATTI', 'BUILD', 'BUILDERS', 'BUSINESS', 'BUY', 'BUZZ', 'BV', 'BW', 'BY', 'BZ', 'BZH', 'CA', 'CAB', 'CAFE', 'CAL', 'CALL', 'CALVINKLEIN', 'CAM', 'CAMERA', 'CAMP', 'CANCERRESEARCH', 'CANON', 'CAPETOWN', 'CAPITAL', 'CAPITALONE', 'CAR', 'CARAVAN', 'CARDS', 'CARE', 'CAREER', 'CAREERS', 'CARS', 'CARTIER', 'CASA', 'CASE', 'CASEIH', 'CASH', 'CASINO', 'CAT', 'CATERING', 'CATHOLIC', 'CBA', 'CBN', 'CBRE', 'CBS', 'CC', 'CD', 'CEB', 'CENTER', 'CEO', 'CERN', 'CF', 'CFA', 'CFD', 'CG', 'CH', 'CHANEL', 'CHANNEL', 'CHARITY', 'CHASE', 'CHAT', 'CHEAP', 'CHINTAI', 'CHRISTMAS', 'CHROME', 'CHRYSLER', 'CHURCH', 'CI', 'CIPRIANI', 'CIRCLE', 'CISCO', 'CITADEL', 'CITI', 'CITIC', 'CITY', 'CITYEATS', 'CK', 'CL', 'CLAIMS', 'CLEANING', 'CLICK', 'CLINIC', 'CLINIQUE', 'CLOTHING', 'CLOUD', 'CLUB', 'CLUBMED', 'CM', 'CN', 'CO', 'COACH', 'CODES', 'COFFEE', 'COLLEGE', 'COLOGNE', 'COM', 'COMCAST', 'COMMBANK', 'COMMUNITY', 'COMPANY', 'COMPARE', 'COMPUTER', 'COMSEC', 'CONDOS', 'CONSTRUCTION', 'CONSULTING', 'CONTACT', 'CONTRACTORS', 'COOKING', 'COOKINGCHANNEL', 'COOL', 'COOP', 'CORSICA', 'COUNTRY', 'COUPON', 'COUPONS', 'COURSES', 'CR', 'CREDIT', 'CREDITCARD', 'CREDITUNION', 'CRICKET', 'CROWN', 'CRS', 'CRUISE', 'CRUISES', 'CSC', 'CU', 'CUISINELLA', 'CV', 'CW', 'CX', 'CY', 'CYMRU', 'CYOU', 'CZ', 'DABUR', 'DAD', 'DANCE', 'DATA', 'DATE', 'DATING', 'DATSUN', 'DAY', 'DCLK', 'DDS', 'DE', 'DEAL', 'DEALER', 'DEALS', 'DEGREE', 'DELIVERY', 'DELL', 'DELOITTE', 'DELTA', 'DEMOCRAT', 'DENTAL', 'DENTIST', 'DESI', 'DESIGN', 'DEV', 'DHL', 'DIAMONDS', 'DIET', 'DIGITAL', 'DIRECT', 'DIRECTORY', 'DISCOUNT', 'DISCOVER', 'DISH', 'DIY', 'DJ', 'DK', 'DM', 'DNP', 'DO', 'DOCS', 'DOCTOR', 'DODGE', 'DOG', 'DOHA', 'DOMAINS', 'DOT', 'DOWNLOAD', 'DRIVE', 'DTV', 'DUBAI', 'DUCK', 'DUNLOP', 'DUNS', 'DUPONT', 'DURBAN', 'DVAG', 'DVR', 'DZ', 'EARTH', 'EAT', 'EC', 'ECO', 'EDEKA', 'EDU', 'EDUCATION', 'EE', 'EG', 'EMAIL', 'EMERCK', 'ENERGY', 'ENGINEER', 'ENGINEERING', 'ENTERPRISES', 'EPSON', 'EQUIPMENT', 'ER', 'ERICSSON', 'ERNI', 'ES', 'ESQ', 'ESTATE', 'ESURANCE', 'ET', 'ETISALAT', 'EU', 'EUROVISION', 'EUS', 'EVENTS', 'EVERBANK', 'EXCHANGE', 'EXPERT', 'EXPOSED', 'EXPRESS', 'EXTRASPACE', 'FAGE', 'FAIL', 'FAIRWINDS', 'FAITH', 'FAMILY', 'FAN', 'FANS', 'FARM', 'FARMERS', 'FASHION', 'FAST', 'FEDEX', 'FEEDBACK', 'FERRARI', 'FERRERO', 'FI', 'FIAT', 'FIDELITY', 'FIDO', 'FILM', 'FINAL', 'FINANCE', 'FINANCIAL', 'FIRE', 'FIRESTONE', 'FIRMDALE', 'FISH', 'FISHING', 'FIT', 'FITNESS', 'FJ', 'FK', 'FLICKR', 'FLIGHTS', 'FLIR', 'FLORIST', 'FLOWERS', 'FLY', 'FM', 'FO', 'FOO', 'FOOD', 'FOODNETWORK', 'FOOTBALL', 'FORD', 'FOREX', 'FORSALE', 'FORUM', 'FOUNDATION', 'FOX', 'FR', 'FREE', 'FRESENIUS', 'FRL', 'FROGANS', 'FRONTDOOR', 'FRONTIER', 'FTR', 'FUJITSU', 'FUJIXEROX', 'FUN', 'FUND', 'FURNITURE', 'FUTBOL', 'FYI', 'GA', 'GAL', 'GALLERY', 'GALLO', 'GALLUP', 'GAME', 'GAMES', 'GAP', 'GARDEN', 'GB', 'GBIZ', 'GD', 'GDN', 'GE', 'GEA', 'GENT', 'GENTING', 'GEORGE', 'GF', 'GG', 'GGEE', 'GH', 'GI', 'GIFT', 'GIFTS', 'GIVES', 'GIVING', 'GL', 'GLADE', 'GLASS', 'GLE', 'GLOBAL', 'GLOBO', 'GM', 'GMAIL', 'GMBH', 'GMO', 'GMX', 'GN', 'GODADDY', 'GOLD', 'GOLDPOINT', 'GOLF', 'GOO', 'GOODYEAR', 'GOOG', 'GOOGLE', 'GOP', 'GOT', 'GOV', 'GP', 'GQ', 'GR', 'GRAINGER', 'GRAPHICS', 'GRATIS', 'GREEN', 'GRIPE', 'GROCERY', 'GROUP', 'GS', 'GT', 'GU', 'GUARDIAN', 'GUCCI', 'GUGE', 'GUIDE', 'GUITARS', 'GURU', 'GW', 'GY', 'HAIR', 'HAMBURG', 'HANGOUT', 'HAUS', 'HBO', 'HDFC', 'HDFCBANK', 'HEALTH', 'HEALTHCARE', 'HELP', 'HELSINKI', 'HERE', 'HERMES', 'HGTV', 'HIPHOP', 'HISAMITSU', 'HITACHI', 'HIV', 'HK', 'HKT', 'HM', 'HN', 'HOCKEY', 'HOLDINGS', 'HOLIDAY', 'HOMEDEPOT', 'HOMEGOODS', 'HOMES', 'HOMESENSE', 'HONDA', 'HONEYWELL', 'HORSE', 'HOSPITAL', 'HOST', 'HOSTING', 'HOT', 'HOTELES', 'HOTELS', 'HOTMAIL', 'HOUSE', 'HOW', 'HR', 'HSBC', 'HT', 'HU', 'HUGHES', 'HYATT', 'HYUNDAI', 'IBM', 'ICBC', 'ICE', 'ICU', 'ID', 'IE', 'IEEE', 'IFM', 'IKANO', 'IL', 'IM', 'IMAMAT', 'IMDB', 'IMMO', 'IMMOBILIEN', 'IN', 'INC', 'INDUSTRIES', 'INFINITI', 'INFO', 'ING', 'INK', 'INSTITUTE', 'INSURANCE', 'INSURE', 'INT', 'INTEL', 'INTERNATIONAL', 'INTUIT', 'INVESTMENTS', 'IO', 'IPIRANGA', 'IQ', 'IR', 'IRISH', 'IS', 'ISELECT', 'ISMAILI', 'IST', 'ISTANBUL', 'IT', 'ITAU', 'ITV', 'IVECO', 'JAGUAR', 'JAVA', 'JCB', 'JCP', 'JE', 'JEEP', 'JETZT', 'JEWELRY', 'JIO', 'JLL', 'JM', 'JMP', 'JNJ', 'JO', 'JOBS', 'JOBURG', 'JOT', 'JOY', 'JP', 'JPMORGAN', 'JPRS', 'JUEGOS', 'JUNIPER', 'KAUFEN', 'KDDI', 'KE', 'KERRYHOTELS', 'KERRYLOGISTICS', 'KERRYPROPERTIES', 'KFH', 'KG', 'KH', 'KI', 'KIA', 'KIM', 'KINDER', 'KINDLE', 'KITCHEN', 'KIWI', 'KM', 'KN', 'KOELN', 'KOMATSU', 'KOSHER', 'KP', 'KPMG', 'KPN', 'KR', 'KRD', 'KRED', 'KUOKGROUP', 'KW', 'KY', 'KYOTO', 'KZ', 'LA', 'LACAIXA', 'LADBROKES', 'LAMBORGHINI', 'LAMER', 'LANCASTER', 'LANCIA', 'LANCOME', 'LAND', 'LANDROVER', 'LANXESS', 'LASALLE', 'LAT', 'LATINO', 'LATROBE', 'LAW', 'LAWYER', 'LB', 'LC', 'LDS', 'LEASE', 'LECLERC', 'LEFRAK', 'LEGAL', 'LEGO', 'LEXUS', 'LGBT', 'LI', 'LIAISON', 'LIDL', 'LIFE', 'LIFEINSURANCE', 'LIFESTYLE', 'LIGHTING', 'LIKE', 'LILLY', 'LIMITED', 'LIMO', 'LINCOLN', 'LINDE', 'LINK', 'LIPSY', 'LIVE', 'LIVING', 'LIXIL', 'LK', 'LLC', 'LOAN', 'LOANS', 'LOCKER', 'LOCUS', 'LOFT', 'LOL', 'LONDON', 'LOTTE', 'LOTTO', 'LOVE', 'LPL', 'LPLFINANCIAL', 'LR', 'LS', 'LT', 'LTD', 'LTDA', 'LU', 'LUNDBECK', 'LUPIN', 'LUXE', 'LUXURY', 'LV', 'LY', 'MA', 'MACYS', 'MADRID', 'MAIF', 'MAISON', 'MAKEUP', 'MAN', 'MANAGEMENT', 'MANGO', 'MAP', 'MARKET', 'MARKETING', 'MARKETS', 'MARRIOTT', 'MARSHALLS', 'MASERATI', 'MATTEL', 'MBA', 'MC', 'MCKINSEY', 'MD', 'ME', 'MED', 'MEDIA', 'MEET', 'MELBOURNE', 'MEME', 'MEMORIAL', 'MEN', 'MENU', 'MERCKMSD', 'METLIFE', 'MG', 'MH', 'MIAMI', 'MICROSOFT', 'MIL', 'MINI', 'MINT', 'MIT', 'MITSUBISHI', 'MK', 'ML', 'MLB', 'MLS', 'MM', 'MMA', 'MN', 'MO', 'MOBI', 'MOBILE', 'MOBILY', 'MODA', 'MOE', 'MOI', 'MOM', 'MONASH', 'MONEY', 'MONSTER', 'MOPAR', 'MORMON', 'MORTGAGE', 'MOSCOW', 'MOTO', 'MOTORCYCLES', 'MOV', 'MOVIE', 'MOVISTAR', 'MP', 'MQ', 'MR', 'MS', 'MSD', 'MT', 'MTN', 'MTR', 'MU', 'MUSEUM', 'MUTUAL', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NAB', 'NADEX', 'NAGOYA', 'NAME', 'NATIONWIDE', 'NATURA', 'NAVY', 'NBA', 'NC', 'NE', 'NEC', 'NET', 'NETBANK', 'NETFLIX', 'NETWORK', 'NEUSTAR', 'NEW', 'NEWHOLLAND', 'NEWS', 'NEXT', 'NEXTDIRECT', 'NEXUS', 'NF', 'NFL', 'NG', 'NGO', 'NHK', 'NI', 'NICO', 'NIKE', 'NIKON', 'NINJA', 'NISSAN', 'NISSAY', 'NL', 'NO', 'NOKIA', 'NORTHWESTERNMUTUAL', 'NORTON', 'NOW', 'NOWRUZ', 'NOWTV', 'NP', 'NR', 'NRA', 'NRW', 'NTT', 'NU', 'NYC', 'NZ', 'OBI', 'OBSERVER', 'OFF', 'OFFICE', 'OKINAWA', 'OLAYAN', 'OLAYANGROUP', 'OLDNAVY', 'OLLO', 'OM', 'OMEGA', 'ONE', 'ONG', 'ONL', 'ONLINE', 'ONYOURSIDE', 'OOO', 'OPEN', 'ORACLE', 'ORANGE', 'ORG', 'ORGANIC', 'ORIGINS', 'OSAKA', 'OTSUKA', 'OTT', 'OVH', 'PA', 'PAGE', 'PANASONIC', 'PARIS', 'PARS', 'PARTNERS', 'PARTS', 'PARTY', 'PASSAGENS', 'PAY', 'PCCW', 'PE', 'PET', 'PF', 'PFIZER', 'PG', 'PH', 'PHARMACY', 'PHD', 'PHILIPS', 'PHONE', 'PHOTO', 'PHOTOGRAPHY', 'PHOTOS', 'PHYSIO', 'PIAGET', 'PICS', 'PICTET', 'PICTURES', 'PID', 'PIN', 'PING', 'PINK', 'PIONEER', 'PIZZA', 'PK', 'PL', 'PLACE', 'PLAY', 'PLAYSTATION', 'PLUMBING', 'PLUS', 'PM', 'PN', 'PNC', 'POHL', 'POKER', 'POLITIE', 'PORN', 'POST', 'PR', 'PRAMERICA', 'PRAXI', 'PRESS', 'PRIME', 'PRO', 'PROD', 'PRODUCTIONS', 'PROF', 'PROGRESSIVE', 'PROMO', 'PROPERTIES', 'PROPERTY', 'PROTECTION', 'PRU', 'PRUDENTIAL', 'PS', 'PT', 'PUB', 'PW', 'PWC', 'PY', 'QA', 'QPON', 'QUEBEC', 'QUEST', 'QVC', 'RACING', 'RADIO', 'RAID', 'RE', 'READ', 'REALESTATE', 'REALTOR', 'REALTY', 'RECIPES', 'RED', 'REDSTONE', 'REDUMBRELLA', 'REHAB', 'REISE', 'REISEN', 'REIT', 'RELIANCE', 'REN', 'RENT', 'RENTALS', 'REPAIR', 'REPORT', 'REPUBLICAN', 'REST', 'RESTAURANT', 'REVIEW', 'REVIEWS', 'REXROTH', 'RICH', 'RICHARDLI', 'RICOH', 'RIGHTATHOME', 'RIL', 'RIO', 'RIP', 'RMIT', 'RO', 'ROCHER', 'ROCKS', 'RODEO', 'ROGERS', 'ROOM', 'RS', 'RSVP', 'RU', 'RUGBY', 'RUHR', 'RUN', 'RW', 'RWE', 'RYUKYU', 'SA', 'SAARLAND', 'SAFE', 'SAFETY', 'SAKURA', 'SALE', 'SALON', 'SAMSCLUB', 'SAMSUNG', 'SANDVIK', 'SANDVIKCOROMANT', 'SANOFI', 'SAP', 'SARL', 'SAS', 'SAVE', 'SAXO', 'SB', 'SBI', 'SBS', 'SC', 'SCA', 'SCB', 'SCHAEFFLER', 'SCHMIDT', 'SCHOLARSHIPS', 'SCHOOL', 'SCHULE', 'SCHWARZ', 'SCIENCE', 'SCJOHNSON', 'SCOR', 'SCOT', 'SD', 'SE', 'SEARCH', 'SEAT', 'SECURE', 'SECURITY', 'SEEK', 'SELECT', 'SENER', 'SERVICES', 'SES', 'SEVEN', 'SEW', 'SEX', 'SEXY', 'SFR', 'SG', 'SH', 'SHANGRILA', 'SHARP', 'SHAW', 'SHELL', 'SHIA', 'SHIKSHA', 'SHOES', 'SHOP', 'SHOPPING', 'SHOUJI', 'SHOW', 'SHOWTIME', 'SHRIRAM', 'SI', 'SILK', 'SINA', 'SINGLES', 'SITE', 'SJ', 'SK', 'SKI', 'SKIN', 'SKY', 'SKYPE', 'SL', 'SLING', 'SM', 'SMART', 'SMILE', 'SN', 'SNCF', 'SO', 'SOCCER', 'SOCIAL', 'SOFTBANK', 'SOFTWARE', 'SOHU', 'SOLAR', 'SOLUTIONS', 'SONG', 'SONY', 'SOY', 'SPACE', 'SPORT', 'SPOT', 'SPREADBETTING', 'SR', 'SRL', 'SRT', 'SS', 'ST', 'STADA', 'STAPLES', 'STAR', 'STARHUB', 'STATEBANK', 'STATEFARM', 'STC', 'STCGROUP', 'STOCKHOLM', 'STORAGE', 'STORE', 'STREAM', 'STUDIO', 'STUDY', 'STYLE', 'SU', 'SUCKS', 'SUPPLIES', 'SUPPLY', 'SUPPORT', 'SURF', 'SURGERY', 'SUZUKI', 'SV', 'SWATCH', 'SWIFTCOVER', 'SWISS', 'SX', 'SY', 'SYDNEY', 'SYMANTEC', 'SYSTEMS', 'SZ', 'TAB', 'TAIPEI', 'TALK', 'TAOBAO', 'TARGET', 'TATAMOTORS', 'TATAR', 'TATTOO', 'TAX', 'TAXI', 'TC', 'TCI', 'TD', 'TDK', 'TEAM', 'TECH', 'TECHNOLOGY', 'TEL', 'TELEFONICA', 'TEMASEK', 'TENNIS', 'TEVA', 'TF', 'TG', 'TH', 'THD', 'THEATER', 'THEATRE', 'TIAA', 'TICKETS', 'TIENDA', 'TIFFANY', 'TIPS', 'TIRES', 'TIROL', 'TJ', 'TJMAXX', 'TJX', 'TK', 'TKMAXX', 'TL', 'TM', 'TMALL', 'TN', 'TO', 'TODAY', 'TOKYO', 'TOOLS', 'TOP', 'TORAY', 'TOSHIBA', 'TOTAL', 'TOURS', 'TOWN', 'TOYOTA', 'TOYS', 'TR', 'TRADE', 'TRADING', 'TRAINING', 'TRAVEL', 'TRAVELCHANNEL', 'TRAVELERS', 'TRAVELERSINSURANCE', 'TRUST', 'TRV', 'TT', 'TUBE', 'TUI', 'TUNES', 'TUSHU', 'TV', 'TVS', 'TW', 'TZ', 'UA', 'UBANK', 'UBS', 'UCONNECT', 'UG', 'UK', 'UNICOM', 'UNIVERSITY', 'UNO', 'UOL', 'UPS', 'US', 'UY', 'UZ', 'VA', 'VACATIONS', 'VANA', 'VANGUARD', 'VC', 'VE', 'VEGAS', 'VENTURES', 'VERISIGN', 'VERSICHERUNG', 'VET', 'VG', 'VI', 'VIAJES', 'VIDEO', 'VIG', 'VIKING', 'VILLAS', 'VIN', 'VIP', 'VIRGIN', 'VISA', 'VISION', 'VISTAPRINT', 'VIVA', 'VIVO', 'VLAANDEREN', 'VN', 'VODKA', 'VOLKSWAGEN', 'VOLVO', 'VOTE', 'VOTING', 'VOTO', 'VOYAGE', 'VU', 'VUELOS', 'WALES', 'WALMART', 'WALTER', 'WANG', 'WANGGOU', 'WARMAN', 'WATCH', 'WATCHES', 'WEATHER', 'WEATHERCHANNEL', 'WEBCAM', 'WEBER', 'WEBSITE', 'WED', 'WEDDING', 'WEIBO', 'WEIR', 'WF', 'WHOSWHO', 'WIEN', 'WIKI', 'WILLIAMHILL', 'WIN', 'WINDOWS', 'WINE', 'WINNERS', 'WME', 'WOLTERSKLUWER', 'WOODSIDE', 'WORK', 'WORKS', 'WORLD', 'WOW', 'WS', 'WTC', 'WTF', 'XBOX', 'XEROX', 'XFINITY', 'XIHUAN', 'XIN', 'XN--11B4C3D', 'XN--1CK2E1B', 'XN--1QQW23A', 'XN--2SCRJ9C', 'XN--30RR7Y', 'XN--3BST00M', 'XN--3DS443G', 'XN--3E0B707E', 'XN--3HCRJ9C', 'XN--3OQ18VL8PN36A', 'XN--3PXU8K', 'XN--42C2D9A', 'XN--45BR5CYL', 'XN--45BRJ9C', 'XN--45Q11C', 'XN--4GBRIM', 'XN--54B7FTA0CC', 'XN--55QW42G', 'XN--55QX5D', 'XN--5SU34J936BGSG', 'XN--5TZM5G', 'XN--6FRZ82G', 'XN--6QQ986B3XL', 'XN--80ADXHKS', 'XN--80AO21A', 'XN--80AQECDR1A', 'XN--80ASEHDB', 'XN--80ASWG', 'XN--8Y0A063A', 'XN--90A3AC', 'XN--90AE', 'XN--90AIS', 'XN--9DBQ2A', 'XN--9ET52U', 'XN--9KRT00A', 'XN--B4W605FERD', 'XN--BCK1B9A5DRE4C', 'XN--C1AVG', 'XN--C2BR7G', 'XN--CCK2B3B', 'XN--CG4BKI', 'XN--CLCHC0EA0B2G2A9GCD', 'XN--CZR694B', 'XN--CZRS0T', 'XN--CZRU2D', 'XN--D1ACJ3B', 'XN--D1ALF', 'XN--E1A4C', 'XN--ECKVDTC9D', 'XN--EFVY88H', 'XN--ESTV75G', 'XN--FCT429K', 'XN--FHBEI', 'XN--FIQ228C5HS', 'XN--FIQ64B', 'XN--FIQS8S', 'XN--FIQZ9S', 'XN--FJQ720A', 'XN--FLW351E', 'XN--FPCRJ9C3D', 'XN--FZC2C9E2C', 'XN--FZYS8D69UVGM', 'XN--G2XX48C', 'XN--GCKR3F0F', 'XN--GECRJ9C', 'XN--GK3AT1E', 'XN--H2BREG3EVE', 'XN--H2BRJ9C', 'XN--H2BRJ9C8C', 'XN--HXT814E', 'XN--I1B6B1A6A2E', 'XN--IMR513N', 'XN--IO0A7I', 'XN--J1AEF', 'XN--J1AMH', 'XN--J6W193G', 'XN--JLQ61U9W7B', 'XN--JVR189M', 'XN--KCRX77D1X4A', 'XN--KPRW13D', 'XN--KPRY57D', 'XN--KPU716F', 'XN--KPUT3I', 'XN--L1ACC', 'XN--LGBBAT1AD8J', 'XN--MGB9AWBF', 'XN--MGBA3A3EJT', 'XN--MGBA3A4F16A', 'XN--MGBA7C0BBN0A', 'XN--MGBAAKC7DVF', 'XN--MGBAAM7A8H', 'XN--MGBAB2BD', 'XN--MGBAH1A3HJKRD', 'XN--MGBAI9AZGQP6J', 'XN--MGBAYH7GPA', 'XN--MGBB9FBPOB', 'XN--MGBBH1A', 'XN--MGBBH1A71E', 'XN--MGBC0A9AZCG', 'XN--MGBCA7DZDO', 'XN--MGBERP4A5D4AR', 'XN--MGBGU82A', 'XN--MGBI4ECEXP', 'XN--MGBPL2FH', 'XN--MGBT3DHD', 'XN--MGBTX2B', 'XN--MGBX4CD0AB', 'XN--MIX891F', 'XN--MK1BU44C', 'XN--MXTQ1M', 'XN--NGBC5AZD', 'XN--NGBE9E0A', 'XN--NGBRX', 'XN--NODE', 'XN--NQV7F', 'XN--NQV7FS00EMA', 'XN--NYQY26A', 'XN--O3CW4H', 'XN--OGBPF8FL', 'XN--OTU796D', 'XN--P1ACF', 'XN--P1AI', 'XN--PBT977C', 'XN--PGBS0DH', 'XN--PSSY2U', 'XN--Q9JYB4C', 'XN--QCKA1PMC', 'XN--QXAM', 'XN--RHQV96G', 'XN--ROVU88B', 'XN--RVC1E0AM3E', 'XN--S9BRJ9C', 'XN--SES554G', 'XN--T60B56A', 'XN--TCKWE', 'XN--TIQ49XQYJ', 'XN--UNUP4Y', 'XN--VERMGENSBERATER-CTB', 'XN--VERMGENSBERATUNG-PWB', 'XN--VHQUV', 'XN--VUQ861B', 'XN--W4R85EL8FHU5DNRA', 'XN--W4RS40L', 'XN--WGBH1C', 'XN--WGBL6A', 'XN--XHQ521B', 'XN--XKC2AL3HYE2A', 'XN--XKC2DL3A5EE0H', 'XN--Y9A3AQ', 'XN--YFRO4I67O', 'XN--YGBI2AMMX', 'XN--ZFR164B', 'XXX', 'XYZ', 'YACHTS', 'YAHOO', 'YAMAXUN', 'YANDEX', 'YE', 'YODOBASHI', 'YOGA', 'YOKOHAMA', 'YOU', 'YOUTUBE', 'YT', 'YUN', 'ZA', 'ZAPPOS', 'ZARA', 'ZERO', 'ZIP', 'ZM', 'ZONE', 'ZUERICH', 'ZW']; // Keep as upper-case to make updating from source easier\n\nmodule.exports = new Set(internals.tlds.map(tld => tld.toLowerCase()));" }, { - "id": 50, + "id": 49, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/node_modules/@hapi/hoek/lib/contain.js", "name": "../node_modules/@hapi/hoek/lib/contain.js", - "index": 49, - "index2": 47, - "size": 4364, + "index": 48, + "index2": 46, + "size": 3364, "cacheable": true, "built": true, "optional": false, @@ -8867,7 +8681,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", - "issuerId": 43, + "issuerId": 42, "issuerName": "../lib/types/string/index.js", "issuerPath": [ { @@ -8875,25 +8689,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 }, "failed": false, "errors": 0, @@ -8901,13 +8715,13 @@ "assets": [], "reasons": [ { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "@hapi/hoek/lib/contain", - "loc": "17:14-47" + "loc": "15:16-49" } ], "usedExports": true, @@ -8916,15 +8730,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar Assert = require('./assert');\n\nvar DeepEqual = require('./deepEqual');\n\nvar EscapeRegex = require('./escapeRegex');\n\nvar Utils = require('./utils');\n\nvar internals = {};\n\nmodule.exports = function (ref, values) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n // options: { deep, once, only, part, symbols }\n\n /*\n string -> string(s)\n array -> item(s)\n object -> key(s)\n object -> object (key:value)\n */\n var valuePairs = null;\n\n if (_typeof(ref) === 'object' && _typeof(values) === 'object' && !Array.isArray(ref) && !Array.isArray(values)) {\n valuePairs = values;\n var symbols = Object.getOwnPropertySymbols(values).filter(Object.prototype.propertyIsEnumerable.bind(values));\n values = [].concat(_toConsumableArray(Object.keys(values)), _toConsumableArray(symbols));\n } else {\n values = [].concat(values);\n }\n\n Assert(typeof ref === 'string' || _typeof(ref) === 'object', 'Reference must be string or an object');\n Assert(values.length, 'Values array cannot be empty');\n var compare;\n var compareFlags;\n\n if (options.deep) {\n compare = DeepEqual;\n var hasOnly = options.only !== undefined;\n var hasPart = options.part !== undefined;\n compareFlags = {\n prototype: hasOnly ? options.only : hasPart ? !options.part : false,\n part: hasOnly ? !options.only : hasPart ? options.part : false\n };\n } else {\n compare = function compare(a, b) {\n return a === b;\n };\n }\n\n var misses = false;\n var matches = new Array(values.length);\n\n for (var i = 0; i < matches.length; ++i) {\n matches[i] = 0;\n }\n\n if (typeof ref === 'string') {\n var pattern = '(';\n\n for (var _i = 0; _i < values.length; ++_i) {\n var value = values[_i];\n Assert(typeof value === 'string', 'Cannot compare string reference to non-string value');\n pattern += (_i ? '|' : '') + EscapeRegex(value);\n }\n\n var regex = new RegExp(pattern + ')', 'g');\n var leftovers = ref.replace(regex, function ($0, $1) {\n var index = values.indexOf($1);\n ++matches[index];\n return ''; // Remove from string\n });\n misses = !!leftovers;\n } else if (Array.isArray(ref)) {\n var onlyOnce = !!(options.only && options.once);\n\n if (onlyOnce && ref.length !== values.length) {\n return false;\n }\n\n for (var _i2 = 0; _i2 < ref.length; ++_i2) {\n var matched = false;\n\n for (var j = 0; j < values.length && matched === false; ++j) {\n if (!onlyOnce || matches[j] === 0) {\n matched = compare(values[j], ref[_i2], compareFlags) && j;\n }\n }\n\n if (matched !== false) {\n ++matches[matched];\n } else {\n misses = true;\n }\n }\n } else {\n var keys = Utils.keys(ref, options);\n\n for (var _i3 = 0; _i3 < keys.length; ++_i3) {\n var key = keys[_i3];\n var pos = values.indexOf(key);\n\n if (pos !== -1) {\n if (valuePairs && !compare(valuePairs[key], ref[key], compareFlags)) {\n return false;\n }\n\n ++matches[pos];\n } else {\n misses = true;\n }\n }\n }\n\n if (options.only) {\n if (misses || !options.once) {\n return !misses;\n }\n }\n\n var result = false;\n\n for (var _i4 = 0; _i4 < matches.length; ++_i4) {\n result = result || !!matches[_i4];\n\n if (options.once && matches[_i4] > 1 || !options.part && !matches[_i4]) {\n return false;\n }\n }\n\n return result;\n};" + "source": "'use strict';\n\nconst Assert = require('./assert');\n\nconst DeepEqual = require('./deepEqual');\n\nconst EscapeRegex = require('./escapeRegex');\n\nconst Utils = require('./utils');\n\nconst internals = {};\n\nmodule.exports = function (ref, values) {\n let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n // options: { deep, once, only, part, symbols }\n\n /*\n string -> string(s)\n array -> item(s)\n object -> key(s)\n object -> object (key:value)\n */\n let valuePairs = null;\n\n if (typeof ref === 'object' && typeof values === 'object' && !Array.isArray(ref) && !Array.isArray(values)) {\n valuePairs = values;\n const symbols = Object.getOwnPropertySymbols(values).filter(Object.prototype.propertyIsEnumerable.bind(values));\n values = [...Object.keys(values), ...symbols];\n } else {\n values = [].concat(values);\n }\n\n Assert(typeof ref === 'string' || typeof ref === 'object', 'Reference must be string or an object');\n Assert(values.length, 'Values array cannot be empty');\n let compare;\n let compareFlags;\n\n if (options.deep) {\n compare = DeepEqual;\n const hasOnly = options.only !== undefined;\n const hasPart = options.part !== undefined;\n compareFlags = {\n prototype: hasOnly ? options.only : hasPart ? !options.part : false,\n part: hasOnly ? !options.only : hasPart ? options.part : false\n };\n } else {\n compare = (a, b) => a === b;\n }\n\n let misses = false;\n const matches = new Array(values.length);\n\n for (let i = 0; i < matches.length; ++i) {\n matches[i] = 0;\n }\n\n if (typeof ref === 'string') {\n let pattern = '(';\n\n for (let i = 0; i < values.length; ++i) {\n const value = values[i];\n Assert(typeof value === 'string', 'Cannot compare string reference to non-string value');\n pattern += (i ? '|' : '') + EscapeRegex(value);\n }\n\n const regex = new RegExp(pattern + ')', 'g');\n const leftovers = ref.replace(regex, ($0, $1) => {\n const index = values.indexOf($1);\n ++matches[index];\n return ''; // Remove from string\n });\n misses = !!leftovers;\n } else if (Array.isArray(ref)) {\n const onlyOnce = !!(options.only && options.once);\n\n if (onlyOnce && ref.length !== values.length) {\n return false;\n }\n\n for (let i = 0; i < ref.length; ++i) {\n let matched = false;\n\n for (let j = 0; j < values.length && matched === false; ++j) {\n if (!onlyOnce || matches[j] === 0) {\n matched = compare(values[j], ref[i], compareFlags) && j;\n }\n }\n\n if (matched !== false) {\n ++matches[matched];\n } else {\n misses = true;\n }\n }\n } else {\n const keys = Utils.keys(ref, options);\n\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n const pos = values.indexOf(key);\n\n if (pos !== -1) {\n if (valuePairs && !compare(valuePairs[key], ref[key], compareFlags)) {\n return false;\n }\n\n ++matches[pos];\n } else {\n misses = true;\n }\n }\n }\n\n if (options.only) {\n if (misses || !options.once) {\n return !misses;\n }\n }\n\n let result = false;\n\n for (let i = 0; i < matches.length; ++i) {\n result = result || !!matches[i];\n\n if (options.once && matches[i] > 1 || !options.part && !matches[i]) {\n return false;\n }\n }\n\n return result;\n};" }, { - "id": 51, + "id": 50, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/ip.js", "name": "../lib/types/string/ip.js", - "index": 50, - "index2": 49, - "size": 780, + "index": 49, + "index2": 48, + "size": 760, "cacheable": true, "built": true, "optional": false, @@ -8933,7 +8747,7 @@ 0 ], "issuer": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", - "issuerId": 43, + "issuerId": 42, "issuerName": "../lib/types/string/index.js", "issuerPath": [ { @@ -8941,25 +8755,25 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } }, { - "id": 43, + "id": 42, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "name": "../lib/types/string/index.js", "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 } } ], "profile": { - "factory": 675, - "building": 23, - "dependencies": 0 + "factory": 378, + "building": 40, + "dependencies": 1 }, "failed": false, "errors": 0, @@ -8967,13 +8781,13 @@ "assets": [], "reasons": [ { - "moduleId": 43, + "moduleId": 42, "moduleIdentifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/string/index.js", "module": "../lib/types/string/index.js", "moduleName": "../lib/types/string/index.js", "type": "cjs require", "userRequest": "./ip", - "loc": "23:9-24" + "loc": "21:11-26" } ], "usedExports": true, @@ -8982,15 +8796,15 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 2, - "source": "'use strict';\n\nvar Uri = require('./uri');\n\nvar internals = {};\nexports.cidrs = {\n ipv4: {\n required: '\\\\/(?:' + Uri.ipv4Cidr + ')',\n optional: '(?:\\\\/(?:' + Uri.ipv4Cidr + '))?',\n forbidden: ''\n },\n ipv6: {\n required: '\\\\/' + Uri.ipv6Cidr,\n optional: '(?:\\\\/' + Uri.ipv6Cidr + ')?',\n forbidden: ''\n },\n ipvfuture: {\n required: '\\\\/' + Uri.ipv6Cidr,\n optional: '(?:\\\\/' + Uri.ipv6Cidr + ')?',\n forbidden: ''\n }\n};\nexports.versions = {\n ipv4: Uri.ipv4address,\n ipv6: Uri.ipv6address,\n ipvfuture: Uri.ipvFuture\n};\n\nexports.createIpRegex = function (versions, cidr) {\n var parts = versions.map(function (version) {\n return exports.versions[version] + exports.cidrs[version][cidr];\n });\n return new RegExp('^(?:' + parts.join('|') + ')$');\n};" + "source": "'use strict';\n\nconst Uri = require('./uri');\n\nconst internals = {};\nexports.cidrs = {\n ipv4: {\n required: '\\\\/(?:' + Uri.ipv4Cidr + ')',\n optional: '(?:\\\\/(?:' + Uri.ipv4Cidr + '))?',\n forbidden: ''\n },\n ipv6: {\n required: '\\\\/' + Uri.ipv6Cidr,\n optional: '(?:\\\\/' + Uri.ipv6Cidr + ')?',\n forbidden: ''\n },\n ipvfuture: {\n required: '\\\\/' + Uri.ipv6Cidr,\n optional: '(?:\\\\/' + Uri.ipv6Cidr + ')?',\n forbidden: ''\n }\n};\nexports.versions = {\n ipv4: Uri.ipv4address,\n ipv6: Uri.ipv6address,\n ipvfuture: Uri.ipvFuture\n};\n\nexports.createIpRegex = function (versions, cidr) {\n const parts = versions.map(version => exports.versions[version] + exports.cidrs[version][cidr]);\n return new RegExp('^(?:' + parts.join('|') + ')$');\n};" }, { - "id": 52, + "id": 51, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/symbol.js", "name": "../lib/types/symbol.js", - "index": 52, - "index2": 51, - "size": 7798, + "index": 51, + "index2": 50, + "size": 2221, "cacheable": true, "built": true, "optional": false, @@ -9007,15 +8821,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -9029,7 +8843,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/symbol", - "loc": "48:12-37" + "loc": "34:12-37" } ], "usedExports": true, @@ -9038,14 +8852,14 @@ "ModuleConcatenation bailout: Module is not an ECMAScript module" ], "depth": 1, - "source": "'use strict';\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\n\nfunction isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\n\nfunction _isNativeFunction(fn) { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nvar Assert = require('@hapi/hoek/lib/assert');\n\nvar Any = require('./any');\n\nvar internals = {};\n\ninternals.Map =\n/*#__PURE__*/\nfunction (_Map) {\n _inherits(_class, _Map);\n\n function _class() {\n _classCallCheck(this, _class);\n\n return _possibleConstructorReturn(this, _getPrototypeOf(_class).apply(this, arguments));\n }\n\n _createClass(_class, [{\n key: \"slice\",\n value: function slice() {\n return new internals.Map(this);\n }\n }]);\n\n return _class;\n}(_wrapNativeSuper(Map));\n\nmodule.exports = Any.extend({\n type: 'symbol',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.map = new internals.Map();\n },\n // Coerce\n coerce: {\n method: function method(schema, value, _ref) {\n var error = _ref.error;\n var lookup = schema.$_terms.map.get(value);\n\n if (lookup) {\n value = lookup;\n }\n\n if (!schema._flags.only || _typeof(value) === 'symbol') {\n return {\n value: value\n };\n }\n\n return {\n value: value,\n errors: error('symbol.map', {\n map: schema.$_terms.map\n })\n };\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n var error = _ref2.error;\n\n if (_typeof(value) !== 'symbol') {\n return {\n value: value,\n errors: error('symbol.base')\n };\n }\n },\n // Rules\n rules: {\n map: {\n method: function method(iterable) {\n if (iterable && !iterable[Symbol.iterator] && _typeof(iterable) === 'object') {\n iterable = Object.entries(iterable);\n }\n\n Assert(iterable && iterable[Symbol.iterator], 'Iterable must be an iterable or object');\n var obj = this.clone();\n var symbols = [];\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = iterable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var entry = _step.value;\n Assert(entry && entry[Symbol.iterator], 'Entry must be an iterable');\n\n var _entry = _slicedToArray(entry, 2),\n key = _entry[0],\n value = _entry[1];\n\n Assert(_typeof(key) !== 'object' && typeof key !== 'function' && _typeof(key) !== 'symbol', 'Key must not be of type object, function, or Symbol');\n Assert(_typeof(value) === 'symbol', 'Value must be a Symbol');\n obj.$_terms.map.set(key, value);\n symbols.push(value);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n return obj.valid.apply(obj, symbols);\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n obj = obj.map(desc.map);\n return obj;\n },\n // Errors\n messages: {\n 'symbol.base': '\"{{#label}}\" must be a symbol',\n 'symbol.map': '\"{{#label}}\" must be one of {{#map}}'\n }\n});" + "source": "'use strict';\n\nconst Assert = require('@hapi/hoek/lib/assert');\n\nconst Any = require('./any');\n\nconst internals = {};\ninternals.Map = class extends Map {\n slice() {\n return new internals.Map(this);\n }\n\n};\nmodule.exports = Any.extend({\n type: 'symbol',\n // Initialize\n initialize: function initialize(schema) {\n schema.$_terms.map = new internals.Map();\n },\n // Coerce\n coerce: {\n method: function method(schema, value, _ref) {\n let {\n error\n } = _ref;\n const lookup = schema.$_terms.map.get(value);\n\n if (lookup) {\n value = lookup;\n }\n\n if (!schema._flags.only || typeof value === 'symbol') {\n return {\n value\n };\n }\n\n return {\n value,\n errors: error('symbol.map', {\n map: schema.$_terms.map\n })\n };\n }\n },\n // Base validation\n validate: function validate(schema, value, _ref2) {\n let {\n error\n } = _ref2;\n\n if (typeof value !== 'symbol') {\n return {\n value,\n errors: error('symbol.base')\n };\n }\n },\n // Rules\n rules: {\n map: {\n method: function method(iterable) {\n if (iterable && !iterable[Symbol.iterator] && typeof iterable === 'object') {\n iterable = Object.entries(iterable);\n }\n\n Assert(iterable && iterable[Symbol.iterator], 'Iterable must be an iterable or object');\n const obj = this.clone();\n const symbols = [];\n\n for (const entry of iterable) {\n Assert(entry && entry[Symbol.iterator], 'Entry must be an iterable');\n const [key, value] = entry;\n Assert(typeof key !== 'object' && typeof key !== 'function' && typeof key !== 'symbol', 'Key must not be of type object, function, or Symbol');\n Assert(typeof value === 'symbol', 'Value must be a Symbol');\n obj.$_terms.map.set(key, value);\n symbols.push(value);\n }\n\n return obj.valid(...symbols);\n }\n }\n },\n // Build\n build: function build(obj, desc) {\n obj = obj.map(desc.map);\n return obj;\n },\n // Errors\n messages: {\n 'symbol.base': '\"{{#label}}\" must be a symbol',\n 'symbol.map': '\"{{#label}}\" must be one of {{#map}}'\n }\n});" }, { - "id": 53, + "id": 52, "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/null-loader/dist/cjs.js!/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/types/binary.js", "name": "../lib/types/binary.js", - "index": 53, - "index2": 52, + "index": 52, + "index2": 51, "size": 0, "cacheable": true, "built": true, @@ -9063,15 +8877,15 @@ "identifier": "/home/eran/code/hapijs/joi/browser/node_modules/babel-loader/lib/index.js??ref--5!/home/eran/code/hapijs/joi/lib/index.js", "name": "../lib/index.js", "profile": { - "factory": 32, - "building": 526 + "factory": 22, + "building": 288 } } ], "profile": { - "factory": 1165, - "building": 407, - "dependencies": 896 + "factory": 685, + "building": 313, + "dependencies": 588 }, "failed": false, "errors": 0, @@ -9085,7 +8899,7 @@ "moduleName": "../lib/index.js", "type": "cjs require", "userRequest": "./types/binary", - "loc": "54:27-52" + "loc": "40:27-52" } ], "usedExports": true, diff --git a/lib/types/object.js b/lib/types/object.js index 5ec8a244e..f03d7a823 100755 --- a/lib/types/object.js +++ b/lib/types/object.js @@ -205,30 +205,31 @@ module.exports = Any.extend({ }, assert: { - method: function (ref, schema, message) { + method: function (subject, schema, message) { - ref = Compile.ref(ref); - Assert(ref.type === 'global' || ref.depth > 1, 'Cannot use assertions for root level references - use direct key rules instead'); - message = message || 'pass the assertion test'; - Assert(typeof message === 'string', 'Message must be a string'); + if (!Template.isTemplate(subject)) { + subject = Compile.ref(subject); + Assert(subject.type === 'global' || subject.depth > 1, 'Cannot use assertions for root level references - use direct key rules instead'); + } + + Assert(message === undefined || typeof message === 'string', 'Message must be a string'); schema = this.$_compile(schema, { appendPath: true }); - const path = ref.path.join('.'); - const obj = this.$_addRule({ name: 'assert', args: { ref, schema, message }, path }); + const obj = this.$_addRule({ name: 'assert', args: { subject, schema, message } }); obj.$_mutateRegister(schema); return obj; }, - validate: function (value, { error, prefs, state }, { ref, schema, message }, { path }) { + validate: function (value, { error, prefs, state }, { subject, schema, message }) { const entryState = state.entry(schema, value); - if (schema.$_match(ref.resolve(null, { ancestors: [value, ...state.ancestors] }), entryState, prefs)) { + if (schema.$_match(subject.resolve(null, { ancestors: [value, ...state.ancestors] }), entryState, prefs)) { return value; } - return error('object.assert', { ref: path, message }); + return error('object.assert', { subject, message }); }, - args: ['ref', 'schema', 'message'], + args: ['subject', 'schema', 'message'], multi: true }, @@ -260,10 +261,10 @@ module.exports = Any.extend({ const obj = this.clone(); - if (!schema) { // Allow all + if (!schema) { // Allow all obj.$_terms.keys = null; } - else if (!Object.keys(schema).length) { // Allow none + else if (!Object.keys(schema).length) { // Allow none obj.$_terms.keys = []; } else { @@ -630,7 +631,7 @@ module.exports = Any.extend({ messages: { 'object.and': '"{{#label}}" contains {{#presentWithLabels}} without its required peers {{#missingWithLabels}}', - 'object.assert': '"{{#label}}" is invalid because "{{#ref}}" failed to {{#message}}', + 'object.assert': '"{{#label}}" is invalid because {if(#subject.key, `"` + #subject.key + `" failed to ` + (#message || "pass the assertion test"), #message || "the assertion failed")}', 'object.base': '"{{#label}}" must be of type {{#type}}', 'object.instance': '"{{#label}}" must be an instance of "{{#type}}"', 'object.length': '"{{#label}}" must have {{#limit}} keys', diff --git a/test/errors.js b/test/errors.js index 567c2ccc8..6393dfebe 100755 --- a/test/errors.js +++ b/test/errors.js @@ -987,12 +987,13 @@ describe('errors', () => { } }; + const ref = Joi.ref('options.stripUnknown'); const schema = Joi.object({ response: Joi.object({ modify: Joi.boolean(), options: Joi.object() }) - .assert('options.stripUnknown', Joi.ref('modify'), 'meet requirement of having peer modify set to true') + .assert(ref, Joi.ref('modify'), 'meet requirement of having peer modify set to true') }); const err = schema.validate(object, { abortEarly: false }).error; @@ -1002,7 +1003,7 @@ describe('errors', () => { path: ['response'], type: 'object.assert', context: { - ref: 'options.stripUnknown', + subject: ref, message: 'meet requirement of having peer modify set to true', label: 'response', key: 'response', diff --git a/test/ref.js b/test/ref.js index 3eec26d98..964e07273 100755 --- a/test/ref.js +++ b/test/ref.js @@ -1344,13 +1344,12 @@ describe('ref', () => { rules: [{ name: 'assert', args: { - message: 'pass the assertion test', schema: { type: 'any', flags: { only: true }, allow: [{ ref: { path: ['a', 'b'] } }] }, - ref: { path: ['a', 'b'] } + subject: { ref: { path: ['a', 'b'] } } } }], keys: { diff --git a/test/types/object.js b/test/types/object.js index 9803974b8..4fa149413 100755 --- a/test/types/object.js +++ b/test/types/object.js @@ -1015,9 +1015,9 @@ describe('object', () => { d: { e: Joi.any() } - }).assert(Joi.ref('d/e', { separator: '/' }), Joi.ref('a.c'), 'equal to a.c'); + }).assert(Joi.ref('d/e', { separator: '/' }), Joi.ref('a.c'), 'equal to a/c'); - expect(schema.validate({ a: { b: 'x', c: 5 }, d: { e: 6 } }).error).to.be.an.error('"value" is invalid because "d.e" failed to equal to a.c'); + expect(schema.validate({ a: { b: 'x', c: 5 }, d: { e: 6 } }).error).to.be.an.error('"value" is invalid because "d/e" failed to equal to a/c'); Helper.validate(schema, [ [{ a: { b: 'x', c: 5 }, d: { e: 5 } }, true] @@ -1026,6 +1026,7 @@ describe('object', () => { it('validates upwards reference with implicit context', () => { + const ref = Joi.ref('d.e'); const schema = Joi.object({ a: { b: Joi.string(), @@ -1034,7 +1035,7 @@ describe('object', () => { d: { e: Joi.any() } - }).assert('d.e', Joi.ref('a.c'), 'equal to a.c'); + }).assert(ref, Joi.ref('a.c'), 'equal to a.c'); const err = schema.validate({ a: { b: 'x', c: 5 }, d: { e: 6 } }).error; expect(err).to.be.an.error('"value" is invalid because "d.e" failed to equal to a.c'); @@ -1042,7 +1043,7 @@ describe('object', () => { message: '"value" is invalid because "d.e" failed to equal to a.c', path: [], type: 'object.assert', - context: { ref: 'd.e', message: 'equal to a.c', label: 'value', value: { a: { b: 'x', c: 5 }, d: { e: 6 } } } + context: { subject: ref, message: 'equal to a.c', label: 'value', value: { a: { b: 'x', c: 5 }, d: { e: 6 } } } }]); Helper.validate(schema, [ @@ -1084,6 +1085,7 @@ describe('object', () => { it('provides a default message for failed assertions', () => { + const ref = Joi.ref('d.e'); const schema = Joi.object({ a: { b: Joi.string(), @@ -1092,7 +1094,7 @@ describe('object', () => { d: { e: Joi.any() } - }).assert('d.e', Joi.boolean()); + }).assert(ref, Joi.boolean()); const err = schema.validate({ d: { e: [] } }).error; expect(err).to.be.an.error('"value" is invalid because "d.e" failed to pass the assertion test'); @@ -1101,8 +1103,8 @@ describe('object', () => { path: [], type: 'object.assert', context: { - ref: 'd.e', - message: 'pass the assertion test', + subject: ref, + message: undefined, label: 'value', value: { d: { e: [] } } } @@ -1119,6 +1121,41 @@ describe('object', () => { expect(schema.validate({ a: { b: 1 }, b: { c: 2 } }).error).to.not.exist(); }); + + it('uses templates', () => { + + const subject = Joi.x('{a || b || c}'); + const schema = Joi.object({ + a: Joi.boolean(), + b: Joi.boolean(), + c: Joi.boolean() + }) + .assert(subject, true, 'at least one key must be true'); + + expect(schema.validate().error).to.not.exist(); + expect(schema.validate({ a: false, b: true, c: true }).error).to.not.exist(); + + Helper.validate(schema, [ + [{ a: true, b: true, c: true }, true], + [{ a: true, b: false, c: false }, true], + [{ a: false, b: true, c: false }, true], + [{ a: false, b: false, c: true }, true], + [{ a: false, b: false, c: false }, false, null, { + message: '"value" is invalid because at least one key must be true', + details: [{ + message: '"value" is invalid because at least one key must be true', + path: [], + type: 'object.assert', + context: { + subject, + message: 'at least one key must be true', + label: 'value', + value: { a: false, b: false, c: false } + } + }] + }] + ]); + }); }); describe('cast()', () => {