Recipe edit (WIP): all form fields are now saved
This commit is contained in:
parent
07b7ff425e
commit
6876a254e1
12 changed files with 563 additions and 210 deletions
|
|
@ -6,7 +6,6 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
regex = "1"
|
||||
lazy_static = "1"
|
||||
|
||||
ron = "0.8"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
|
|
|||
|
|
@ -92,6 +92,36 @@ pub struct SetGroupComment {
|
|||
pub comment: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct SetStepAction {
|
||||
pub step_id: i64,
|
||||
pub action: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct SetIngredientName {
|
||||
pub ingredient_id: i64,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct SetIngredientComment {
|
||||
pub ingredient_id: i64,
|
||||
pub comment: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct SetIngredientQuantity {
|
||||
pub ingredient_id: i64,
|
||||
pub quantity: Option<f64>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct SetIngredientUnit {
|
||||
pub ingredient_id: i64,
|
||||
pub unit: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct Group {
|
||||
pub id: i64,
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue