I have a use-case where I want to access whether or not ANY entities within my BreezeJS EntityManager has validation errors. Basically a "hasValidationErrors" on the EntityManager.
The use-case is simply that I want to disable a "Save changes" button on the UI, and since I am using the Angular Binding system it should be a fast operation.
To me, it seems that this does not exist, and am wondering if there are any simple workaround or any actual ways of accomplishing it.
The closest I've come is the following:
var mgr = new breeze.EntityManager(
{
serviceName: "/breeze/Model/"
});
var errorCount = 0;
mgr.validationErrorsChanged.subscribe(function (validationChangeArgs) {
var added = validationChangeArgs.added;
if (added) {
errorCount += added.length;
}
var removed = validationChangeArgs.removed;
if (removed) {
errorCount -= removed.length;
}
});
And then using errorCount to see if there are any validation errors. But this approach does not take into consideration if an entity is detached when it has validation errors. (For example through a call to rejectChanges() on the EntityManager).
It also feels like a very "hackish" approach.