Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
checker-factory
Advanced tools
Checker Factory used by Deku Prop Type Validators
npm install --save checker-factory
import checkerFactory from 'checker-factory'
const numberChecker = checkerFactory('number')
numberChecker.validate('hello', 'age')
// => TypeError: Expected age to be of type `number`, but got `string`
numberChecker.validate(3, 'age')
// => undefined
const requiredString = checkerFactory('string').isRequired
requiredString.validate(undefined, 'name')
// => Error: name is required
const evenNumberChecker = checkerFactory((prop, key) => {
if (prop % 2 === 1) {
return new Error(`Expected ${key} to be an even number`)
}
})
evenNumberChecker.validate(3, 'id')
// => Error: Expected id to be an even number
const checkerWithName = checkerFactory('number', 'dog')
checkerWithName.name
// => 'dog'
Returns a CheckerFactory with an isRequired
getter and validate
function.
type: function
| string
If validator
is a string
, then a typeof
check will be performed. If validator
is a function
, then the function will be execution. The function is passed the prop
value and the key
name.
type: string
This is an optional value to retrieve a name for the checker factory.
MIT © Dustin Specker
FAQs
Checker Factory used by Deku Prop Type Validators
The npm package checker-factory receives a total of 1 weekly downloads. As such, checker-factory popularity was classified as not popular.
We found that checker-factory 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.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.