import { lowerCaseValidator, numberValidator, symbolValidator, upperCaseValidator, } from "#/utils/validators"; import { PasswordComplexitySettings } from "@zitadel/server"; type Props = { passwordComplexitySettings: PasswordComplexitySettings; password: string; equals: boolean; }; const check = ( Matches ); const cross = ( Doesn't match ); const desc = "text-14px leading-4 text-input-light-label dark:text-input-dark-label"; export default function PasswordComplexity({ passwordComplexitySettings, password, equals, }: Props) { const hasMinLength = password?.length >= passwordComplexitySettings.minLength; const hasSymbol = symbolValidator(password); const hasNumber = numberValidator(password); const hasUppercase = upperCaseValidator(password); const hasLowercase = lowerCaseValidator(password); return (
{passwordComplexitySettings.minLength != undefined ? (
{hasMinLength ? check : cross} Password length {passwordComplexitySettings.minLength}
) : ( )}
{hasSymbol ? check : cross} has Symbol
{hasNumber ? check : cross} has Number
{hasUppercase ? check : cross} has uppercase
{hasLowercase ? check : cross} has lowercase
{equals ? check : cross} equals
); }