1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
//! Lightweight structural email-address validation used for request-input //! checks. //! //! Copyright (c) systemprompt.io — Business Source License 1.1. //! See <https://systemprompt.io> for licensing details. pub fn is_valid_email(email: &str) -> bool { let email = email.trim(); let Some((local, domain)) = email.split_once('@') else { return false; }; if local.is_empty() || domain.is_empty() { return false; } if email.chars().filter(|c| *c == '@').count() != 1 { return false; } if !domain.contains('.') || domain.starts_with('.') || domain.ends_with('.') { return false; } true }