
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Note: Strings only!
This module simplifies validation that requires regular expressions or multiple steps. It will not include anything that is already simple to calculate and reason about, such as string length.
npm install --save s-valid
var valid = require('s-valid');
// simple validation
if (valid.email('email@test.com')) {
// ...
}
// primary use case: server-side form validation
if (!valid.email(req.body.email)) {
// return error...
}
Use it modularly if you prefer
var email = require('s-valid/email');
if (email('email@test.com')) {
// ...
}
valid.affirmative('yes'); // true
valid.affirmative('y'); // true
valid.affirmative('on'); // true
valid.affirmative('true'); // true
valid.negatory('no'); // true
valid.negatory('n'); // true
valid.negatory('off'); // true
valid.negatory('false'); // true
valid.alpha('Foo'); // true
valid.alpha('Foo bar'); // false
valid.alpha('Test123'); // false
valid.numeric('123'); // true
valid.numeric('-123'); // true
valid.numeric('123px'); // false
valid.numeric('$123000'); // false
valid.alphaNumeric('Test123'); // true
valid.alphaNumeric('Tést'); // false
valid.alphaNumeric('Test 123'); // false
valid.alphaNumeric('Test_123'); // false
valid.alphaNumeric('Test-123'); // false
Note: valid.creditCard()
is an alias for valid.card.generic()
valid.creditCard('4242424242424242'); // true (matches Visa regexp)
valid.creditCard('5610591081018250'); // true with no regexp match (Australian Bankcard)
valid.creditCard('1234123412341234'); // false
amex
)carteBlanche
)dinersClub
)discover
)jcb
)lasercard
)maestro
)mastercard
)solo
)unionpay
)visa
)valid.card.amex('371449635398431'); // true
valid.card.amex('4242424242424242'); // false (is Visa)
valid.email('email@test.com'); // true
valid.email('email@test'); // false
valid.socialSecurity('078-05-1120'); // true (from Wikipedia)
valid.socialSecurity('078-00-1120'); //false
valid.socialSecurity('078051120'); // false
Similar to numeric
, but less restrictive. Passes for $ (or any non-number first character), commas, and units (such as 12px or 38BTC)
valid.value('123'); // true
valid.value('-123'); // true
valid.value('#000000'); // true
valid.value('123px'); // true
valid.value('$123,000.00'); // true
valid.value('test'); // false
valid.value('Infinity'); // false
valid.url('http://test.com'); // true
valid.url('https://test.com'); // true
valid.url('https://test.com:3000'); // true -- works with port numbers
valid.url('http://4.35.153.221'); // true -- IP addresses are valid URLs
valid.url('http://300.35.153.221'); // false -- invalid IP addresses fail
valid.url('http:/test.com'); // false
valid.zipCode('89052'); // true
valid.zipCode('89052-6589'); // false
valid.zipCode('890526589'); // false
Additional 4-digit code is optional and must be separated by a hyphen
valid.zipCodeLong('89052'); // true
valid.zipCodeLong('89052-6589'); // true
valid.zipCodeLong('890526589'); // false
is.js provided some of the regular expressions used behind-the-scenes, however the following improvements have been made to them:
FAQs
Simple validator for strings
The npm package s-valid receives a total of 46 weekly downloads. As such, s-valid popularity was classified as not popular.
We found that s-valid 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
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.