isEmail.js.flow 540 B

1234567891011121314151617
  1. /**
  2. * Copyright (c) 2013-present, Facebook, Inc.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @providesModule isEmail
  8. */
  9. // good approximation of RFC 2822
  10. // http://www.regular-expressions.info/email.html
  11. var re = /^[\w!#\$%&'\*\+\/\=\?\^`\{\|\}~\-]+(:?\.[\w!#\$%&'\*\+\/\=\?\^`\{\|\}~\-]+)*@(?:[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?$/i;
  12. function isEmail(email) {
  13. return re.test(email);
  14. }
  15. module.exports = isEmail;