0
我有一個Breeze實體,它具有多個其他實體的集合。當爲第一個實體檢索驗證錯誤時,我還想從其集合中的每個實體中檢索錯誤。從微風實體集合屬性中檢索驗證錯誤
因此,如果我有一個實體Foo
與許多Bars
和Bazs
。有沒有檢索沿myFoo.getAllValidatioErrors()
我有一個Breeze實體,它具有多個其他實體的集合。當爲第一個實體檢索驗證錯誤時,我還想從其集合中的每個實體中檢索錯誤。從微風實體集合屬性中檢索驗證錯誤
因此,如果我有一個實體Foo
與許多Bars
和Bazs
。有沒有檢索沿myFoo.getAllValidatioErrors()
這裏的線Foo
爲Bars
和Bazs
驗證錯誤一個通用的方法是你可以做的一種方式:
// get primary entity's validation errors.
var validationErrors = entity.entityAspect.getValidationErrors()
// concat all child entity validation errors...
.concat(
// grab every navigation property array.
entity.entityType.navigationProperties
.filter(function (propertyInfo) { return !propertyInfo.isScalar; })
.map(function (propertyInfo) { return entity[propertyInfo.name]; })
// flatten the array of entity-arrays into one big array of entities.
.reduce(function (a, b) { return a.concat(b); })
// validate the entities.
.map(function (childEntity) { return childEntity.getValidationErrors(); })
// flatten the array of ValidationError-arrays into one big array of validation errors.
.reduce(function (a, b) { return a.concat(b); })
);
獲得上線。降低錯誤(函數(a,b){return a.concat(b);})。它說a不是一個功能 – jpo 2015-02-02 16:54:10