A request authorization header validator for Joi.
use
joi-authorization-header
validates an object contains an
"authorization" property whose value is a string of the specified length, optionally
prefixed with "Bearer " or "bearer ". It's used just like you'd use
any other Joi
type.
var Joi = require('joi');
Joi.authHeader = require('joi-authorization-header')(Joi);
Joi.validate(request.headers, Joi.authHeader(64));
specifying value length
You must specify the length requirements of your authorization header value
or an Error will be thrown. It's easiest to explain by showing some examples:
var Joi = require('joi');
Joi.authHeader = require('joi-authorization-header')(Joi);
Joi.authHeader(64);
Joi.authHeader(2, 20);
The length validators do not include the optional "Bearer " value prefix.
Installation
npm install joi-authorization-header --save
Development
running tests
Pebble Technology!
License
MIT