From 5bc510b37c4a09aa60e69ab4cc7113758f1ca901 Mon Sep 17 00:00:00 2001
From: devs-rootstrap <112487182+devs-rootstrap@users.noreply.github.com>
Date: Tue, 10 Nov 2026 09:04:49 -0300
Subject: [PATCH] fix(auth): drop password length rule from sign-in form
---
__tests__/components/login-form.test.tsx | 32 +++++++++++++++++++-
docs/src/content/docs/ui-and-theme/Forms.mdx | 4 +--
src/components/login-form.tsx | 3 +-
src/translations/en.json | 1 -
4 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/__tests__/components/login-form.test.tsx b/__tests__/components/login-form.test.tsx
index 95888de40..e0e615766 100644
--- a/__tests__/components/login-form.test.tsx
+++ b/__tests__/components/login-form.test.tsx
@@ -1,4 +1,4 @@
-import { cleanup, fireEvent, render, screen } from '@/lib/test-utils';
+import { cleanup, fireEvent, render, screen, waitFor } from '@/lib/test-utils';
import { LoginForm } from '../../src/components/login-form';
@@ -35,4 +35,34 @@ describe('LoginForm Form ', () => {
expect(screen.queryByText(/Email is required/i)).not.toBeOnTheScreen();
expect(await screen.findByText(/Invalid Email Format/i)).toBeOnTheScreen();
});
+
+ it('should display required error when password is cleared', async () => {
+ render();
+
+ const passwordInput = screen.getByTestId('password-input');
+ fireEvent.changeText(screen.getByTestId('email-input'), 'user@example.com');
+ fireEvent.changeText(passwordInput, '123');
+ fireEvent.changeText(passwordInput, '');
+ fireEvent.press(screen.getByTestId(LOGIN_BUTTON));
+
+ expect(await screen.findByText(/Password is required/i)).toBeOnTheScreen();
+ });
+
+ it('should submit with a short password without a length error', async () => {
+ const onSubmit = jest.fn();
+ render();
+
+ fireEvent.changeText(screen.getByTestId('email-input'), 'user@example.com');
+ fireEvent.changeText(screen.getByTestId('password-input'), '123');
+ fireEvent.press(screen.getByTestId(LOGIN_BUTTON));
+
+ await waitFor(() => {
+ expect(onSubmit).toHaveBeenCalledWith(
+ { email: 'user@example.com', password: '123' },
+ undefined,
+ );
+ });
+ expect(screen.queryByText(/at least/i)).not.toBeOnTheScreen();
+ expect(screen.queryByText(/Password is required/i)).not.toBeOnTheScreen();
+ });
});
diff --git a/docs/src/content/docs/ui-and-theme/Forms.mdx b/docs/src/content/docs/ui-and-theme/Forms.mdx
index 11a1ffc58..5c23e7c2b 100644
--- a/docs/src/content/docs/ui-and-theme/Forms.mdx
+++ b/docs/src/content/docs/ui-and-theme/Forms.mdx
@@ -40,7 +40,7 @@ import z from 'zod';
const schema = z.object({
email: z.string().email(),
- password: z.string().min(6),
+ password: z.string().min(1),
});
type FormType = z.infer;
@@ -61,7 +61,7 @@ import { Button, ControlledInput, View } from '@/components/ui';
const schema = z.object({
email: z.string().email(),
- password: z.string().min(6),
+ password: z.string().min(1),
});
type FormType = z.infer;
diff --git a/src/components/login-form.tsx b/src/components/login-form.tsx
index b41cf6e93..72e358cf8 100644
--- a/src/components/login-form.tsx
+++ b/src/components/login-form.tsx
@@ -9,14 +9,13 @@ import { object, string } from 'zod';
import { Button, ControlledInput, Text, View } from '@/components/ui';
import { translate } from '@/lib';
-const MIN_CHARS = 6;
const schema = object({
email: string({
required_error: translate('auth.signIn.validation.emailRequired'),
}).email(translate('auth.signIn.validation.invalidEmail')),
password: string({
required_error: translate('auth.signIn.validation.passwordRequired'),
- }).min(MIN_CHARS, translate('auth.signIn.validation.passwordMinChars')),
+ }).min(1, translate('auth.signIn.validation.passwordRequired')),
});
export type FormType = z.infer;
diff --git a/src/translations/en.json b/src/translations/en.json
index 58d57b6eb..bae586dee 100644
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -16,7 +16,6 @@
"validation": {
"emailRequired": "Email is required",
"invalidEmail": "Invalid email format",
- "passwordMinChars": "Password must be at least 6 characters",
"passwordRequired": "Password is required"
}
},