-
-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Config validation was moved to util.
- Loading branch information
1 parent
863ef3b
commit bb36408
Showing
3 changed files
with
40 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,39 @@ | ||
import { isFunction } from 'lodash' | ||
import { getEventsFromInput } from './events' | ||
export { getEventsFromInput } from './events' | ||
|
||
/** | ||
* @private | ||
* @description Create a function if not already one | ||
* @param {Function|Object|Array|String} Callable function or value of return for new function | ||
*/ | ||
export const createCallable = f => isFunction(f) ? f : () => f | ||
|
||
export { | ||
getEventsFromInput | ||
} | ||
/** | ||
* @private | ||
* @description Validate config input | ||
* @param {Object} Config object containing all combined configs | ||
*/ | ||
export const validateConfig = (config) => { | ||
// require needed Firebase config | ||
const requiredProps = [ | ||
'databaseURL', | ||
'authDomain', | ||
'apiKey' | ||
] | ||
requiredProps.forEach((p) => { | ||
if (!config[p]) { | ||
throw new Error(`${p} is a required config parameter for react-redux-firebase.`) | ||
} | ||
}) | ||
|
||
export default { | ||
createCallable, | ||
getEventsFromInput | ||
// Check that some certain config are functions if they exist | ||
const functionProps = [ | ||
'fileMetadataFactory', | ||
'profileDecorator' | ||
] | ||
functionProps.forEach((p) => { | ||
if (!!config[p] && !isFunction(config[p])) { | ||
throw new Error(`${p} parameter in react-redux-firebase config must be a function. check your compose function.`) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters