Validate confirmation email

This commit is contained in:
Andrés Moya 2020-06-08 09:47:53 +02:00 committed by Andrey Antukh
parent 68798522af
commit a4c7215fa8
3 changed files with 50 additions and 35 deletions

View file

@ -27,6 +27,15 @@
(s/def ::email-1 ::fm/email)
(s/def ::email-2 ::fm/email)
(defn- email-equality
[data]
(let [email-1 (:email-1 data)
email-2 (:email-2 data)]
(cond-> {}
(and email-1 email-2 (not= email-1 email-2))
(assoc :email-2 {:message (tr "errors.email-invalid-confirmation")}))))
(s/def ::email-change-form
(s/keys :req-un [::email-1 ::email-2]))
@ -59,6 +68,7 @@
[:& form {:on-submit on-submit
:spec ::email-change-form
:validators [email-equality]
:initial {}}
[:& input {:type "text"
:name :email-1

View file

@ -54,8 +54,7 @@
password-2 (:password-2 data)]
(cond-> {}
(and password-1 password-2
(not= password-1 password-2))
(and password-1 password-2 (not= password-1 password-2))
(assoc :password-2 {:message (tr "errors.password-invalid-confirmation")})
(and password-1 (> 8 (count password-1)))