
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Satpam is a wrapper for some nodejs validator libraries, I made Satpam
so it's easy to create
custom validator with parameters and custom validation messages.
var satpam = require('satpam');
var rules = {
name : ['required']
officeEmail : ['email'],
phone : ['required', 'numeric']
};
var input = {
name: 'Sendy',
title: 'Lord',
officeEmail: 'invalid email',
phone: 'hi there123'
};
var result = satpam.validate(rules, input);
if (result.success === true) {
// valid
} else {
// invalid
result.messages.officeEmail.email === 'OfficeEmail must be email';
result.messages.phone.number === 'Phone must be numeric';
// or get all messages in array form
result.messages.messageArray[0] = 'OfficeEmail must be email';
result.messages.messageArray[1] = 'Phone must be numeric';
}
Satpam has create
method to create new validator instance.
var satpam = require('satpam');
var validatorOne = satpam.create();
var validatorTwo = satpam.create();
required
numeric
email
image
alpha
alphanumeric
date
dateFormat:<format, e.g. DD-MM-YYYY>
dateAfter:<the date input format, e.g. DD-MM-YYYY>:<date after e.g. 'now' or 20-1-2015>:<offset>:<unit of time e.g. 'days'>
dateBefore:<the date input format, e.g. DD-MM-YYYY>:<date after e.g. 'now' or 20-1-2015>:<offset>:<unit of time e.g. 'days'>
url
string
nonBlank
creditCard
phoneNumber
(Currently only supports Indonesia phone number)
mobilePhoneNumber
(Currently only supports Indonesia mobile phone number)
maxLength:<length>
minLength:<length>
maxValue:<max value>
minValue:<min value>
memberOf:$1
equal:$1
notEqual:$1
requiredIf:$1:$2
var input = {message: 'hi!'};
// `subject` is required if message equals `hi!`
satpam.validate({subject: 'requiredIf:message:hi!'});
taxId:$1
Currently only support indonesian tax id e.g. taxId:id
Use object notation for defining this rule examples
beginWith:$1
Use object notation for defining this rule examples
regex:$1:$2
$1
is the pattern, $2
is the regex flags
examples
Add custom rules globally, it will affect every Validator
instance(s) that
is created after the custom rules addition, but not the old instance(s).
var satpam = require('satpam');
// oldValidator will not have `must-be-ironman` rule, because it's created
// before we add the custom validation.
var oldValidator = satpam.create();
// The global satpam validator will always the most updated validation rules.
// After this statement, we can do satpam.validate({name: ['must-be-ironman']}, ...);
satpam.addCustomValidation('must-be-ironman', function(val) {
return val === 'ironman';
});
satpam.setValidationMessage('must-be-ironman', 'Not ironman D:');
// With parameters
satpam.addCustomValidation('range:$1:$2', function(val, ruleObj) {
return val >= ruleObj.params[0] && val <= ruleObj.params[1];
});
// If validation fails it will set message to:
// "PropertyName must between 0 and 30"
satpam.setValidationMessage('range:$1:$2', '<%= propertyName %> must between <%= ruleParams[0] %> and <%= ruleParams[1] %>');
// newValidator will have `must-be-ironman` rule because it's created
// after we add the custom validation.
var newValidator = satpam.create();
FAQs
Simple and Effective Object Validator
The npm package satpam receives a total of 858 weekly downloads. As such, satpam popularity was classified as not popular.
We found that satpam demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.