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 PhoneRule;

impl Rule for PhoneRule {
    const REGEX: LazyCell<Regex> =
        LazyCell::new(|| Regex::new(r"^\+?[0-9]{1,3}[0-9]{3,14}$").unwrap());
    const DEFAULT: &'static str = "+41791234567";
    const ATTRIBUTES: &'static [(&'static str, &'static str)] = &[("type", "phone")];
}

pub type Phone = Field<PhoneRule>;
pub type PhoneError = FieldError<PhoneRule>;