Sign up form and other stuff
This commit is contained in:
parent
b1ffd1a04a
commit
45d4867cb3
18 changed files with 817 additions and 107 deletions
24
common/src/utils.rs
Normal file
24
common/src/utils.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
use regex::Regex;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
pub enum EmailValidation {
|
||||
Ok,
|
||||
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})").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,
|
||||
}
|
||||
|
||||
pub fn validate_password(password: &str) -> PasswordValidation {
|
||||
if password.len() < 8 { PasswordValidation::TooShort } else { PasswordValidation::Ok }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue