Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add max phone number length to user creation form #9952

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/Users/CreateUserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,12 @@ export default function CreateUserForm({ onSubmitSuccess }: Props) {
<FormItem>
<FormLabel>{t("phone_number")}</FormLabel>
<FormControl>
<Input type="tel" placeholder="+91XXXXXXXXXX" {...field} />
<Input
type="tel"
placeholder="+91XXXXXXXXXX"
maxLength={13}
{...field}
/>
Comment on lines +315 to +320
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Phone number validation requirements are overly restrictive

The current implementation enforces a strict Indian phone number format, but the codebase has utilities (parsePhoneNumber, formatPhoneNumber) that support more flexible phone number handling. Consider:

  • Using the existing phone utilities to allow formatted input (spaces, hyphens)
  • Supporting international numbers since the codebase already has this capability
  • Maintaining +91 validation only if it's a strict business requirement

Example locations that handle phone numbers more flexibly:

  • src/Utils/utils.ts: parsePhoneNumber() and formatPhoneNumber()
  • src/pages/PublicAppointments/auth/PatientLogin.tsx: Phone validation with formatting
🔗 Analysis chain

Verify phone number validation requirements.

The current implementation enforces:

  • Exactly 13 characters
  • Must start with +91
  • Exactly 10 digits after +91

Please confirm if these strict requirements align with the business needs:

  1. Should international numbers be supported?
  2. Should spaces or hyphens be allowed for formatting?
  3. Should shorter emergency numbers be allowed?

Also applies to: 337-337

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other phone number validation patterns in the codebase
rg -l "phone.*validation|phone.*regex" --type ts --type tsx

Length of output: 89


Script:

#!/bin/bash
# Search for phone-related validation patterns in TypeScript files
rg -t typescript -t javascriptreact -t typescriptreact "phone.*validation|phone.*regex|phoneNumber|phone.*schema" -A 5

# Search for form validation schemas
rg -t typescript -t typescriptreact "schema.*phone|validate.*phone" -A 5

# Search for test files related to phone validation
fd ".*\.(test|spec)\.(ts|tsx)$" --exec rg -l "phone|mobile"

Length of output: 327


Script:

#!/bin/bash
# Search for validation schema in CreateUserForm.tsx
rg "phone" src/components/Users/CreateUserForm.tsx -A 5 -B 5

# Search for validation-related imports and schemas
rg "import.*yup|import.*zod|schema.*=|validation.*=|phone.*=" src/components/Users/CreateUserForm.tsx

# Search for phone-related patterns in the entire codebase
rg "phone.*validation|phoneNumber|phone.*schema" --type-add 'ts:*.{ts,tsx}' -t ts

Length of output: 12071

</FormControl>
<FormMessage />
</FormItem>
Expand All @@ -329,6 +334,7 @@ export default function CreateUserForm({ onSubmitSuccess }: Props) {
<Input
placeholder="+91XXXXXXXXXX"
type="tel"
maxLength={13}
{...field}
disabled={isWhatsApp}
/>
Expand Down
Loading