react-moment-proptypes
Advanced tools
Comparing version 1.5.0 to 1.6.0
{ | ||
"name": "react-moment-proptypes", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "React proptype for moment module", | ||
@@ -19,3 +19,3 @@ "keywords": [ | ||
"coveralls": "cat ./coverage/lcov.info | coveralls", | ||
"test": "./node_modules/.bin/mocha --recursive --compilers js:babel/register", | ||
"test": "./node_modules/.bin/mocha --recursive --compilers js:babel/register --require ./test/suppress-fallback-warning.js", | ||
"test-all": "npm run test-1.6 && npm run test-1.7 && npm run test-latest", | ||
@@ -27,3 +27,3 @@ "test-1.6": "rm -Rf ./node_modules/moment/ && npm i moment@1.6.0 && npm test", | ||
"lint-quiet": "./node_modules/.bin/eslint --ext .js --quiet .", | ||
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter dot --recursive --compilers js:babel/register" | ||
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter dot --recursive --compilers js:babel/register --require ./test/suppress-fallback-warning.js" | ||
}, | ||
@@ -30,0 +30,0 @@ "author": { |
@@ -39,2 +39,18 @@ # react-moment-proptypes | ||
# Moment Configuration | ||
## createFromInputFallback | ||
Moment provides a `moment.createFromInputFallback` method you can define to create additional parsing rules. | ||
With some versions of moment you may receive the following console warning: | ||
``` | ||
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info. | ||
Arguments: | ||
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: not a date, _f: undefined, _strict: undefined, _locale: [object Object] | ||
Error | ||
at [... stack trace] | ||
``` | ||
Example implementations can be found at the [given documentation link](http://momentjs.com/guides/#/warnings/js-date/). | ||
# Tests | ||
@@ -41,0 +57,0 @@ |
@@ -38,2 +38,23 @@ var messages = { | ||
var independentGuardianValue = -1; | ||
function preValidationRequireCheck(isRequired, componentName, propFullName, propValue) { | ||
var isPropValueUndefined = typeof propValue === 'undefined'; | ||
var isPropValueNull = propValue === null; | ||
if (isRequired) { | ||
if (isPropValueUndefined) { | ||
return createInvalidRequiredErrorMessage(propFullName, componentName, 'undefined'); | ||
} else if (isPropValueNull) { | ||
return createInvalidRequiredErrorMessage(propFullName, componentName, 'null'); | ||
} | ||
} | ||
if (isPropValueUndefined || isPropValueNull) { | ||
return null; | ||
} | ||
return independentGuardianValue; | ||
} | ||
function createMomentChecker(type, typeValidator, validator, momentType) { | ||
@@ -53,17 +74,11 @@ | ||
var isPropValueUndefined = typeof propValue === 'undefined'; | ||
var isPropValueNull = propValue === null; | ||
componentName = componentName || messages.anonymousMessage; | ||
propFullName = propFullName || propName; | ||
if (isRequired) { | ||
componentName = componentName || messages.anonymousMessage; | ||
propFullName = propFullName || propName; | ||
if (isPropValueUndefined) { | ||
return createInvalidRequiredErrorMessage(propFullName, componentName, 'undefined'); | ||
} else if (isPropValueNull) { | ||
return createInvalidRequiredErrorMessage(propFullName, componentName, 'null'); | ||
} | ||
} | ||
var preValidationRequireCheckValue = preValidationRequireCheck( | ||
isRequired, componentName, propFullName, propValue | ||
); | ||
if (isPropValueUndefined || isPropValueNull) { | ||
return null; | ||
if (preValidationRequireCheckValue !== independentGuardianValue) { | ||
return preValidationRequireCheckValue; | ||
} | ||
@@ -78,3 +93,3 @@ | ||
if (! validator(propValue)) { | ||
if (!validator(propValue)) { | ||
return new Error( | ||
@@ -86,3 +101,3 @@ messages.baseInvalidMessage + location + ' `' + propName + '` of type `' + propType + '` ' + | ||
if (predicate && ! predicate(propValue)) { | ||
if (predicate && !predicate(propValue)) { | ||
var predicateName = predicate.name || messages.anonymousMessage; | ||
@@ -89,0 +104,0 @@ return new Error( |
@@ -5,6 +5,2 @@ var moment = require('moment'); | ||
moment.createFromInputFallback = function(config) { | ||
config._d = new Date(config._i); | ||
}; | ||
module.exports = { | ||
@@ -11,0 +7,0 @@ |
@@ -28,3 +28,3 @@ import { before, after } from 'mocha'; | ||
before(() => { | ||
sinon.stub(console, 'error', (warning) => { | ||
sinon.stub(console, 'error').callsFake((warning) => { | ||
throw new TestUtilError(warning); | ||
@@ -31,0 +31,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
50597
1010
67
0