Skip to content

Commit

Permalink
Fix the applying of the item schema's factory and / or serialize meth…
Browse files Browse the repository at this point in the history
…ods by IterableSchema's
  • Loading branch information
JaapRood committed Apr 3, 2017
1 parent 703b014 commit ab4c5a7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ const _isFunction = require('lodash.isfunction')

const internals = {}

internals.idenity = (val) => val

internals.IterableSchema = function(iterable, itemSchema) {
Invariant(_isFunction(iterable), 'Iterable constructor required to create IterableSchema')
Invariant(exports.isType(itemSchema) || exports.isSchema(itemSchema), 'Item schema or type required to create IterableSchema')

_assign(this, {
getItemSchema: () => itemSchema,
factory: (val) => iterable(val),
serialize: (val) => val.toJS()
factory: (val) => iterable(val).map(itemSchema.factory || internals.idenity),
serialize: (val) => val.map(itemSchema.serialize || internals.idenity).toJS()
})
}

Expand Down

0 comments on commit ab4c5a7

Please sign in to comment.