breezehottowel

how to view breeze client validation errors


I have read through the breeze validator information, but am not sure how to view the actual error that is occurring.

Error: client side validation errors encountered - see the entity Errors collection on this object for more detail.

I believe it's somewhere in entity.entityAspect.getValidationErrors() but am having trouble figuring out how to get the actual error out of it.

I am trying to insert a record into an entity and save changes when this error message occurs.


Solution

  • See :

    http://www.breezejs.com/sites/all/apidocs/classes/ValidationError.html

    http://www.breezejs.com/sites/all/apidocs/classes/EntityAspect.html#method_getValidationErrors

    Simple example:

    var errors = entity.entityAspect.getValidationErrors();
    errors.forEach(function(ve) {
       var errorMessage = ve.errorMessage;
       var property = ve.property;
    });
    

    To get all of the errors in an EntityManager you can use

    manager.getEntities().forEach(function(entity) { 
       var errors = entity.entityAspect.getValidationErrors();
       //.. do something with the errors ..
    });