[Validation Issue]: Profile name accepts invalid inputs like single dot (.) or single space ( )
Describe the bug
The profile name field incorrectly allows a single dot (.) or a single space ( ). These are not valid names. Double dots (..) and double spaces ( ) are rejected correctly.
Steps To Reproduce
- After App starts up
- Go to Admin Control and enter the Admin pin
- Select Edit Profiles
- Click and Rename any profile(New/Admin) with single dot (.) or a single space ( )
Expected Behavior
- Profile names should require at least one valid letter
- Inputs that are only special characters or spaces should not be accepted
Screenshots/Videos
https://github.com/user-attachments/assets/a6f34375-6427-4ccf-b302-42d98c59b637
What device/emulator are you using?
Vivo v21e
Which Android version is your device/emulator running?
Android 13
Which version of the Oppia Android app are you using?
0.16-beta-5f3e75afa7
Additional Context
No response
From a quick glance at https://github.com/oppia/oppia-android/blob/develop/utility/src/main/java/org/oppia/android/util/profile/ProfileNameValidator.kt this appears to be an existing issue with the validator, and one that we perhaps missed in the original implementation. We should probably prohibit symbols starting names and instead require letters only.
Hey, @reshmimahadevan if the issue is still open, I would like to take this up
Hi @satnam-singh-JustCode, I would be happy to assign this to you. Have you began your repo set up?
Hi @satnam-singh-JustCode, I would be happy to assign this to you. Have you began your repo set up?
yup
Hi @satnam-singh-JustCode, how is it going with this issue?
If the person is not active I can try to solve the issue. You can assign it to me.
Planning to get into contributing to Oppia with this issue, seems simple enough and think can be fixed pretty easily. I have already setup the project and managed to recreate the issue. If no one else is currently working on this i will proceed with it? @adhiamboperes
Hi @satnam-singh-JustCode , are you still working on this issue?
Unasssigning @satnam-singh-JustCode due to inactivity. Please feel free to work on this @ShankhanilSaha
@adhiamboperes I have fixed the issue by adding another function notOnlySymbols(name) in the isNameValid(name), function in utility/src/main/java/org/oppia/android/util/profile/ProfileNameValidator.kt this checks the name and verifies whether the name is of only symbols.
When running the command java -jar ../oppia-android-tools/ktlint -F --android domain/src/**/*.kt utility/src/**/*.kt data/src/**/*.kt app/src/**/*.kt testing/src/**/*.kt scripts/src/**/*.kt instrumentation/src/**/*.kt for format checks i get and error saying word limit of line exceeded.
/home/shankhanil/opensource/oppia-android/utility/src/main/java/org/oppia/android/util/profile/ProfileNameValidator.kt:21:1: Exceeded max line length (100) (cannot be auto-corrected)
is there anyways this check excludes this particular line on this file? or i should find another way to fix this.
Also shall I add validation that the name does not start with a symbol?
@ShankhanilSaha, is it possible to check that the name doesn’t contain any symbols, i.e. letters and spaces only? Then we only need one function
@adhiamboperes , yeah it sure is, but some special symbols like hyphens and dots are included in the special symbol list which ig should be allowed.
I was thinking we could maybe change the function for checking repeated smbols to something along checkSymbolsFormatting(name) ehich checks bost repeated symbols and wheather it is a symbol only name.
From a quick glance at https://github.com/oppia/oppia-android/blob/develop/utility/src/main/java/org/oppia/android/util/profile/ProfileNameValidator.kt this appears to be an existing issue with the validator, and one that we perhaps missed in the original implementation. We should probably prohibit symbols starting names and instead require letters only.
@ShankhanilSaha, please see the quoted comment posted by @BenHenning above. Instead of adding any new functions, we instead want to make the naming standard stricter, by prohibiting any symbols in fun isNameValid. We should also trim the profile name before validation, which will remove extra spaces and ensure a blank space cannot be accepted as a name.
@adhiamboperes , okay then. I will try making a isNameValid() function with stricter rules.
@adhiamboperes please review the implementation method of the PR.
Hi everyone 👋,
I’ve reviewed ProfileNameValidator.kt and the discussion around this PR. Initially, I considered using a regex-based approach, but after understanding that Oppia supports multilingual input, I think it’s better to keep the Unicode-safe validation logic. To make the validation simpler and stricter, we could add a concise pre-check to ensure the name isn’t blank, has a meaningful length, and includes at least one alphabetic character using Oppia’s existing isAlphabetic() helper:
""" val trimmed = name.trim() if (!trimmed.isNotBlank() || trimmed.length < 2 || !trimmed.any { it.isAlphabetic() }) return false """
This would reject names made only of spaces or symbols (like "." or " ") while preserving valid names such as "Anne-Marie" or "O’Connor". Just sharing this as an idea that might help make the validator simpler and more consistent — and if the current PR needs further updates or becomes inactive, I’d be glad to help implement it. 🙂
@ShankhanilSaha Is you are still working on this issue?
@itsadityaaaaa yes i am.