| Crates.io | pval |
| lib.rs | pval |
| version | 0.1.1 |
| created_at | 2025-03-07 19:07:51.690836+00 |
| updated_at | 2025-03-07 19:14:43.091259+00 |
| description | A Rust library for password validation with customizable criteria. |
| homepage | https://github.com/91dns/pval |
| repository | https://github.com/91dns/pval |
| max_upload_size | |
| id | 1583515 |
| size | 10,470 |
Add pval to your Cargo.toml:
[dependencies]
pval = "0.1.0"
Or you can add it via the command line:
cargo add pval
Here's an example of how to use pval:
use pval::Pval;
fn main() -> Result<(), String> {
let validator = Pval::new()
.min_length(8)
.require_uppercase(true)
.require_lowercase(true)
.require_digit(true)
.require_special(true)
.build();
let password = "P@ssw0rd";
validator.validate(password)?;
println!("Password is valid.");
Ok(())
}
You can also load passwords from a file and validate them:
use pval::Pval;
use pval::utils::load_passwords;
fn main() -> Result<(), std::io::Error> {
let validator = Pval::new()
.min_length(8)
.require_uppercase(true)
.require_lowercase(true)
.require_digit(true)
.require_special(true)
.build();
let passwords = load_passwords("passwords.txt")?;
for password in passwords {
match validator.validate(&password) {
Ok(_) => println!("Password '{}' is valid.", password),
Err(e) => println!("Password '{}' is invalid: {}", password, e),
}
}
Ok(())
}
This project is licensed under the MIT License. See the LICENSE file for details.