refactor(web): one password rule and one wording for account-form errors (DRY W4)
The 8-character minimum was written into sign-up, reset, Settings › Account and Admin › Users as minlength="8" and a message, and each page mapped password_too_short, username_invalid and username_taken to its own copy of the same sentence. lib/auth/password.ts now holds the minimum, the hint and "Passwords do not match.", and the pages take an error code's wording from the shared error copy (knownCopy), falling back to their own. username_invalid's shared copy now states the rule (3–32 characters: letters, numbers, underscores, hyphens), as the pages did, on web and Android alike. Account's mismatch line reads "Passwords do not match." like the other forms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,12 @@ import errorCopyJson from '../styles/error-copy.json';
|
||||
|
||||
export const ERROR_COPY: Readonly<Record<string, string>> = errorCopyJson;
|
||||
|
||||
/** The fixed copy for a known error code, or undefined for any other code,
|
||||
so a form can fall back to its own wording. */
|
||||
export function knownCopy(code: string | null | undefined): string | undefined {
|
||||
return code && code !== 'unknown' ? ERROR_COPY[code] : undefined;
|
||||
}
|
||||
|
||||
export function copyForCode(code: string | null | undefined): string {
|
||||
if (!code) return ERROR_COPY.unknown ?? 'Something went wrong.';
|
||||
return ERROR_COPY[code] ?? ERROR_COPY.unknown ?? 'Something went wrong.';
|
||||
|
||||
Reference in New Issue
Block a user