react-entity
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "react-entity", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Create entities base on React propTypes", | ||
@@ -5,0 +5,0 @@ "main": "lib/ReactEntity.js", |
@@ -35,7 +35,6 @@ const createGetterAndSetter = function (instance, field){ | ||
for(var field in this.data){ | ||
if (this.data[field].fetch){ | ||
rawData[field] = this.data[field].fetch; | ||
}else{ | ||
rawData[field] = this.data[field] | ||
} | ||
rawData[field] = this.fetchChild(this.data[field]) | ||
} | ||
@@ -47,2 +46,15 @@ | ||
fetchChild(fieldValue){ | ||
if (Array.isArray(fieldValue)){ | ||
return fieldValue = fieldValue.map(fetchChild) | ||
} | ||
if (fieldValue.fetch){ | ||
return fieldValue.fetch; | ||
} | ||
return fieldValue | ||
} | ||
validateField(field) { | ||
@@ -49,0 +61,0 @@ const type = typeof(this.schema[field]) === 'function' ? |
10015
165