joi-jwt
v1.0.1
Published
JWT Token validation rule for Joi
Downloads
30
Readme
joi-jwt
Lead Maintainer: Roman Rodomansky
Joi extensions for JWT Token rules.
Installation
yarn add joi-jwt --save
Usage
const JoiBase = require('joi');
const Joi = JoiBase.extend(require('joi-jwt'));
const schema = Joi.jwt().valid({secret: 'secret-key'}).required();
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaXRlIjoiaHR0cHM6Ly9yYWxhYnMub3JnIiwiaWF0IjoxNTU1Njk5Njg5fQ.1-YemibEH2bC7EqoQtG2naPRui0MP8Ma-Y5mAKYoJDU';
const result = schema.validate(token, { abortEarly: false });
console.log('result', result);