From 5b81562650542709d8285e187c750a370bda404c Mon Sep 17 00:00:00 2001 From: Ed Guloien Date: Thu, 23 Apr 2026 08:27:51 -0400 Subject: [PATCH] completed implementation of validation function --- src/main.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/main.rs b/src/main.rs index a495463..df06cad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,6 +44,42 @@ fn validate_password(password: &str, policy: &PasswordPolicy) -> bool { return false; } } + if policy.0.charset.contains(CharSet::LOWERCASE) { + let mut found_lower = false; + for c in password.chars() { + if LOWERCASE_CHARS.contains(&(c as u8)) { + found_lower = true; + break; + } + } + if !found_lower { + return false; + } + } + if policy.0.charset.contains(CharSet::NUMBERS) { + let mut found_number = false; + for c in password.chars() { + if NUMBER_CHARS.contains(&(c as u8)) { + found_number = true; + break; + } + } + if !found_number { + return false; + } + } + if policy.0.charset.contains(CharSet::SYMBOLS) { + let mut found_symbol = false; + for c in password.chars() { + if SYMBOL_CHARS.contains(&(c as u8)) { + found_symbol = true; + break; + } + } + if !found_symbol { + return false; + } + } // todo: do similar checks here true }