Comparing version 3.3.0 to 3.4.0
{ | ||
"name": "incarnate", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "Dependency Injection (DI) with Lifecycle features for JavaScript.", | ||
@@ -5,0 +5,0 @@ "main": "src/Incarnate.jsx", |
@@ -6,3 +6,4 @@ import T from 'prop-types'; | ||
static INCARNATE_LABEL = 'Incarnate'; | ||
static DEPENDENCY_LABEL = 'Dependency'; | ||
static DEPENDENCY_DECLARATION_LABEL = 'Dependency Declaration'; | ||
static DEPENDENCY_DECLARATION_PROPERTY_LABEL = 'Dependency Declaration Property'; | ||
static DEFAULT_PATH_DELIMITER = '.'; | ||
@@ -20,20 +21,34 @@ static ERRORS = { | ||
static validateDependencyDeclaration(dependencyDeclaration, dependencyName) { | ||
const validatorShape = { | ||
subMap: T.bool, | ||
required: T.arrayOf(T.string), | ||
optional: T.arrayOf(T.string), | ||
getters: T.arrayOf(T.string), | ||
setters: T.arrayOf(T.string), | ||
invalidators: T.arrayOf(T.string), | ||
listeners: T.arrayOf(T.string), | ||
factory: T.func.isRequired | ||
}; | ||
static validateDependencyDeclaration(dependencyDeclaration, dependencyName = Incarnate.DEPENDENCY_DECLARATION_LABEL) { | ||
if (dependencyDeclaration instanceof Object) { | ||
const validatorShape = { | ||
subMap: T.bool, | ||
required: T.arrayOf(T.string), | ||
optional: T.arrayOf(T.string), | ||
getters: T.arrayOf(T.string), | ||
setters: T.arrayOf(T.string), | ||
invalidators: T.arrayOf(T.string), | ||
listeners: T.arrayOf(T.string), | ||
factory: T.func.isRequired | ||
}; | ||
const validPropList = Object.keys(validatorShape); | ||
const dependencyPropList = Object.keys(dependencyDeclaration); | ||
T.checkPropTypes( | ||
validatorShape, | ||
dependencyDeclaration, | ||
Incarnate.DEPENDENCY_LABEL, | ||
`${Incarnate.INCARNATE_LABEL}: ${dependencyName}` | ||
); | ||
dependencyPropList.forEach(key => { | ||
if (validPropList.indexOf(key) === -1) { | ||
console.warn( | ||
`Warning: Invalid ${Incarnate.DEPENDENCY_DECLARATION_PROPERTY_LABEL} \`${key}\` in \`${Incarnate.INCARNATE_LABEL}: ${dependencyName}\`.` | ||
); | ||
} | ||
}); | ||
T.checkPropTypes( | ||
validatorShape, | ||
dependencyDeclaration, | ||
Incarnate.DEPENDENCY_DECLARATION_PROPERTY_LABEL, | ||
`${Incarnate.INCARNATE_LABEL}: ${dependencyName}` | ||
); | ||
} else { | ||
console.warn(`Warning: Invalid ${Incarnate.DEPENDENCY_DECLARATION_LABEL} \`${dependencyName}\`.`); | ||
} | ||
} | ||
@@ -40,0 +55,0 @@ |
@@ -47,2 +47,3 @@ import expect from 'expect.js'; | ||
Incarnate.validateDependencyDeclaration({ | ||
junk: true, | ||
subMap: 10, | ||
@@ -49,0 +50,0 @@ required: 9, |
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
29296
786