import size from 'lodash/size'

export const emailRegex = '[a-z0-9!#$%&/\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&/\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?'

const emailRegExp = new RegExp(emailRegex)

export const isValidEmail = (email: string) => (
  emailRegExp.test(email.toLowerCase()) && size(email) <= 100
)
