Skip to content

Commit

Permalink
fix: updates username validation to allow for all special character u…
Browse files Browse the repository at this point in the history
…sage (#9946)

### What?

Previously, only `.` & `-` special chars were allowed in usernames

### How?

Now - all special chars are accepted during username creating like `@`
  • Loading branch information
PatrikKozak authored Dec 12, 2024
1 parent d57cad6 commit 7a8b464
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/payload/src/fields/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ export const username: UsernameFieldValidation = (
return t('validation:shorterThanMax', { maxLength })
}

if ((value && !/^[\w.-]+$/.test(value)) || (!value && required)) {
return t('validation:username')
if (!value && required) {
return t('validation:required')
}

return true
Expand Down

0 comments on commit 7a8b464

Please sign in to comment.