Have ideas to improve npm?Join in the discussion! »

@puzzleframework/joi-xss

1.0.0 • Public • Published

joi-xss

Avoid XSS with the help of Joi validator

Example

const xss = require('@puzzleframework/joi-xss');
const Joi = require('@hapi/joi').extend(xss('object'), xss('array'), xss('string'));
  
const input = { name: "<p>hola</p>" };
 
// Return result.
const { value } = Joi.object().unknown(true).xss().validate(input);
//  value.name === '&lt;p&gt;hola&lt;/p&gt;'
 
// You can also pass options.
const { value } = Joi.object().unknown(true).xss({ stripIgnoreTag: true }).validate(input);
//  value.name === 'hola'
 

Keywords

none

Install

npm i @puzzleframework/joi-xss

DownloadsWeekly Downloads

5

Version

1.0.0

License

MIT

Unpacked Size

11.4 kB

Total Files

15

Last publish

Collaborators

  • avatar