diff --git a/index.js b/index.js index ceae147..b95dfa0 100644 --- a/index.js +++ b/index.js @@ -16,16 +16,16 @@ const Relish = function Relish (opts) { this.parseError = (error) => { return error.data.details.map((i) => { let err = { - key: i.path.split('.').pop(), - path: i.path, + key: i.context.key, + path: i.path.join('.'), message: this._opts.stripQuotes ? i.message.replace(/"/g, '') : i.message, type: i.type.split('.').shift(), constraint: i.type.split('.').pop() } // if label is different than key, provide label - if (i.context.key !== err.key) { - err.label = i.context.key + if (i.context.label !== err.key) { + err.label = i.context.label } // set custom message (if exists) diff --git a/package-lock.json b/package-lock.json index 4b69e6a..fd4b2ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -378,6 +378,18 @@ "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true + }, + "joi": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/joi/-/joi-10.6.0.tgz", + "integrity": "sha512-hBF3LcqyAid+9X/pwg+eXjD2QBZI5eXnBFJYaAkH4SK3mp9QSRiiQnDYlmlz5pccMvnLcJRS4whhDOTCkmsAdQ==", + "dev": true, + "requires": { + "hoek": "4.2.1", + "isemail": "2.2.1", + "items": "2.1.1", + "topo": "2.0.2" + } } } }, @@ -1196,9 +1208,9 @@ } }, "hapi": { - "version": "16.6.0", - "resolved": "https://registry.npmjs.org/hapi/-/hapi-16.6.0.tgz", - "integrity": "sha512-8vZTMod1To1hpu8IowRe1aRGq2VqpgGt1rfgk4gydaXjDxCnyNDc9N0iOjiKCxntCA1Wt2//REk4OxuY/LHI5w==", + "version": "16.6.3", + "resolved": "https://registry.npmjs.org/hapi/-/hapi-16.6.3.tgz", + "integrity": "sha512-Fe1EtSlRWdez9c1sLDrHZYxpsp3IddwtUWp7y65TCBW5CMcBP98X4WnoBJZTGsDZnk/FDkRyEMhUVsC9qysDPg==", "dev": true, "requires": { "accept": "2.1.4", @@ -1212,7 +1224,7 @@ "hoek": "4.2.1", "iron": "4.0.5", "items": "2.1.1", - "joi": "10.6.0", + "joi": "11.4.0", "mimos": "3.0.3", "podium": "1.3.0", "shot": "3.4.2", @@ -1244,6 +1256,32 @@ "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true + }, + "isemail": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/isemail/-/isemail-3.1.2.tgz", + "integrity": "sha512-zfRhJn9rFSGhzU5tGZqepRSAj3+g6oTOHxMGGriWNJZzyLPUK8H7VHpqKntegnW8KLyGA9zwuNaCoopl40LTpg==", + "dev": true, + "requires": { + "punycode": "2.1.0" + } + }, + "joi": { + "version": "11.4.0", + "resolved": "https://registry.npmjs.org/joi/-/joi-11.4.0.tgz", + "integrity": "sha512-O7Uw+w/zEWgbL6OcHbyACKSj0PkQeUgmehdoXVSxt92QFCq4+1390Rwh5moI2K/OgC7D8RHRZqHZxT2husMJHA==", + "dev": true, + "requires": { + "hoek": "4.2.1", + "isemail": "3.1.2", + "topo": "2.0.2" + } + }, + "punycode": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz", + "integrity": "sha1-X4Y+3Im5bbCQdLrXlHvwkFbKTn0=", + "dev": true } } }, @@ -1337,6 +1375,18 @@ "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true + }, + "joi": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/joi/-/joi-10.6.0.tgz", + "integrity": "sha512-hBF3LcqyAid+9X/pwg+eXjD2QBZI5eXnBFJYaAkH4SK3mp9QSRiiQnDYlmlz5pccMvnLcJRS4whhDOTCkmsAdQ==", + "dev": true, + "requires": { + "hoek": "4.2.1", + "isemail": "2.2.1", + "items": "2.1.1", + "topo": "2.0.2" + } } } }, @@ -1577,22 +1627,39 @@ "dev": true }, "joi": { - "version": "10.6.0", - "resolved": "https://registry.npmjs.org/joi/-/joi-10.6.0.tgz", - "integrity": "sha512-hBF3LcqyAid+9X/pwg+eXjD2QBZI5eXnBFJYaAkH4SK3mp9QSRiiQnDYlmlz5pccMvnLcJRS4whhDOTCkmsAdQ==", + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/joi/-/joi-13.1.2.tgz", + "integrity": "sha512-bZZSQYW5lPXenOfENvgCBPb9+H6E6MeNWcMtikI04fKphj5tvFL9TOb+H2apJzbCrRw/jebjTH8z6IHLpBytGg==", "dev": true, "requires": { - "hoek": "4.2.1", - "isemail": "2.2.1", - "items": "2.1.1", - "topo": "2.0.2" + "hoek": "5.0.3", + "isemail": "3.1.2", + "topo": "3.0.0" }, "dependencies": { - "hoek": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", + "isemail": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/isemail/-/isemail-3.1.2.tgz", + "integrity": "sha512-zfRhJn9rFSGhzU5tGZqepRSAj3+g6oTOHxMGGriWNJZzyLPUK8H7VHpqKntegnW8KLyGA9zwuNaCoopl40LTpg==", + "dev": true, + "requires": { + "punycode": "2.1.0" + } + }, + "punycode": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz", + "integrity": "sha1-X4Y+3Im5bbCQdLrXlHvwkFbKTn0=", "dev": true + }, + "topo": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/topo/-/topo-3.0.0.tgz", + "integrity": "sha512-Tlu1fGlR90iCdIPURqPiufqAlCZYzLjHYVVbcFWDMcX7+tK8hdZWAfsMrD/pBul9jqHHwFjNdf1WaxA9vTRRhw==", + "dev": true, + "requires": { + "hoek": "5.0.3" + } } } }, @@ -2121,6 +2188,18 @@ "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true + }, + "joi": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/joi/-/joi-10.6.0.tgz", + "integrity": "sha512-hBF3LcqyAid+9X/pwg+eXjD2QBZI5eXnBFJYaAkH4SK3mp9QSRiiQnDYlmlz5pccMvnLcJRS4whhDOTCkmsAdQ==", + "dev": true, + "requires": { + "hoek": "4.2.1", + "isemail": "2.2.1", + "items": "2.1.1", + "topo": "2.0.2" + } } } }, @@ -2385,6 +2464,18 @@ "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true + }, + "joi": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/joi/-/joi-10.6.0.tgz", + "integrity": "sha512-hBF3LcqyAid+9X/pwg+eXjD2QBZI5eXnBFJYaAkH4SK3mp9QSRiiQnDYlmlz5pccMvnLcJRS4whhDOTCkmsAdQ==", + "dev": true, + "requires": { + "hoek": "4.2.1", + "isemail": "2.2.1", + "items": "2.1.1", + "topo": "2.0.2" + } } } }, @@ -2617,6 +2708,18 @@ "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true + }, + "joi": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/joi/-/joi-10.6.0.tgz", + "integrity": "sha512-hBF3LcqyAid+9X/pwg+eXjD2QBZI5eXnBFJYaAkH4SK3mp9QSRiiQnDYlmlz5pccMvnLcJRS4whhDOTCkmsAdQ==", + "dev": true, + "requires": { + "hoek": "4.2.1", + "isemail": "2.2.1", + "items": "2.1.1", + "topo": "2.0.2" + } } } }, diff --git a/package.json b/package.json index 87bddc3..6413bfe 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,10 @@ "engines": { "node": ">= 6.0.0" }, + "peerDependencies": { + "hapi": ">= 16.6.1 < 17", + "joi": ">= 11" + }, "author": "Dialexa", "contributors": [ "Andrew Turner " @@ -42,15 +46,11 @@ "devDependencies": { "code": "~3.0.2", "coveralls": "~2.11.12", - "hapi": "16.6.0", - "joi": "~10.6.0", + "hapi": "~16.6.2", + "joi": "~13.1.1", "lab": "~10.9.0", "markdown-toc": "~0.12.16", "snazzy": "~4.0.0", "standard": "~7.1.2" - }, - "peerDependencies": { - "hapi": "<= 16.6.0", - "joi": "< 11" } }