Skip to content

Commit

Permalink
upgrade to use the latest lab and joi to validate
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydbenson committed Aug 3, 2020
1 parent 402967b commit 770c28d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ const Stream = require('stream');
const Boom = require('@hapi/boom');
const Cryptiles = require('@hapi/cryptiles');
const Hoek = require('@hapi/hoek');
const Joi = require('@hapi/joi');
const Validate = require('@hapi/validate');


const internals = {
restfulValidatedMethods: ['post', 'put', 'patch', 'delete']
};


internals.schema = Joi.object().keys({
key: Joi.string().optional(),
size: Joi.number().optional(),
autoGenerate: Joi.boolean().optional(),
addToViewContext: Joi.boolean().optional(),
cookieOptions: Joi.object().keys(null),
headerName: Joi.string().optional(),
restful: Joi.boolean().optional(),
skip: Joi.func().optional(),
enforce: Joi.boolean().optional(),
logUnauthorized: Joi.boolean().optional()
internals.schema = Validate.object().keys({
key: Validate.string().optional(),
size: Validate.number().optional(),
autoGenerate: Validate.boolean().optional(),
addToViewContext: Validate.boolean().optional(),
cookieOptions: Validate.object().keys(null),
headerName: Validate.string().optional(),
restful: Validate.boolean().optional(),
skip: Validate.func().optional(),
enforce: Validate.boolean().optional(),
logUnauthorized: Validate.boolean().optional()
});


Expand Down Expand Up @@ -51,7 +51,7 @@ exports.plugin = {

register: function (server, options) {

Joi.assert(options, internals.schema);
Validate.assert(options, internals.schema);

const settings = Hoek.applyToDefaults(internals.defaults, options);

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"@hapi/boom": "9.x.x",
"@hapi/cryptiles": "5.x.x",
"@hapi/hoek": "9.x.x",
"@hapi/joi": "17.x.x"
"@hapi/validate": "1.x.x"
},
"devDependencies": {
"@hapi/code": "8.x.x",
"@hapi/hapi": "19.x.x",
"@hapi/lab": "22.x.x",
"@hapi/lab": "23.x.x",
"@hapi/vision": "6.x.x",
"handlebars": "4.x.x"
},
Expand Down

0 comments on commit 770c28d

Please sign in to comment.