diff options
Diffstat (limited to 'src/constants/regex.ts')
-rw-r--r-- | src/constants/regex.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/constants/regex.ts b/src/constants/regex.ts new file mode 100644 index 00000000..350cb855 --- /dev/null +++ b/src/constants/regex.ts @@ -0,0 +1,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}$/; |