aboutsummaryrefslogtreecommitdiff
path: root/src/constants/regex.ts
blob: 350cb8555435764d1a8580a8102212ccf01f9bcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
 * The email regex has complex constraints compliant with RFC 5322 standards. More details can be found [here](https://emailregex.com/).
 */
export const emailRegex: RegExp = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

/**
 * The password regex has the following constraints
 * - min. 8 chars, max. 120 chars ({8,120})
 * - at least one numeric digit ([0-9])
 * - at least one lowercase letter ([a-z])
 * - at least one uppercase letter ([A-Z])
 * - at least one special character ([^a-zA-z0-9])
 */
export const passwordRegex: RegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,120}$/;

/**
 * The username regex has the following constraints
 * - min. 6 chars, max. 30 chars ({6,30})
 * - match only alphanumerics, underscores, and periods
 */
export const usernameRegex: RegExp = /^[a-zA-Z0-9_.]{6,30}$/;