export const PATTERN = { EMAIL : '(([^<>()[\\]\\\\.,;:\\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,}))' , UUID_V4 : '[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}' , } ; export function isUUIDv4 ( candidate ) { const uuidv4Regex = new RegExp ( `^${ PATTERN . UUID_V4 }$` , 'i' ) ; return uuidv4Regex . test ( candidate ) ; } export function isValidEmail ( email ) { const regExp = new RegExp ( `^${ PATTERN . EMAIL }$` , 'i' ) ; return regExp . test ( email ) ; } export function isValidHandle ( handle ) { return /^[a-z_0-9.-]{2,256}$/ . test ( handle ) ; } export const DEFAULT_PASSWORD_MIN_LENGTH = 8 ; export const DEFAULT_PASSWORD_MAX_LENGTH = 120 ; export function getNewPasswordPattern ( minLength = DEFAULT_PASSWORD_MIN_LENGTH , maxLength = DEFAULT_PASSWORD_MAX_LENGTH ) { return `(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[^0-9a-zA-Z]).{${ minLength },${ maxLength }}$` ; }