I'm trying to do validation test by using express-validator.
so far everything is working good except isStrongPassword()
import {check} from "express-validator"
const val =
check('pwd')
.exists()
.withMessage('please enter the password')
.isStrongPassword({minLength: 6})
.withMessage('password is must be above six letters')
Router.post('/signup',val,SignUp)
const SignUp = async(req,res) => {
// if email and password are invalid throw the errors
const errors = validationResult(req).array();
if (errors && errors.length) {
console.log(errors);
res.status(400).json({ errors });
my code is like that .but when I request password 1 letter or 7 letters regardless It just call error. It seems to be doesn`t work anybody who knows why it happened? Thank you for your attention
isStrongPassword has default values
Either you override the other properties with 0 or just follow the default values.
IMHO, a strong password should respect the combination of lower case, upper case, number, and special character, not only the minimal length.
I hope this answers your problem.