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.
pre-post-validation
Advanced tools
simple javascript libaray for user input validation before POST request
This is a very simple to use javascript library for professionally validating the user input before POST
request for Login and Register.
fields include name, email, password, confirm_password
Name must be between 2 and 30 characters, Name required, Email required and is not invalid, Password required and must be at least 6 characters, Confirm Password field is required, Passwords must match.
Run npm install pre-post-validation
and then
const validateRegisterInput = require('pre-post-validation');
// or you can import like this
import { validateRegisterInput } from 'pre-post-validation';
const validateLoginInput = require('pre-post-validation');
// or you can import like this
import { validateRegisterInput } from 'pre-post-validation';
The functions are called with (data)
property which includes the user data.
and return errors
and isValid
.
const router = express.Router();
router.post('/register', (req, res) => {
const { errors, isValid } = validateRegisterInput(req.body);
if (!isValid) {
return res.status(400).json(errors);
}
else {
// add your logic after the validation passed.
}
}
router.post('/Login', (req, res) => {
const { errors, isValid } = validateLoginInput(data);
if (!isValid) {
return res.status(400).json(errors);
}
else {
// add your logic after the validation passed.
}
}
Every time you call this function you have to do some destructuring by taking out const { errors, isValid }
and check isValid
property for validation.
FAQs
simple javascript libaray for user input validation before POST request
The npm package pre-post-validation receives a total of 1 weekly downloads. As such, pre-post-validation popularity was classified as not popular.
We found that pre-post-validation 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.