reuse validation rule

This commit is contained in:
Athou
2026-01-16 01:08:25 +01:00
parent 5a95b95801
commit 5f30cb7e2e
32 changed files with 82 additions and 155 deletions

View 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,
}
}