@kaspernj/api-maker 1.0.198 → 1.0.199
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
const {digg} = require("diggerize")
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const propTypesValidator = (expectedClassName, args = {}) => (props, propName, componentName) => {
|
|
4
4
|
const prop = digg(props, propName)
|
|
5
|
+
|
|
6
|
+
if (!prop) {
|
|
7
|
+
if (args.required) {
|
|
8
|
+
return new Error(`The prop \`${propName}\` is marked as required in \`${componentName}\`, but its value is \`${typeof prop}\`.`)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
5
14
|
const className = digg(prop, "constructor", "name")
|
|
6
15
|
|
|
7
16
|
if (className != expectedClassName) {
|
|
@@ -9,4 +18,12 @@ const instanceOfClassName = (expectedClassName) => (props, propName, componentNa
|
|
|
9
18
|
}
|
|
10
19
|
}
|
|
11
20
|
|
|
21
|
+
const instanceOfClassName = (expectedClassName) => {
|
|
22
|
+
const validator = propTypesValidator(expectedClassName)
|
|
23
|
+
|
|
24
|
+
validator.isRequired = propTypesValidator(expectedClassName, {required: true})
|
|
25
|
+
|
|
26
|
+
return validator
|
|
27
|
+
}
|
|
28
|
+
|
|
12
29
|
module.exports = instanceOfClassName
|