Skip to content

Commit

Permalink
Merge e87a759 into 57e1518
Browse files Browse the repository at this point in the history
  • Loading branch information
auser committed Oct 17, 2016
2 parents 57e1518 + e87a759 commit 59107d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Schema.js
Expand Up @@ -68,7 +68,7 @@ export default class Schema extends Generator{
na = (fieldConfig.concatStrict) ? [...new Set(na)] : na
}

let length = fieldArrayCalcLength(fieldConfig, na.length)
let length = fieldArrayCalcLength(fieldConfig, na.length, this)

Array.from(new Array(length)).map(() => {
array.push(this.generateField(fieldConfig))
Expand Down
6 changes: 4 additions & 2 deletions src/utils.js
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 59107d1

Please sign in to comment.