![Greenkeeper badge](https://badges.greenkeeper.io/jaebradley/email-prop-type.svg)
Email Prop Type
Introduction
This package is used to validate if a React Prop value is a valid email.
Currently, there is no email prop type defined by the prop-types
package. While using PropType.string
works, why not be as specific as possible when validating your props?
Additionally, though it's relatively straightforward to create a custom prop type validator, if you need to implement similar prop type checking in multiple packages, you might not want to repeat yourself.
Depends on the isemail
package. While the isemail
package has options to specify various error levels, email-prop-type
implements the highest level of granularity, i.e. a perfectly granular email address.
Installation
npm install --save email-prop-type
Example Usage
import React from 'react';
import PropTypes from 'prop-types';
import emailPropType from 'email-prop-type';
const Hyperlink = props => (
<a href={`${mailto:props.emailAddress}`>{props.text}</a>
);
Hyperlink.propTypes = {
text: PropTypes.string.isRequired,
emailAddress: emailPropType.isRequired,
};
Alternatives
I didn't see many alternatives: