Apply payload validation to initial object state

This commit is contained in:
Kai Moseley 2016-12-05 16:54:15 +00:00
parent 128c55bc52
commit 6ff5c56a2a
1 changed files with 1 additions and 1 deletions

View File

@ -82,7 +82,7 @@ function calculateDefaults(reducerStructure) {
function createReducer(objectStructure: StructureType, behaviors: ObjectReducerBehaviors): ObjectReducer {
const initialState = calculateDefaults(objectStructure().structure);
const initialState = validateObject(objectStructure, calculateDefaults(objectStructure().structure));
return (state = initialState, { type, payload }: ObjectReducerAction) => {
//If the action type does not match any of the specified behaviors, just return the current state.
if (!behaviors[type]) return state;