feat(auth): add validatePassword function with requirements for min and max characters amount, presence of at least one uppercase letter, one lowercase letter, one digit and one special symbol; cover it with tests

This commit is contained in:
Ilia Mashkov
2026-03-25 10:34:54 +03:00
parent 5b49398665
commit 6d81eaba4b
4 changed files with 87 additions and 5 deletions

View File

@@ -4,7 +4,7 @@ import { login, logout, register } from "../../../api";
import { callApi } from "shared/utils";
import { UNEXPECTED_ERROR_MESSAGE } from "shared/api";
import { selectAuthData, selectFormValid } from "../../selectors";
import { validateEmail } from "../../../lib";
import { validateEmail, validatePassword } from "../../../lib";
export const defaultStoreState: Readonly<AuthStoreState> = {
formData: {
@@ -16,10 +16,6 @@ export const defaultStoreState: Readonly<AuthStoreState> = {
error: null,
};
function validatePassword(password: string): boolean {
return Boolean(password);
}
export const useAuthStore = create<AuthStore>()((set, get) => ({
...defaultStoreState,