MCPcopy Create free account
hub / github.com/0010aor/FlashNotes / confirmPasswordRules

Function confirmPasswordRules

frontend/src/utils.ts:38–58  ·  view source on GitHub ↗
(getValues: () => unknown, isRequired = true)

Source from the content-addressed store, hash-verified

36}
37
38export const confirmPasswordRules = (getValues: () => unknown, isRequired = true) => {
39 const rules: {
40 validate: (value: string) => boolean | string
41 required?: string
42 } = {
43 validate: (value: string) => {
44 const formValues = getValues() as {
45 password?: string
46 new_password?: string
47 }
48 const password = formValues.password || formValues.new_password
49 return value === password ? true : t('general.errors.passwordsDoNotMatch')
50 },
51 }
52
53 if (isRequired) {
54 rules.required = t('general.errors.passwordConfirmationIsRequired')
55 }
56
57 return rules
58}
59
60export const handleError = (
61 err: ApiError,

Callers 1

SignUpFunction · 0.90

Calls 1

tFunction · 0.85

Tested by

no test coverage detected