Rewrite README + use lettre crate to validate email address instead of regex
This commit is contained in:
parent
67e13d9074
commit
65489e7692
8 changed files with 62 additions and 85 deletions
|
|
@ -5,7 +5,5 @@ authors = ["Grégory Burri <greg.burri@gmail.com>"]
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
regex = "1"
|
||||
|
||||
ron = "0.8"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
|
|
|||
|
|
@ -1,29 +1,5 @@
|
|||
use std::sync::LazyLock;
|
||||
|
||||
use regex::Regex;
|
||||
|
||||
use crate::consts;
|
||||
|
||||
pub enum EmailValidation {
|
||||
Ok,
|
||||
NotValid,
|
||||
}
|
||||
|
||||
static EMAIL_REGEX: LazyLock<Regex> = LazyLock::new(|| {
|
||||
Regex::new(
|
||||
r"^([a-z0-9_+]([a-z0-9_+.]*[a-z0-9_+])?)@([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6})",
|
||||
)
|
||||
.expect("Error parsing email regex")
|
||||
});
|
||||
|
||||
pub fn validate_email(email: &str) -> EmailValidation {
|
||||
if EMAIL_REGEX.is_match(email) {
|
||||
EmailValidation::Ok
|
||||
} else {
|
||||
EmailValidation::NotValid
|
||||
}
|
||||
}
|
||||
|
||||
pub enum PasswordValidation {
|
||||
Ok,
|
||||
TooShort,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue