nova-forms 0.1.11

Build online forms with ease.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::cell::LazyCell;
use regex::Regex;
use super::{Field, FieldError, Rule};

pub struct EmailRule;

impl Rule for EmailRule {
    const REGEX: LazyCell<Regex> =
        LazyCell::new(|| Regex::new(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$").unwrap());
    const DEFAULT: &'static str = "test@example.com";
    const ATTRIBUTES: &'static [(&'static str, &'static str)] = &[("type", "email")];
}

pub type Email = Field<EmailRule>;
pub type EmailError = FieldError<EmailRule>;