Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
joi - v17.4.0 Making the most powerful schema description language and data validator for JavaScript slightly more powerful.
Joi.string().escape()
&
, >
, <
, "
, '
, \
, /
and `
with HTML entities.Joi.string().unescape()
&
| >
| <
| "
| $
| /
| \
| `
HTML entities with characters.Joi.string().sanitize(function)
Joi.string().alpha()
Joi.string().numeric()
Joi.string().decimal(digit, decimal)
Joi.string().base32()
Joi.string().countryCode(type)
alpha-2
or ISO alpha-3
country code.Joi.string().password(policy)
Joi.string().match(reference)
Joi.string().contain(seed, [index])
$ npm i joi-plus
const Joi = require('joi-plus');
const schema = Joi.object({
username: Joi.string()
.min(8)
.max(20)
.alpha()
.required(),
email: Joi.string()
.email()
.required(),
password: Joi.string()
.password({
min: 8,
max: 120,
lowercase: true,
uppercase: true,
number: true,
special: true,
count: 3
})
.required(),
repeat_password: Joi.string()
.match('password')
.required(),
base32_encoded: Joi.string()
.base32()
.required(),
country: Joi.string()
.countryCode('alpha-2')
.required(),
contact_number: Joi.string()
.min(2)
.max(20)
.numeric()
.required(),
salary: Joi.string()
.decimal(11,2)
.required()
});
The above schema defines the following constraints:
username
email
password
repeat_password
password
base32_encoded
country
contact_number
salary
Using Joi.string().sanitize() with sanitization libraries such as sanitize-html
const sanitizeHtml = require('sanitize-html');
const schema = Joi.object({
escape: Joi.string()
.escape(),
unescape: Joi.string()
.unescape(),
sanitize: Joi.string()
.sanitize(sanitizeHtml)
});
const { error, value } = schema.validate({
escape: '<escape>',
unescape: '<unescape>',
sanitize: 'Hello,<script>evil()</script> I am Good.'
});
console.log(value);
/*
{
escape: '<escape>',
unescape: '<unescape>',
sanitize: 'Hello, I am Good.'
}
*/
1.4.0
Update joi to version 17.6.0 Added TypeScript support
FAQs
Joi with extra rules for string and array.
We found that joi-plus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.