stack/packages/stack-shared/src/helpers/password.ts
Konstantin Wohlwend 277356e4f6
Some checks failed
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Test / docker (push) Has been cancelled
Runs E2E API Tests / build (20.x) (push) Has been cancelled
Lint & build / lint_and_build (20.x) (push) Has been cancelled
Lint & build / lint_and_build (22.x) (push) Has been cancelled
Mirror main branch to main-mirror-for-wdb / lint_and_build (push) Has been cancelled
Publish Docs / run (push) Has been cancelled
Run setup tests / test (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
Cap password length at 70 characters
2025-02-15 12:18:20 -08:00

17 lines
404 B
TypeScript

import { KnownErrors } from "..";
const minLength = 8;
const maxLength = 70;
export function getPasswordError(password: string): KnownErrors["PasswordRequirementsNotMet"] | undefined {
if (password.length < minLength) {
return new KnownErrors.PasswordTooShort(minLength);
}
if (password.length > maxLength) {
return new KnownErrors.PasswordTooLong(maxLength);
}
return undefined;
}