forked from Archives/Athou_commafeed
reuse validation rule
This commit is contained in:
15
commafeed-client/src/hooks/useValidationRules.ts
Normal file
15
commafeed-client/src/hooks/useValidationRules.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { msg } from "@lingui/core/macro"
|
||||
import { useLingui } from "@lingui/react"
|
||||
import { useAppSelector } from "@/app/store"
|
||||
|
||||
export function useValidationRules() {
|
||||
const minimumPasswordLength = useAppSelector(state => state.server.serverInfos?.minimumPasswordLength)
|
||||
const { _ } = useLingui()
|
||||
|
||||
return {
|
||||
password: (value: string | undefined) =>
|
||||
value && minimumPasswordLength && value.length < minimumPasswordLength
|
||||
? _(msg`Password must be at least ${minimumPasswordLength} characters`)
|
||||
: null,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user