Skip to main content

systemprompt_api/services/
validation.rs

1pub fn is_valid_email(email: &str) -> bool {
2    let email = email.trim();
3    let Some((local, domain)) = email.split_once('@') else {
4        return false;
5    };
6    if local.is_empty() || domain.is_empty() {
7        return false;
8    }
9    if email.chars().filter(|c| *c == '@').count() != 1 {
10        return false;
11    }
12    if !domain.contains('.') || domain.starts_with('.') || domain.ends_with('.') {
13        return false;
14    }
15    true
16}