diff --git a/lib/validate.js b/lib/validate.js index fb6d622..60e73ac 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -8,20 +8,17 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of this Source Code Form. */ -const Joi = require('@hapi/joi'); - -const { number, object, string } = Joi.types(); +const { partial, number, string, validate } = require('superstruct'); module.exports = { validate(options) { - const keys = { - blockSize: number, - bytes: number, - name: string - }; - const schema = object.keys(keys); - const results = schema.validate(options); + const schema = partial({ + blockSize: number(), + bytes: number(), + name: string() + }); + const [error] = validate(options, schema); - return results; + return { error }; } }; diff --git a/package-lock.json b/package-lock.json index e06e482..7a30fbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -537,49 +537,6 @@ "arrify": "^1.0.1" } }, - "@hapi/address": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@hapi/address/-/address-4.0.1.tgz", - "integrity": "sha512-0oEP5UiyV4f3d6cBL8F3Z5S7iWSX39Knnl0lY8i+6gfmmIBj44JCBNtcMgwyS+5v7j3VYavNay0NFHDS+UGQcw==", - "requires": { - "@hapi/hoek": "^9.0.0" - } - }, - "@hapi/formula": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@hapi/formula/-/formula-2.0.0.tgz", - "integrity": "sha512-V87P8fv7PI0LH7LiVi8Lkf3x+KCO7pQozXRssAHNXXL9L1K+uyu4XypLXwxqVDKgyQai6qj3/KteNlrqDx4W5A==" - }, - "@hapi/hoek": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.0.4.tgz", - "integrity": "sha512-EwaJS7RjoXUZ2cXXKZZxZqieGtc7RbvQhUy8FwDoMQtxWVi14tFjeFCYPZAM1mBCpOpiBpyaZbb9NeHc7eGKgw==" - }, - "@hapi/joi": { - "version": "17.1.1", - "resolved": "https://registry.npmjs.org/@hapi/joi/-/joi-17.1.1.tgz", - "integrity": "sha512-p4DKeZAoeZW4g3u7ZeRo+vCDuSDgSvtsB/NpfjXEHTUjSeINAi/RrVOWiVQ1isaoLzMvFEhe8n5065mQq1AdQg==", - "requires": { - "@hapi/address": "^4.0.1", - "@hapi/formula": "^2.0.0", - "@hapi/hoek": "^9.0.0", - "@hapi/pinpoint": "^2.0.0", - "@hapi/topo": "^5.0.0" - } - }, - "@hapi/pinpoint": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@hapi/pinpoint/-/pinpoint-2.0.0.tgz", - "integrity": "sha512-vzXR5MY7n4XeIvLpfl3HtE3coZYO4raKXW766R6DZw/6aLqR26iuZ109K7a0NtF2Db0jxqh7xz2AxkUwpUFybw==" - }, - "@hapi/topo": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.0.0.tgz", - "integrity": "sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw==", - "requires": { - "@hapi/hoek": "^9.0.0" - } - }, "@nodelib/fs.scandir": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", @@ -8383,6 +8340,11 @@ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true }, + "superstruct": { + "version": "0.10.12", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.10.12.tgz", + "integrity": "sha512-FiNhfegyytDI0QxrrEoeGknFM28SnoHqCBpkWewUm8jRNj74NVxLpiiePvkOo41Ze/aKMSHa/twWjNF81mKaQQ==" + }, "supertap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supertap/-/supertap-1.0.0.tgz", diff --git a/package.json b/package.json index 8d296bd..82e70c4 100644 --- a/package.json +++ b/package.json @@ -33,9 +33,9 @@ "webpack": "^4.20.0" }, "dependencies": { - "@hapi/joi": "^17.1.1", "chalk": "^4.1.0", - "execa": "^4.0.3" + "execa": "^4.0.3", + "superstruct": "^0.10.12" }, "devDependencies": { "@commitlint/cli": "^11.0.0",