Skip to content

natedev-launchcode/practice-password-validator-Nathan-A

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

practice-password-validator-Nathan-A

A small command-line password validator written in Node.js.

What it does

Prompts the user for a password and keeps asking until the input satisfies all of the following rules:

  • At least 8 characters long
  • Contains at least one uppercase letter (AZ)
  • Contains at least one number (09)

Validation is done character-by-character inside a for loop, driven by a do...while so the prompt always runs at least once. When the input passes, the program prints Password accepted. and exits.

Requirements

  • Node.js (any modern LTS version)
  • npm (ships with Node)

Install

npm install

This pulls in the single dependency, readline-sync, which provides synchronous terminal input.

Run

node index.js

You will be prompted:

Enter a password:

Type a password and press Enter. If it fails any rule, the program lists which rules failed and prompts again. On success it prints Password accepted. and exits.

Example session

Enter a password: hello
Password does not meet the requirements. Try again.
 - Must be at least 8 characters long.
 - Must contain at least one uppercase letter.
 - Must contain at least one number.
Enter a password: password1
Password does not meet the requirements. Try again.
 - Must contain at least one uppercase letter.
Enter a password: Hunter22
Password accepted.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors