forked from Archives/Athou_commafeed
make password match rule reusable
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { msg } from "@lingui/core/macro"
|
||||
import { useLingui } from "@lingui/react"
|
||||
import { Trans } from "@lingui/react/macro"
|
||||
import { Anchor, Box, Button, Checkbox, Divider, Group, Input, PasswordInput, Stack, Text, TextInput } from "@mantine/core"
|
||||
@@ -29,7 +28,7 @@ export function ProfileSettings() {
|
||||
const form = useForm<FormData>({
|
||||
validate: {
|
||||
newPassword: validationRules.password,
|
||||
newPasswordConfirmation: (value, values) => (value !== values.newPassword ? _(msg`Passwords do not match`) : null),
|
||||
newPasswordConfirmation: (value, values) => validationRules.passwordConfirmation(value, values.newPassword),
|
||||
},
|
||||
validateInputOnChange: true,
|
||||
})
|
||||
|
||||
@@ -11,5 +11,7 @@ export function useValidationRules() {
|
||||
value && minimumPasswordLength && value.length < minimumPasswordLength
|
||||
? _(msg`Password must be at least ${minimumPasswordLength} characters`)
|
||||
: null,
|
||||
passwordConfirmation: (newPasswordConfirmation: string | undefined, newPassword: string | undefined) =>
|
||||
newPasswordConfirmation && newPasswordConfirmation !== newPassword ? _(msg`Passwords do not match`) : null,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "استعادة كلمة المرور"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "كلمات المرور غير متطابقة"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Recuperació de contrasenya"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Les contrasenyes no coincideixen"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Obnovení hesla"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Hesla se neshodují"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Adfer Cyfrinair"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Nid yw cyfrineiriau yn cyfateb"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Gendannelse af adgangskode"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Adgangskoder stemmer ikke overens"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Passwortwiederherstellung"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Passwörter stimmen nicht überein"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr "Password must be at least {minimumPasswordLength} characters"
|
||||
msgid "Password Recovery"
|
||||
msgstr "Password Recovery"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Passwords do not match"
|
||||
|
||||
|
||||
@@ -795,8 +795,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Recuperación de contraseña"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Las contraseñas no coinciden"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "بازیابی رمز عبور"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "گذرواژه ها مطابقت ندارند"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Salasanan palautus"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Salasanat eivät täsmää"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Récupération de mot de passe"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Les mots de passe ne correspondent pas"
|
||||
|
||||
|
||||
@@ -795,8 +795,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Recuperación do contrasinal"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Os contrasinais non coinciden"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Jelszó helyreállítás"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "A jelszavak nem egyeznek"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Pemulihan Kata Sandi"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Kata sandi tidak cocok"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Recupero password"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Le password non corrispondono"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "パスワード回復"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "パスワードが一致しません"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "비밀번호 복구"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "비밀번호가 일치하지 않습니다"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Pemulihan Kata Laluan"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Kata laluan tidak sepadan"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Passordgjenoppretting"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Passordene samsvarer ikke"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Wachtwoordherstel"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Wachtwoorden komen niet overeen"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Passordgjenoppretting"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Passordene samsvarer ikke"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Odzyskiwanie hasła"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Hasła nie pasują"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Recuperação de Senha"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Senhas não coincidem"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Восстановление пароля"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Пароли не совпадают"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Obnovenie hesla"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Heslá sa nezhodujú"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Lösenordsåterställning"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Lösenorden matchar inte"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr ""
|
||||
msgid "Password Recovery"
|
||||
msgstr "Parola Kurtarma"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "Parolalar eşleşmiyor"
|
||||
|
||||
|
||||
@@ -794,8 +794,7 @@ msgstr "密码最少需要 {minimumPasswordLength} 个字符"
|
||||
msgid "Password Recovery"
|
||||
msgstr "密码恢复"
|
||||
|
||||
#: src/components/settings/ProfileSettings.tsx
|
||||
#: src/pages/auth/PasswordResetPage.tsx
|
||||
#: src/hooks/useValidationRules.ts
|
||||
msgid "Passwords do not match"
|
||||
msgstr "密码不匹配"
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ export function PasswordResetPage() {
|
||||
},
|
||||
validate: {
|
||||
password: validationRules.password,
|
||||
passwordConfirmation: (value, values) => (value === values.password ? null : _(msg`Passwords do not match`)),
|
||||
passwordConfirmation: (value, values) => validationRules.passwordConfirmation(value, values.password),
|
||||
},
|
||||
validateInputOnChange: true,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user