onasty/web/src/Validators.elm (view raw)
Olexandr Smirnov
Olexandr Smirnov
ss2316544@gmail.com feat(web): add account settings (#190)..., 9 months ago
ss2316544@gmail.com feat(web): add account settings (#190)..., 9 months ago
| 1 | module Validators exposing (email, password, passwords) |
| 2 | |
| 3 | |
| 4 | email : String -> Maybe String |
| 5 | email inp = |
| 6 | if |
| 7 | not (String.isEmpty inp) |
| 8 | && (not (String.contains "@" inp) && not (String.contains "." inp)) |
| 9 | then |
| 10 | Just "Please enter a valid email address." |
| 11 | |
| 12 | else |
| 13 | Nothing |
| 14 | |
| 15 | |
| 16 | password : String -> Maybe String |
| 17 | password passwd = |
| 18 | if not (String.isEmpty passwd) && String.length passwd < 8 then |
| 19 | Just "Password must be at least 8 characters long." |
| 20 | |
| 21 | else |
| 22 | Nothing |
| 23 | |
| 24 | |
| 25 | passwords : String -> String -> Maybe String |
| 26 | passwords passowrd1 password2 = |
| 27 | if not (String.isEmpty passowrd1) && passowrd1 /= password2 then |
| 28 | Just "Passwords do not match." |
| 29 | |
| 30 | else |
| 31 | Nothing |