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.
Validator functions for many types of input, intended for use with express
The library provides a number of battle tested validation functions. Each returns the
value supplied or a defaultValue
. Mostly, you can leave defaultValue
empty, which
will cause purify to return undefined
in case the value doesn't pass validation.
The library can be installed by simply installing purify
from npm and can be used
body on node with require('purify')
or as a self-contained UMD browser bundle that
can be used directly in a script tag as follows:
<script src="./node_modules/lib/purify.js">
var app = express(),
purify = require('purify');
app.get('/:userId', function (req, res, next) {
var userId = purify.positiveInteger(req.param('userId')),
force = purify.boolean(req.param('force'), true);
if (userId) {
// ...
} else {
res.send(400);
}
});
.email(rawValue, defaultValue)
.emailIdn(rawValue, defaultValue)
- Returns e-mail with non-punycoded form regardless of input.
.domainName(rawValue, defaultValue)
.domainNameIdn(rawValue, defaultValue)
- Returns domain in non-punycoded form regardless of input.
.url(rawValue, defaultValue)
.urlWithLocalhost(rawValue, defaultValue)
.integer(rawValue, defaultValue)
.integerInRange(rawValue, lower, upper, defaultValue)
.positiveInteger(rawValue, defaultValue)
.positiveIntegerOrZero(rawValue, defaultValue)
.float(rawValue, defaultValue)
.positiveFloat(rawValue, defaultValue)
.positiveFloatOrZero(rawValue, defaultValue)
.nonEmptyVisibleUnicode(rawValue, defaultValue)
.visibleUnicode(rawValue, defaultValue)
.nonEmptyPrintableUnicode(rawValue, defaultValue)
.printableUnicode(rawValue, defaultValue)
.nonEmptyVisibleAscii(rawValue, defaultValue)
.visibleAscii(rawValue, defaultValue)
.nonEmptyPrintableAscii(rawValue, defaultValue)
.printableAscii(rawValue, defaultValue)
.alphaNumeric(rawValue, defaultValue)
.nonEmptyAlphaNumeric(rawValue, defaultValue)
.alphaNumericWithDot(rawValue, defaultValue)
.uuid(rawValue, defaultValue)
.upperCaseUuid(rawValue, defaultValue)
.lowerCaseUuid(rawValue, defaultValue)
.json(rawValue, defaultValue)
FAQs
Validator functions for many types of input, intended for use with express
We found that purify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers 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.