Recipe edit (WIP): all form fields are now saved

This commit is contained in:
Greg Burri 2024-12-27 00:39:23 +01:00
parent 07b7ff425e
commit 6876a254e1
12 changed files with 563 additions and 210 deletions

View file

@ -1,4 +1,5 @@
use lazy_static::lazy_static;
use std::sync::LazyLock;
use regex::Regex;
pub enum EmailValidation {
@ -6,12 +7,12 @@ pub enum EmailValidation {
NotValid,
}
lazy_static! {
static ref EMAIL_REGEX: Regex = Regex::new(
r"^([a-z0-9_+]([a-z0-9_+.]*[a-z0-9_+])?)@([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6})"
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");
}
.expect("Error parsing email regex")
});
pub fn validate_email(email: &str) -> EmailValidation {
if EMAIL_REGEX.is_match(email) {