Skip to content

ALIasgharBalochi/passcheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” passcheck

passcheck is a flexible and lightweight password validation crate for Rust.
It allows you to define custom rules for checking password strength and structure β€” use only what you need!


πŸš€ Features

  • βœ… Rule-based validation system
  • βœ… Add only the checks you want: length, uppercase/lowercase, number, special char, etc.
  • βœ… Supports custom error messages per rule via Option<&str>
  • βœ… Lightweight and dependency-free
  • βœ… Easy to use and extend with a fluent API

πŸ“¦ Installation

Add this to your Cargo.toml:

[dependencies]
passcheck = "0.2.0"

🎯 Usage Example

use passcheck::PasswordChecker;

fn main() {
    let checker = PasswordChecker::new()
        .min_length(8, None)  // Use default error message with None OR use Some(str) for use custom message
        .require_upper_lower(None)
        .require_number(Some("Password must include at least one digit")) // Custom message
        .require_special_char(None);

    let password = "Ali@123";

    match checker.validate(password) {
        Ok(_) => println!("βœ… Strong password!"),
        Err(errors) => {
            println!("❌ Invalid password:");
            for err in errors {
                println!("  - {}", err);
            }
        }
    }
}

πŸ”§ Available Rules

min_length(n, Option<&str>) β†’ Requires password to be at least n characters

require_upper_lower(Option<&str>) β†’ Requires at least one uppercase and one lowercase letter

require_number(Option<&str>) β†’ Requires at least one digit

require_special_char(Option<&str>) β†’ Requires at least one special character


πŸ“„ License MIT

πŸ’» Author Made with ❀ + β˜• by Ali

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages