UNPKG

apphouse

Version:

Component library for React that uses observable state management and theme-able components.

14 lines (13 loc) 417 B
/** * Helper function that checks if string is an email and it is valid * The default validation function for email fields if none is provided * @param str the email string to validate * @returns boolean true if valid email */ export function validateEmail(str: string) { const emailFormat = /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/; if (str.match(emailFormat)) { return true; } return false; }