Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-moment-proptypes

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-moment-proptypes - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0

.eslintrc

76

index.js
var moment = require('moment');
function momentObj(props, propName, componentName, location) {
var propValue = props[propName];
if (! moment.isMoment(propValue)) {
var propType = typeof propValue;
return new Error(
'Invalid ' + location + '`' + propName + '` of type `' + propType + '` ' +
'supplied to `' + componentName + '`, expected `Moment`.'
);
}
return null;
var ANONYMOUS = '<<anonymous>>';
var ReactPropTypeLocationNames = {
prop : 'prop',
context : 'context',
childContext : 'child context',
};
function momentString(props, propName, componentName, location) {
var propValue = props[propName];
if (moment.utc(propValue).format() === 'Invalid date') {
var propType = typeof propValue;
return new Error(
'Invalid ' + location + '`' + propName + '` of type `' + propType + '` ' +
'supplied to `' + componentName + '`, expected `Moment`.'
);
function createMomentChecker(validator) {
function propValidator(isRequired, props, propName, componentName, location, propFullName) {
if (isRequired) {
var locationName = ReactPropTypeLocationNames[ location ];
componentName = componentName || ANONYMOUS;
propFullName = propFullName || propName;
return new Error(
'Required ' + locationName + ' `' + propFullName +
'` was not specified in `' +
componentName + '`.'
);
}
var propValue = props[ propName ];
if (typeof propValue === 'undefined') {
return null;
}
if (validator(propValue)) {
var propType = typeof propValue;
return new Error(
'Invalid ' + location + ' `' + propName + '` of type `' + propType + '` ' +
'supplied to `' + componentName + '`, expected `Moment`.'
);
}
return null;
}
return null;
};
var requiredPropValidator = propValidator.bind(null, false);
requiredPropValidator.isRequired = propValidator.bind(null, true);
return requiredPropValidator;
}
module.exports = {
momentObj : momentObj,
momentString : momentString,
momentObj : createMomentChecker(function(value) {
return !moment.isMoment(value);
}),
momentString : createMomentChecker(function(value) {
return moment.utc(value).format() === 'Invalid date';
}),
};
{
"name": "react-moment-proptypes",
"version": "0.0.5",
"version": "0.1.0",
"description": "React proptype for moment module",
"keywords": [
"moment",
"react",
"props",
"proptypes"
],
"main": "index.js",
"repository": {
"type" : "git",
"url" : "git@github.com:CalebMorris/react-moment-proptypes.git"
"type": "git",
"url": "git@github.com:CalebMorris/react-moment-proptypes.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"clean": "rm -Rf ./coverage",
"test": "./node_modules/.bin/mocha --recursive --compilers js:babel/register",
"lint": "./node_modules/.bin/eslint --ext .js .",
"lint-quiet": "./node_modules/.bin/eslint --ext .js --quiet .",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --recursive --compilers js:babel/register"
},

@@ -20,3 +30,11 @@ "author": {

"moment": ">=1.5.0"
},
"devDependencies": {
"babel": "^5.6.23",
"chai": "^2.3.0",
"eslint": "^0.24.0",
"istanbul": "^0.3.13",
"mocha": "^2.2.1",
"react": "^0.13.3"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc