UNPKG

@root-systems/redux-form-validators

Version:
16 lines (12 loc) 613 B
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