Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

created password validator #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions validators/password.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const dry = require('drytypes')

module.exports = dry.makeDryType((x) => {
if (x.length==0) {
return { success: false, message: 'password cannot be set empty' }
}
if(x.length>30){
return {success:false,message:'password length must be less than 30'}
}
let passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
if (!x.match(passwordRegex)) {
return { success: false, message: 'password must contain an uppercase letter , a lower case letter , a special character and a number' }
}

return { success: true }

}, 'Password')