1.0.0 • Published 4 years ago
@puzzleframework/joi-xss v1.0.0
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 === '<p>hola</p>'
// You can also pass options.
const { value } = Joi.object().unknown(true).xss({ stripIgnoreTag: true }).validate(input);
// value.name === 'hola'
1.0.0
4 years ago