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