I define a one to many relationship. A customer can have many orders but an order can belong to only one customer. An order can have many itemcodes but an item code can only belong to one order. An order has a required field: DateCreated
. And an Item with itemcode has a required field, ItemName
. From HERE I understand the use of custom validators in breeze.
But say I create a customer entity with multiple orders. I then add another order with a null DateCreated
field, thus making this entity invalid. If i try to validate the customer entity using customer.entityAspect.validateEntity()
, should breeze be able to validate each item in the orders and result that the customer entity is invalid because it has an order with no DateCreated
?
Similarly if I add an item to an order with no ItemName
, will breeze still determine that the customer is invalid because it contains an order with one item lacking an item name? That is, will breeze validate any depth of nested relationships?
I have been trying this for a while but to no avail. Collections defined in EF are not just validated when I use entity.entityAspect.validateEntity()
, but the validation fails when I try saving. If I try validating the order entity itself ('order.entityAspect.validateEntity()') or the Item Entity itself (item.entityAspect.validateEntity()
), the validation works fine. I just does not when I try validating the parent entity: customer(customer.entityAspect.validateEntity()
). I am wondering if this is normal or I am doing something wrong. Should this validation be handled using custom validators?