mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
fix: fix email verification regex & unittests (#139)
This commit is contained in:
@ -12,7 +12,7 @@ pub fn validate_email(email: &str) -> CustomResult<(), ValidationError> {
|
|||||||
#[deny(clippy::invalid_regex)]
|
#[deny(clippy::invalid_regex)]
|
||||||
static EMAIL_REGEX: Lazy<Option<Regex>> = Lazy::new(|| {
|
static EMAIL_REGEX: Lazy<Option<Regex>> = Lazy::new(|| {
|
||||||
match Regex::new(
|
match Regex::new(
|
||||||
r"^(?i)[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$",
|
r"^(?i)[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$",
|
||||||
) {
|
) {
|
||||||
Ok(regex) => Some(regex),
|
Ok(regex) => Some(regex),
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
@ -92,11 +92,9 @@ mod tests {
|
|||||||
prop_assert!(validate_email(&email).is_err());
|
prop_assert!(validate_email(&email).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make maybe unit test working
|
#[test]
|
||||||
// minimal failing input: email = "+@a"
|
fn proptest_invalid_email(email in "[.+]@(.+)") {
|
||||||
// #[test]
|
prop_assert!(validate_email(&email).is_err());
|
||||||
// fn proptest_invalid_email(email in "[.+]@(.+)") {
|
}
|
||||||
// prop_assert!(validate_email(&email).is_err());
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user