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.
object-key-validator
Advanced tools
check objects for the existence of certain keys
validateKeys
(rule: Rule, obj: Object) => boolean
Accepts a rule definition and a test object. If the rule definition is invalid, the validation function will throw.
There are three rule types: $and
, $or
, and $not
. Rules can be nested (as shown below).
$and
Checks an array of rules. If all of the rules pass, validation returns true.
Examples
// checks to make sure an object has BOTH `a` AND `b` keys
// logically: (a && b)
{ $and: ['a', 'b'] }
// checks to make sure an object has `a`, `b`, AND `c` keys
// logically: (a && (b && c))
{
$and: [
'a',
{ $and: ['b', 'c']}
]
}
$or
Checks an array of rules. If one or more of the rules pass, validation returns true.
Examples
// checks to make sure an object has EITHER `a` OR `b` keys
// logically: (a || b)
{ $or: ['a', 'b'] }
// checks to make sure an object has either an `a` key OR a `b` AND `c` key
// logically: (a || (b && c))
{
$or: [
'a',
{ $and: ['b', 'c']}
]
}
$not
Inverts the response value of a single rule. $not
does not accept an array of conditions like $and
and $or
.
Examples
// checks to make sure an object doesn't have EITHER `a` OR `b` keys
// logically: !(a || b)
{ $not: { $or: ['a', 'b'] } }
// checks to make sure an object doesn't have either an `a` key OR a `b` AND `c` key
// logically: !(a || (b && c))
{
$not: {
$or: [
'a',
{ $and: ['b', 'c']}
]
}
}
FAQs
check objects for the existence of certain keys
The npm package object-key-validator receives a total of 22 weekly downloads. As such, object-key-validator popularity was classified as not popular.
We found that object-key-validator 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.