Skip to content

Commit

Permalink
Update utils.js
Browse files Browse the repository at this point in the history
Check for `length` as a function.
  • Loading branch information
auser committed Oct 17, 2016
1 parent 6d8e490 commit e87a759
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ export const evalWithContextData = function (key, object, db) {
return eval(key)
}

export const fieldArrayCalcLength = function (config, fixedArrayLength) {
export const fieldArrayCalcLength = function (config, fixedArrayLength, schema) {
let length
if (config.fixedLength) {
if (typeof config.length === 'function') {
length = config.length.call(schema);
} else if (config.fixedLength) {
length = config.length - fixedArrayLength
} else {
length = Math.floor((Math.random() * config.length) + 1)
Expand Down

0 comments on commit e87a759

Please sign in to comment.