File tree Expand file tree Collapse file tree 3 files changed +8
-1
lines changed
packages/payload/src/fields Expand file tree Collapse file tree 3 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ export const email: EmailFieldValidation = (
200
200
* Supports multiple subdomains (e.g., user@sub.domain.example.com)
201
201
*/
202
202
const emailRegex =
203
- / ^ (? ! .* \. \. ) [ \w . % + - ] + @ [ a - z 0 - 9 ] (?: [ a - z 0 - 9 - ] * [ a - z 0 - 9 ] ) ? (?: \. [ a - z 0 - 9 ] (?: [ a - z 0 - 9 - ] * [ a - z 0 - 9 ] ) ? ) * \. [ a - z ] { 2 , } $ / i
203
+ / ^ (? ! .* \. \. ) [ \w ! # $ % & ' * + / = ? ^ ` { | } ~ . - ] + @ [ a - z 0 - 9 ] (?: [ a - z 0 - 9 - ] * [ a - z 0 - 9 ] ) ? (?: \. [ a - z 0 - 9 ] (?: [ a - z 0 - 9 - ] * [ a - z 0 - 9 ] ) ? ) * \. [ a - z ] { 2 , } $ / i
204
204
205
205
if ( ( value && ! emailRegex . test ( value ) ) || ( ! value && required ) ) {
206
206
return t ( 'validation:emailAddress' )
Original file line number Diff line number Diff line change @@ -1016,6 +1016,7 @@ describe('Auth', () => {
1016
1016
expect ( emailValidation ( 'user.name+alias@example.co.uk' , mockContext ) ) . toBe ( true )
1017
1017
expect ( emailValidation ( 'user-name@example.org' , mockContext ) ) . toBe ( true )
1018
1018
expect ( emailValidation ( 'user@ex--ample.com' , mockContext ) ) . toBe ( true )
1019
+ expect ( emailValidation ( "user'payload@example.org" , mockContext ) ) . toBe ( true )
1019
1020
} )
1020
1021
1021
1022
it ( 'should not allow emails with double quotes' , ( ) => {
@@ -1045,5 +1046,11 @@ describe('Auth', () => {
1045
1046
expect ( emailValidation ( 'user@-example.com' , mockContext ) ) . toBe ( 'validation:emailAddress' )
1046
1047
expect ( emailValidation ( 'user@example-.com' , mockContext ) ) . toBe ( 'validation:emailAddress' )
1047
1048
} )
1049
+ it ( 'should not allow emails that start with dot' , ( ) => {
1050
+ expect ( emailValidation ( '.user@example.com' , mockContext ) ) . toBe ( 'validation:emailAddress' )
1051
+ } )
1052
+ it ( 'should not allow emails that have a comma' , ( ) => {
1053
+ expect ( emailValidation ( 'user,name@example.com' , mockContext ) ) . toBe ( 'validation:emailAddress' )
1054
+ } )
1048
1055
} )
1049
1056
} )
You can’t perform that action at this time.
0 commit comments