Created
July 22, 2019 17:16
-
-
Save kwiss/b5ea487d87bf78370be58d5bbb216944 to your computer and use it in GitHub Desktop.
express validator password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { check } from 'express-validator/check'; | |
app.post('/testPostPassword', [ | |
check('password') | |
.exists() | |
.withMessage('Password should not be empty, minimum eight characters, at least one letter, one number and one special character') | |
.isLength({ min: 8 }) | |
.withMessage('Password should not be empty, minimum eight characters, at least one letter, one number and one special character') | |
.matches(/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/) | |
.withMessage('Password should not be empty, minimum eight characters, at least one letter, one number and one special character') | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment