email-prop-type
Advanced tools
Comparing version 1.1.7 to 2.0.0
@@ -1,32 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _emailValidator = _interopRequireDefault(require("email-validator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var requiredEmailPropType = function requiredEmailPropType(props, propName, componentName) { | ||
var value = props[propName]; | ||
if (value == null || typeof value !== 'string' || !_emailValidator.default.validate(value)) { | ||
return new TypeError("Invalid Email Prop Value: ".concat(value, " for ").concat(propName, " in ").concat(componentName)); | ||
} | ||
return null; | ||
}; | ||
var emailPropType = function emailPropType(props, propName, componentName) { | ||
if (props[propName] == null) { | ||
return null; | ||
} | ||
return requiredEmailPropType(props, propName, componentName); | ||
}; | ||
emailPropType.isRequired = requiredEmailPropType; | ||
var _default = emailPropType; | ||
exports.default = _default; | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("email-validator")):"function"==typeof define&&define.amd?define(["email-validator"],n):e["email-prop-type"]=n(null)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var n=function(n,t,r){var i=n[t];return null!=i&&"string"==typeof i&&e.validate(i)?null:new TypeError("Invalid Email Prop Value: ".concat(i," for ").concat(t," in ").concat(r))},t=function(e,t,r){return null==e[t]?null:n(e,t,r)};return t.isRequired=n,t}); |
{ | ||
"name": "email-prop-type", | ||
"version": "1.1.7", | ||
"description": "React Prop Types Email Validator", | ||
"main": "./build/index.js", | ||
"version": "2.0.0", | ||
"description": "React Email Prop Type", | ||
"keywords": [ | ||
"react", | ||
"email", | ||
"email prop-type", | ||
"email prop", | ||
"email prop-types", | ||
"email props" | ||
], | ||
"files": [ | ||
"build" | ||
], | ||
"browser": "build/index.js", | ||
"main": "build/index.cjs.js", | ||
"module": "build/index.esm.js", | ||
"scripts": { | ||
"build": "BABEL_ENV=production rollup -c", | ||
"codecov": "codecov", | ||
"commitmsg": "commitlint -e $GIT_PARAMS", | ||
"compile": "babel -d build/ src/ --delete-dir-on-start", | ||
"deploy": "npm run travis-deploy-once 'npm run semantic-release'", | ||
"gc": "commit", | ||
"lint": "eslint --ext .js .", | ||
"test": "jest src/ --coverage --no-cache", | ||
"prepublishOnly": "npm run compile", | ||
"semantic-commit": "commit", | ||
"prepare": "npm run build", | ||
"semantic-release": "semantic-release", | ||
"test": "BABEL_ENV=test jest src/ --coverage --no-cache", | ||
"travis-deploy-once": "travis-deploy-once" | ||
@@ -21,6 +35,2 @@ }, | ||
}, | ||
"keywords": [ | ||
"react", | ||
"prop-types" | ||
], | ||
"author": "jae.b.bradley@gmail.com", | ||
@@ -32,5 +42,14 @@ "license": "MIT", | ||
"homepage": "https://github.com/jaebradley/email-prop-type#readme", | ||
"readme": "https://github.com/jaebradley/email-prop-type#readme", | ||
"jest": { | ||
"testEnvironment": "node" | ||
"testEnvironment": "node", | ||
"testPathIgnorePatterns": [ | ||
"<rootDir>/build/", | ||
"<rootDir>/node_modules/" | ||
] | ||
}, | ||
"dependencies": {}, | ||
"peerDependencies": { | ||
"email-validator": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
@@ -47,2 +66,3 @@ "@babel/cli": "^7.0.0-beta.47", | ||
"codecov": "^3.0.2", | ||
"email-validator": "^2.0.0", | ||
"eslint": "^4.12.0", | ||
@@ -53,8 +73,13 @@ "eslint-config-airbnb-base": "^12.1.0", | ||
"jest": "^22.0.3", | ||
"rollup": "^0.58.2", | ||
"rollup-plugin-babel": "^4.0.0-beta.4", | ||
"rollup-plugin-babel-minify": "^4.0.0", | ||
"rollup-plugin-commonjs": "^9.1.3", | ||
"rollup-plugin-filesize": "^1.5.0", | ||
"rollup-plugin-local-resolve": "^1.0.7", | ||
"rollup-plugin-node-resolve": "^3.3.0", | ||
"rollup-plugin-uglify": "^3.0.0", | ||
"semantic-release": "^15.0.0", | ||
"travis-deploy-once": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"email-validator": "^2.0.0" | ||
} | ||
} |
@@ -0,1 +1,4 @@ | ||
# `email-prop-type` | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/jaebradley/email-prop-type.svg)](https://greenkeeper.io/) | ||
[![Build Status](https://travis-ci.org/jaebradley/email-prop-type.svg?branch=master)](https://travis-ci.org/jaebradley/email-prop-type) | ||
@@ -5,9 +8,7 @@ [![codecov](https://codecov.io/gh/jaebradley/email-prop-type/branch/master/graph/badge.svg)](https://codecov.io/gh/jaebradley/email-prop-type) | ||
[![npm](https://img.shields.io/npm/v/email-prop-type.svg)](https://www.npmjs.com/package/email-prop-type) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/jaebradley/email-prop-type.svg)](https://greenkeeper.io/) | ||
# Email Prop Type | ||
## Introduction | ||
This package is used to validate if a React Prop value is a valid email. | ||
This package is used to validate if a React Prop value is a valid email address. | ||
Currently, there is no email prop type defined by [the `prop-types` package](https://www.npmjs.com/package/prop-types). While using `PropType.string` works, why not be as specific as possible when validating your props? | ||
@@ -17,8 +18,14 @@ | ||
Depends on [the `isemail` package](https://www.npmjs.com/package/isemail). While the `isemail` package has options to [specify various error levels](https://github.com/hapijs/isemail#validateemail-options-callback), `email-prop-type` implements the highest level of granularity, i.e. a perfectly granular email address. | ||
Depends on [the `email-validator` package](https://github.com/Sembiance/email-validator). | ||
## Installation | ||
`npm install --save email-prop-type` | ||
```bash | ||
npm install --save email-prop-type | ||
``` | ||
As mentioned above, `email-prop-type` depends on the `email-validator` package. You need to install this package as a peer dependency of `email-prop-type`. | ||
## Example Usage | ||
```javascript | ||
@@ -41,4 +48,6 @@ import React from 'react'; | ||
## Alternatives | ||
I didn't see many alternatives: | ||
* It doesn't look like [the `airbnb/prop-types` project](https://github.com/airbnb/prop-types) has email validation. | ||
* There's also [the `react-validator-prop-types` library](https://www.npmjs.com/package/react-validator-prop-types) but if you just want email validation, it might be too heavyweight. | ||
* It doesn't look like [the `airbnb/prop-types` project](https://github.com/airbnb/prop-types) has email validation. | ||
* There's also [the `react-validator-prop-types` library](https://www.npmjs.com/package/react-validator-prop-types) but if you just want email validation, it might be too heavyweight. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7282
51
26
6
7
2
1
- Removedemail-validator@^2.0.0