Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Simple JavaScript validation module
npm install correct
var correct = require('correct')
var fn = correct.string.min(1).max(12)
fn('abc') === true
fn('') === false
At any time, if you want to understand why you have a failing validation, you can use
var fn = correct.string.min(1).max(12)
fn.validate('')
// will return an object with {valid: false, errors: [...]} and the array of validations that did not pass
fn.validate('abc') //will return {valid: true}
For now there are only 3 base validation types available
Example:
var isInt = correct.int
isInt('5') == false
isInt(5.1) == false
isInt(5) == true
You can chain validation functions for all types (detailed below).
var intMax10 = correct.int.max(10)
intMax10(4) == true
intMax10(40) == false
NOTE: types are specified with simple dot access, while all other chained validations should be chained as function calls:
var validate = correct.string.max(10).not('hello word').required()
validate('my string') == true
var stringMin5 = correct.string.min(5)
stringMin5('abc') == false
stringMin5('abcde') == true
Available string tests:
Validates numbers.
var between10And100 = correct.number.min(10).max(100)
between10And100(40) == true
between10And100(4) == false
var even = correct.number.fn(function(v){
return v % 2 == 0
})
even(2) == true
var x = 67
even(x) == false
var isNumber = correct.number
isNumber(4.5) == true
isNumber('4.5') == false
Available number tests:
Inherits all the number tests, and adds some more
make
MIT
FAQs
Simple JavaScript validation module
The npm package correct receives a total of 4 weekly downloads. As such, correct popularity was classified as not popular.
We found that correct 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.