Skip to main content

validate_password

Function validate_password 

Source
pub fn validate_password(password: &str) -> PasswordValidation
Expand description

Validate a password and return strength assessment with suggestions.

§Algorithm

  1. Check for presence of lowercase, uppercase, digits, and special characters
  2. Compute length score: 0 (0-7), 1 (8-11), 2 (12-15), 3 (16+)
  3. Sum all criteria to get score (0-7)
  4. Map score to strength level

§Example

use coding_agent_search::pages::password::{PasswordStrength, validate_password};

let result = validate_password("MySecureP@ssw0rd!");
assert_eq!(result.strength, PasswordStrength::Strong);
assert!(result.suggestions.is_empty());