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.
validator-runner
Advanced tools
async form validator runner
yarn add validator-runner
import Validator from 'validator-runner';
const schema = {
name: [
{
validator: name => name,
message: 'Please input something!',
},
{
validator(name) {
return new Promise((res, rej) => {
setTimeout(() => {
name === 'loading' ? res(name) : rej(name);
}, 0);
});
},
message: name => `"${name}" is not my name!`,
},
],
birth: {
validator(date) {
return date === '1995';
},
message: 'Wrong Date!',
},
};
const validator = new Validator(schema);
validator.validateItem({ name: 'loading' }, 'name').then(data => {
// data:
// errors: an array of errors
// rule: the validation object that executed last
});
// or
validator.validateItem({ name: 'loading' }, 'name', (errors, data) => {
// errors: an array of errors
// data:
// errors: an array of errors
// rule: the validation object that executed last
});
⚠️⚠️⚠️
Note: All sync validators will be transformed to promises internally.
new Validator(schema, options)
option.first
default: true
. If true, every field will not stop validation at first failed rule
option.retention
default: false
. If true, the last pending validation will be not covered when a new validation begins
option.concurrent
default: false
. if true, all validator will be executed at the same time
validateItem(source, fieldName, callback})
object
The data to validatestring
The name of field to validatefunction(errors, data)
FAQs
Validate form asynchronous
We found that validator-runner 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.