deku-prop-types
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -5,2 +5,6 @@ 'use strict'; | ||
var _arrayJoinConjunction = require('array-join-conjunction'); | ||
var _arrayJoinConjunction2 = _interopRequireDefault(_arrayJoinConjunction); | ||
var _checkerFactory = require('checker-factory'); | ||
@@ -14,6 +18,6 @@ | ||
get any() { | ||
return (0, _checkerFactory2.default)('any'); | ||
return (0, _checkerFactory2.default)(); | ||
}, | ||
get array() { | ||
return (0, _checkerFactory2.default)('array', function (prop, key) { | ||
return (0, _checkerFactory2.default)(function (prop, key) { | ||
if (!Array.isArray(prop)) { | ||
@@ -27,3 +31,3 @@ var actualType = typeof prop === 'undefined' ? 'undefined' : _typeof(prop); | ||
return function (validator) { | ||
return (0, _checkerFactory2.default)('arrayOf', function (prop, key) { | ||
return (0, _checkerFactory2.default)(function (prop, key) { | ||
if (!Array.isArray(prop)) { | ||
@@ -43,10 +47,10 @@ var actualType = typeof prop === 'undefined' ? 'undefined' : _typeof(prop); | ||
get bool() { | ||
return (0, _checkerFactory2.default)('bool', 'boolean'); | ||
return (0, _checkerFactory2.default)('boolean'); | ||
}, | ||
get func() { | ||
return (0, _checkerFactory2.default)('func', 'function'); | ||
return (0, _checkerFactory2.default)('function'); | ||
}, | ||
get instanceOf() { | ||
return function (constructor) { | ||
return (0, _checkerFactory2.default)('instanceOf', function (prop, key) { | ||
return (0, _checkerFactory2.default)(function (prop, key) { | ||
if (!(prop instanceof constructor)) { | ||
@@ -62,10 +66,10 @@ /* eslint-disable prefer-reflect */ | ||
get number() { | ||
return (0, _checkerFactory2.default)('number', 'number'); | ||
return (0, _checkerFactory2.default)('number'); | ||
}, | ||
get object() { | ||
return (0, _checkerFactory2.default)('object', 'object'); | ||
return (0, _checkerFactory2.default)('object'); | ||
}, | ||
get objectOf() { | ||
return function (validator) { | ||
return (0, _checkerFactory2.default)('objectOf', function (prop, key) { | ||
return (0, _checkerFactory2.default)(function (prop, key) { | ||
var propKeys = Object.keys(prop); | ||
@@ -85,3 +89,3 @@ | ||
return function (allowedValues) { | ||
return (0, _checkerFactory2.default)('oneOf', function (prop, key) { | ||
return (0, _checkerFactory2.default)(function (prop, key) { | ||
var isAllowed = allowedValues.some(function (value) { | ||
@@ -91,3 +95,7 @@ return value === prop; | ||
if (!isAllowed) { | ||
return new TypeError(key + ' is not one of the allowed values'); | ||
var valuesMsg = (0, _arrayJoinConjunction2.default)(allowedValues.map(function (v) { | ||
return '`' + v + '`'; | ||
}), 'or'); | ||
var errMsg = 'Expected ' + key + ' to be ' + valuesMsg + ', but got `' + prop + '`'; | ||
return new TypeError(errMsg); | ||
} | ||
@@ -99,3 +107,3 @@ }); | ||
return function (allowedTypes) { | ||
return (0, _checkerFactory2.default)('oneOfType', function (prop, key) { | ||
return (0, _checkerFactory2.default)(function (prop, key) { | ||
var isAllowed = !allowedTypes.every(function (type) { | ||
@@ -112,3 +120,3 @@ return type.validate(prop) instanceof Error; | ||
return function (propsObj) { | ||
return (0, _checkerFactory2.default)('shape', function (prop, key) { | ||
return (0, _checkerFactory2.default)(function (prop, key) { | ||
var validators = Object.keys(propsObj); | ||
@@ -127,4 +135,4 @@ | ||
get string() { | ||
return (0, _checkerFactory2.default)('string', 'string'); | ||
return (0, _checkerFactory2.default)('string'); | ||
} | ||
}; |
{ | ||
"name": "deku-prop-types", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Prop type validation for Deku components", | ||
@@ -49,4 +49,5 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"checker-factory": "^1.0.0" | ||
"array-join-conjunction": "^1.0.0", | ||
"checker-factory": "^2.0.0" | ||
} | ||
} |
@@ -25,3 +25,3 @@ # deku-prop-types | ||
const Counter = ({props}) => <div>{props.count}</div> | ||
Count.propTypes = { | ||
Counter.propTypes = { | ||
count: PropTypes.number.isRequired | ||
@@ -28,0 +28,0 @@ } |
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
13644
175
2
+ Addedarray-join-conjunction@1.0.0(transitive)
+ Addedchecker-factory@2.1.0(transitive)
- Removedchecker-factory@1.0.0(transitive)
Updatedchecker-factory@^2.0.0