completed implementation of validation function

This commit is contained in:
2026-04-23 08:27:51 -04:00
parent 2e2bb6b89e
commit 5b81562650
+36
View File
@@ -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
}