Skip to content

Commit

Permalink
allow email to be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
CyonAlexRDX committed Jan 7, 2025
1 parent bd2cc90 commit 9661fd3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions crates/common/short-string/src/email_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ impl FromStr for EmailAddress {
impl EmailAddress {
pub fn new(email: impl AsRef<str>) -> Result<Self> {
let email = email.as_ref().to_owned();
if email.is_empty() {
return Err(CommonError::EmailAddressEmpty);
}
// Apparently we allows empty string?
// https://rdxworks.slack.com/archives/C031A0V1A1W/p1736262231737039?thread_ts=1736236976.987429&cid=C031A0V1A1W
ShortString::new(email).map(Self)
}
}
Expand Down Expand Up @@ -75,8 +74,8 @@ mod tests {
}

#[test]
fn invalid_empty() {
assert_eq!(EmailAddress::new(""), Err(CommonError::EmailAddressEmpty));
fn empty_is_valid() {
assert_eq!(EmailAddress::new("").unwrap().to_string(), String::new());
}

#[test]
Expand Down

0 comments on commit 9661fd3

Please sign in to comment.