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

Fix username modal check proceed button #104

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
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: 5 additions & 3 deletions src/components/UsernameModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ const UsernameModal = ({ open, handleClose: close }) => {
return;
}

const usernamePattern = /^[a-z0-9._]{1,30}$/;
const usernamePattern = /^(?=.*[a-z])[a-z0-9._]{1,30}$/;
const invalidStartPattern = /^[._]/;

if (
!usernamePattern.test(username) ||
invalidStartPattern.test(username)
) {
setUsernameError(
'Invalid username. Only lower case letters, numbers, underscores, and periods are allowed. Username must be between 1 and 30 characters and cannot start with a period or underscore.'
'Invalid username. Only lower case letters, numbers, underscores, and periods are allowed. Username must be between 1 and 30 characters, contain at least one letter and cannot start with a period or underscore.'
);
} else {
setUsernameError('');
Expand Down Expand Up @@ -170,7 +170,9 @@ const UsernameModal = ({ open, handleClose: close }) => {
variant='contained'
fullWidth
disabled={
username?.length > 0 && username?.length <= 30
!Boolean(usernameError) &&
username?.length > 0 &&
username?.length <= 30
? false
: true
}
Expand Down