idfy_common/utils/
validation.rs1pub fn check_email(email: &str) -> bool {
2 email.contains('@') && email.split('@').all(|part| !part.is_empty())
3 }
5
6pub fn check_pin(number: &str) -> bool {
7 let number = number.trim();
8 let length = number.len();
9
10 if length <= 6 && length >= 4 && number[0..].chars().all(|c| c.is_digit(10)) {
12 true
13 } else {
14 false
15 }
16}
17
18pub fn check_phone(number: &str) -> bool {
19 let number = number.trim();
20 let length = number.len();
21
22 if length == 7 && number[0..].chars().all(|c| c.is_digit(10)) {
24 true
25 } else {
26 false
27 }
28}
29
30pub fn check_password(password: &str) -> bool {
31 let mut no_whitespace = vec![];
33 let mut has_upper = vec![];
34 let mut has_lower = vec![];
35 let mut has_digit = vec![];
36 let mut has_symbol = vec![];
37 let check_symbols_vec = vec![
38 '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '|', '-', '=', '\\', '<', ',',
39 '>', '.', '?', '/', '{', '[', '}', ']', ':', ';', '"', '\'',
40 ];
41
42 for c in password.chars() {
43 no_whitespace.push(c.is_whitespace());
44 has_lower.push(c.is_lowercase());
45 has_upper.push(c.is_uppercase());
46 has_symbol.push(check_symbols_vec.contains(&c));
47 has_digit.push(c.is_digit(10));
48 }
49
50 !no_whitespace.contains(&true)
60 && true
61 && has_lower.contains(&true)
62 && has_digit.contains(&true)
63 && true
64 && password.len() >= 8
65}