all files / src/ email.js

100% Statements 14/14
100% Branches 4/4
100% Functions 2/2
100% Lines 9/9
1 branch Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16           21× 21×      
import React from 'react'
import { FormattedMessage } from 'react-intl'
import { regFormat } from './helpers'
 
export var REG_EMAIL = /^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i
 
// To be extracted by react-intl
let EMAIL_ERROR = (<FormattedMessage id="form.errors.email" defaultMessage="is not a valid email" />)
 
// Uses "format" internally which is already memoized
let email = function (options) {
  options = Object.assign({}, options)
  return regFormat(options, REG_EMAIL, EMAIL_ERROR)
}
 
export default email